Results 1 to 13 of 13

Thread: Qprocess-add commands to a running executable

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Qprocess-add commands to a running executable

    Hi,

    If i have a .exe file running from that was started by QProcess commandProcess, how can I send additional commands to that running .exe file? Like if it was a media player that was playing some media (the .exe file) and I want to have a button on the gui pause it, what exact line of code could I use for that? Pause would be an argument probably. Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Qprocess-add commands to a running executable

    You use inter process communication.
    There's a website about this on the qt documentation site.

    Example: dbus or sockets

  3. #3
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qprocess-add commands to a running executable

    The QProcess class can only send and receive information via stdin/out/err. You cannot use it to press buttons or such in another application.

  4. #4
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qprocess-add commands to a running executable

    Can I get some complete examples? If I already have a exe file started by qprocess, what example code can I use to add additional commands or args to that exe file? Thanks

  5. #5
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Qprocess-add commands to a running executable

    I may very well be wrong here, but my understanding is that in order to "virtually" use a product (like a media player) that product has to expose an API. For example, Apple's iTunes API, which I have used to program a stripped-down iTunes interface in PyQt. I'd love to hear more about this however.

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Qprocess-add commands to a running executable


  7. #7
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qprocess-add commands to a running executable

    Although DBus is ATM available (at least officially) only on NIX, not on the windows - assuming that Milardo uses Windows and i.e. WMP.
    Also I don't think (I can be wrong on this one) you can do what You want with QProcess either. If Your player don't support action like stop/pause/play from the CLI (this is really rare on win), then You can only (and again this is AFAIK, I can be wrong on this one) do a hook and override functionality directly.

    For nix go with dbus.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  8. #8
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Qprocess-add commands to a running executable

    http://msdn.microsoft.com/en-us/libr...74(VS.85).aspx

    You can always use sockets of course.

    But indeed, if the program you want to interface with doesn't have a public api or doesn't expose an ipc option, then you don't have a lot to work with.

    There is of course reverse engineering. You can always automate software from another one, but you need to use hooks.

  9. #9
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qprocess-add commands to a running executable

    The exe program is gst-player.exe from gstreamer. It supports typing like pause, play from the command line. It is for windows os. If somebody can, please provide an example using dbus/sockets/hooks

  10. #10
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Qprocess-add commands to a running executable

    If the program accepts commands like that from any input then I guess you can just write "pause\n" or "play\n" to std out (for the environment where your process is running).

  11. #11
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qprocess-add commands to a running executable

    Can you post an example of some code for that? That would be helpful thanks. I'm not that knowledgeable at programming but I do know some and I can learn fast.

Similar Threads

  1. Replies: 7
    Last Post: 13th September 2011, 13:15
  2. Replies: 0
    Last Post: 26th August 2010, 10:44
  3. Replies: 5
    Last Post: 17th March 2010, 18:30
  4. How to reload QProcess executable?
    By kommu in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 20:13
  5. Error running executable
    By Salazaar in forum Newbie
    Replies: 8
    Last Post: 21st May 2007, 06:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.