Is it possible to send directions to another program instead of just simulating keypr

This is a discussion on Is it possible to send directions to another program instead of just simulating keypr within the C Programming forums, part of the General Programming Boards category; Hi! Im new here so please bear with me.. Is it possible to send directions to another program in some ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    2

    Is it possible to send directions to another program instead of just simulating keypr

    Hi!

    Im new here so please bear with me..

    Is it possible to send directions to another program in some way, using real c
    (or java)? Something similar to using sendkey in c#, but by giving directions to the program without simulating keypresses. I've made programs(in java) before that were able to open programs and in which it was possible to click buttons by using mousemacros clicking in specified coordinates. It was also possible to simulate keypresses. Now to the point..
    Now I'd like to go deeper, by learning how to send the right directions directly to the program, without simulating for example a user mouse click on a button by using mousemacros. This because it will not work if the program isn't at the right place when the mousemacro is clicking in the specified coordinate. If I could send the directions directly, then it's not necessary to know the exact coordinate of the button. How can i achieve this and from where would I get the right directions?
    If it's not possible to send the directions, is it possible to get the button's coordinates from some register in windows, so one wouldn't have to scan through the screen?
    I've been searching for a long time already but I couldn't find any useful about this subject.
    Can anyone please tell me how to achieve this or at least show where I can learn more? Links to articles about this is also useful.

  2. #2
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    This looks like you want to do some interprocess communication. But I'm not totally sure that's what you are looking for.

    Anyway, if you are on Windows, here's what the OS has to offer to you: http://msdn.microsoft.com/en-ca/libr...74(VS.85).aspx
    I hate real numbers.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Is your program starting the other program? If so, popen() & fputs() should work.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    Note that most buttons have shortcuts -- i.e. ALT-C -- that you can simulate with the keyboard, without relying on the mouse. Failing that, you can reach almost any widget, button or otherwise, by pressing TAB and/or SHIFT-TAB a few times, and then simulate ENTER to activate the button/whatever.

    Is there anything in particular you're trying to do?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Posts
    2
    Thx for the replies!
    Rpc (http://msdn.microsoft.com/en-ca/libr...74(VS.85).aspx) was something in the right direction. However it seems one has to make the target program compatible with rpc, and this may not be possible in every situations. What I'd like to do is calling functions in the other program without clicking buttons, I'm not sure if it's possible.. One could of course use the shortcuts as suggested by dwks. But there might be problems if the target program miss some of the buttonpresses. At least when I made c# programs myself, they didnt listen to the buttons all the time. And if one has to press tab several times to get to some specific place, then theres a bigger risk that one buttonpress goes by..
    I still haven't find what I'm looking for, maybe it's impossible to do it the way I wanted. I thought about a program that could manipulate the computer to run some functions in the other program. I know it sounds dangerous but like this I could automate tasks very efficiently. When simulating buttonpresses it often makes th computer to freeze or run slower than if a user had done it.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    Simulating tab several times to get to the right place works just about every time, as long as you count out the tabs properly. I've done it before. As long as you leave a reasonable delay between the keypresses, say 10 ms or 20 ms for operations that might take a while.

    Of course, it takes some time to calculate the number of tabs you have to press and so on, so this only works if you have a task that you want to repeat many, many times. If you just want to rename ten files or something like that, it would be more hassle than worth.

    I guess you can either:
    • simulate keypresses, using tabs if necessary; or
    • calculate the origin of a window and use that to simulate mouse presses; or
    • find programs that take command-line parameters instead of using GUIs.

    I've only ever emulated keypresses, so I can't help you much unless you choose that route.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I think what Saigon was asking was if it was possible to send keystrokes to a program even if it wasn't the active window, possibly minimized...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Server Client Messaging Program
    By X PaYnE X in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-04-2004, 04:20 PM
  2. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 08:48 AM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 04:23 PM
  4. make a program stay....
    By Nirav in forum C Programming
    Replies: 6
    Last Post: 10-12-2003, 07:01 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21