How to send a key event to another process?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mirxon@gmail.com

    How to send a key event to another process?

    Hello,
    I'm working on a C program under Ubuntu.
    It's basd on socket.
    Browser calls a client cgi (C program), and send some parameters to
    server (C program).
    Server runs another program (ooimpress, open office ppt), and
    translate the commands from client to a key event, and send it to
    child process.

    For example.
    first, after openning xxx.odp on server, I need to display it in "full
    screen mode", so I need to send "F5" from server program to child
    process "ooimpress" .

    Now, I need to send F5, ESC, char n, and char p. and
    I open the child process by using pipe (popen), and I send (fputc) the
    command key to the pipe.......

    But I cannot get the correct result......The ppt doesn't respond
    anything......


    My question is,
    1, if I can implement this under pipe, how should I do,
    2, if I cannot implement this under pipe, how should I do.

    My main goal is open ooimpress, and control it to show next, previous
    slide, esc, and full screen (F5 is hotkey for that).

    Thanks a lot!!

    Patrick
  • Keith Thompson

    #2
    Re: How to send a key event to another process?

    Mirxon@gmail.co m writes:
    I'm working on a C program under Ubuntu.
    It's basd on socket.
    Browser calls a client cgi (C program), and send some parameters to
    server (C program).
    Server runs another program (ooimpress, open office ppt), and
    translate the commands from client to a key event, and send it to
    child process.
    [snip]

    There's no way to do this in standard C. Try comp.unix.progr ammer, or
    perhaps a Linux or Ubuntu forum.

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

    Comment

    • Jens Thoms Toerring

      #3
      Re: How to send a key event to another process?

      Mirxon@gmail.co m wrote:
      I'm working on a C program under Ubuntu.
      It's basd on socket.
      Sorry, but you will be in for a bad surprise, sockets (and
      networking at all) aren't part of the C language, they are
      deal with (often system specific libraries).
      Browser calls a client cgi (C program), and send some parameters to
      server (C program).
      Hmm, a browser doesn't call a "client cgi". A browser may
      send a request to a HTTP server which, in turn, may invoke
      a CGI script/program (written in whatever language, but you
      will find that it's rarely C).
      Server runs another program (ooimpress, open office ppt), and
      translate the commands from client to a key event, and send it to
      child process.
      Why should the HTTP server run such a program? Many servers
      may run all day without even screen attached, so running one
      of those programs will be rather futile.
      For example.
      first, after openning xxx.odp on server, I need to display it in "full
      screen mode", so I need to send "F5" from server program to child
      process "ooimpress" .
      Sorry, but I guess you've got a lot of things mixed up here.
      Now, I need to send F5, ESC, char n, and char p. and
      I open the child process by using pipe (popen), and I send (fputc) the
      command key to the pipe.......
      Now you seem to be talking about two processes on a UNIX-
      like platform. That doesn't fit too well with the browser
      (client) and HTTP server things you wrote about before.
      Just note that pipes and the popen() function are POSIX
      terms, they have no real meaning when it comes to the
      language C.
      But I cannot get the correct result......The ppt doesn't respond
      anything......
      I guess you're trying something with certain programs that
      are installed on your machine. But from a language point of
      view C doesn't support networking by any built-in functions,
      it doesn't have a native popen() function (or anything for
      pipes) and definitely doesn't have any special built-in support
      for dealing with program like "ooimpress" or "open office".
      My question is,
      1, if I can implement this under pipe, how should I do,
      2, if I cannot implement this under pipe, how should I do.
      My main goal is open ooimpress, and control it to show next, previous
      slide, esc, and full screen (F5 is hotkey for that).
      I find it difficult to come up with proposals where you should
      ask since you mix too many unrelated things into a single
      question. So a few tentative suggestions: if you have problems
      with pipes and popen() ask in comp.unix.progr ammer, that's where
      the experts for these functions can be found. Regarding control-
      ling some kind of parts from the open office suite from another
      program I am a bit at a loss, but there should be quite a number
      of mailing lists, web forums etc. that are suitable for these
      kind of questions (but I can't tell you were they are since I
      never had to have to deal with that). And about the browser/HTTP
      stuff you started of with I can only recommend to relax, take a
      good look at what exactly you are trying to do and formulate it
      in a somewhat more clear language that takes into account how
      browsers and HTTP servers interact and what is happening on
      both sides. Perhaps the first step you should take is to write
      a clear description of what you intend to do, not already in-
      sisting of the ways to do it. That may clear up the way to a
      workable solution a lot. Write down what you want to, not mixing
      it up with how to do it, and you may come up with a question that
      can be answered (although not completely or even in parts here
      in clc).

      Regards, Jens
      --
      \ Jens Thoms Toerring ___ jt@toerring.de
      \______________ ____________ http://toerring.de

      Comment

      • Mirxon@gmail.com

        #4
        Re: How to send a key event to another process?

        Hi guys, thanks a lot for all your replies.

        Seems I need to move my question to unix group :)

        Thanks again for the hearty reply.

        Good Luck~~

        Patrick

        Comment

        • Keith Thompson

          #5
          Re: How to send a key event to another process?

          Mirxon@gmail.co m writes:
          I'm working on a C program under Ubuntu.
          It's basd on socket.
          Browser calls a client cgi (C program), and send some parameters to
          server (C program).
          Server runs another program (ooimpress, open office ppt), and
          translate the commands from client to a key event, and send it to
          child process.
          [snip]

          There's no way to do this in standard C. Try comp.unix.progr ammer, or
          perhaps a Linux or Ubuntu forum.

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          Nokia
          "We must do something. This is something. Therefore, we must do this."
          -- Antony Jay and Jonathan Lynn, "Yes Minister"

          Comment

          • Mirxon@gmail.com

            #6
            Re: How to send a key event to another process?

            Hi guys, thanks a lot for all your replies.

            Seems I need to move my question to unix group :)

            Thanks again for the hearty reply.

            Good Luck~~

            Patrick

            Comment

            Working...