Answer» Is it possible to create programs that run in background and give reply to some specific program when it is found running. Okay, lets make it simpler:
A program that just gives replies to specific program if it is found running or terminates. with PStools:
batch program, accepts program to view info of as argument.
Code: [Select]@echo off pslist | find "explorer" /i
the PSLIST program will need to be on your path for this too work.
I think the main confusion is this "replies" to business. a reply implicates PREVIOUS communication between this program you want to "reply" to and the program you are running- how does this occur?Thanks for replying. Sorry for getting late, OK, example:
The program which I want to write is ProgramMe, and the program to which it will SEND message is ProgramX. Now ProgramX has suppose three PushButtons on its first screen, and I want ProgramMe to select the second PushButton from that as would have done.wow, that's more troublesome then it sounds.
is the caption of the window always the same? the button? If so, you will need to use some API calls within your program.
First, you'll need to use the "FindWindow" API to find the handle of the window with the caption. Note that if "programX" changes it's caption at all this portion will become much more difficult (if this is the case let me know- I could add that here but it's messy, even in pseudocode).
Armed with the window handle from FindWindow, you will need to start a EnumWindows() call.
EnumWindows will call a callback function you define for every window in the SYSTEM. With every call you will need to use the "IsChild" API routine to determine wether this enumerated window is a child of the window you retrieved with FindWindow earlier. If it is, you then determine, using "GetWindowText", wether this is also the button you wish to emulate a push for.
If it is, you will call PostMessage() to post a proper button message to emulate the click (PostMessage is USED to prevent a deadlock situation between enumwindows and the messagepump of the target window).
And that's all there is to it! LOL.
If course this will REQUIRE some familiarity with the windows API...Okay, thanks, I'll read. TYVM.
|