Need advice on best ways to launch and control another application.
-
I am writing a program that needs to launch another program, log in, run another program, and then type in some text or make selections in a list box. I've figured out how to launch the app and get's it's window handle but that's it. I'm at a loss as to how to find the resulting window and send clicks, keystrokes, or whatever. Worse, after intially launching the first app (Citrix, if your are curious), I will be presented with a login screen, a folder with several icons one of which will need to be launched, another login screen, another virtual folder with an app that needs to be run, etc. So what is the best way to approach this? I've been reading up on the Windows API... This is frustrating because at home I often use a program called Macro Express to automate this sort of thing.
-
I am writing a program that needs to launch another program, log in, run another program, and then type in some text or make selections in a list box. I've figured out how to launch the app and get's it's window handle but that's it. I'm at a loss as to how to find the resulting window and send clicks, keystrokes, or whatever. Worse, after intially launching the first app (Citrix, if your are curious), I will be presented with a login screen, a folder with several icons one of which will need to be launched, another login screen, another virtual folder with an app that needs to be run, etc. So what is the best way to approach this? I've been reading up on the Windows API... This is frustrating because at home I often use a program called Macro Express to automate this sort of thing.
It's been a while, but I think you want to look at the sendmessagee function in the win32 api.
-
I am writing a program that needs to launch another program, log in, run another program, and then type in some text or make selections in a list box. I've figured out how to launch the app and get's it's window handle but that's it. I'm at a loss as to how to find the resulting window and send clicks, keystrokes, or whatever. Worse, after intially launching the first app (Citrix, if your are curious), I will be presented with a login screen, a folder with several icons one of which will need to be launched, another login screen, another virtual folder with an app that needs to be run, etc. So what is the best way to approach this? I've been reading up on the Windows API... This is frustrating because at home I often use a program called Macro Express to automate this sort of thing.
Well you could use EnumWindows to get the list of all top level windows. Then you could use EnumChildWindows to get the list of the child compoments inside the parent. Since you are posting this in VB section i am asuming that you are using VB, then you can use AppActivate to set focus on the window and then SendKeys to send the keys to the window :-D To run an application you can use the Shell function which returns the process id if the program is running. ------------------------------------------- Taken From MSDN 2003 ------------------------------------------- 'Example AppActivate("Untitled - Notepad") SendKeys.SendWait("Hello world!") ' Send Ctrl S to open the Save As dialog box. SendKeys.SendWait("^S") ' Send the name of the new file. SendKeys.SendWait("c:\HelloWorld.txt") ' Send Alt S to save the file. SendKeys.SendWait("%S") ------------------------------------------- I hope the above helps :) Life Is A Cipher Substituting "happiness" with "sadness" and Transforming "pleasure" into "pain"
-
Well you could use EnumWindows to get the list of all top level windows. Then you could use EnumChildWindows to get the list of the child compoments inside the parent. Since you are posting this in VB section i am asuming that you are using VB, then you can use AppActivate to set focus on the window and then SendKeys to send the keys to the window :-D To run an application you can use the Shell function which returns the process id if the program is running. ------------------------------------------- Taken From MSDN 2003 ------------------------------------------- 'Example AppActivate("Untitled - Notepad") SendKeys.SendWait("Hello world!") ' Send Ctrl S to open the Save As dialog box. SendKeys.SendWait("^S") ' Send the name of the new file. SendKeys.SendWait("c:\HelloWorld.txt") ' Send Alt S to save the file. SendKeys.SendWait("%S") ------------------------------------------- I hope the above helps :) Life Is A Cipher Substituting "happiness" with "sadness" and Transforming "pleasure" into "pain"
SendKeys!! Thats what I was thinking of...
-
Well you could use EnumWindows to get the list of all top level windows. Then you could use EnumChildWindows to get the list of the child compoments inside the parent. Since you are posting this in VB section i am asuming that you are using VB, then you can use AppActivate to set focus on the window and then SendKeys to send the keys to the window :-D To run an application you can use the Shell function which returns the process id if the program is running. ------------------------------------------- Taken From MSDN 2003 ------------------------------------------- 'Example AppActivate("Untitled - Notepad") SendKeys.SendWait("Hello world!") ' Send Ctrl S to open the Save As dialog box. SendKeys.SendWait("^S") ' Send the name of the new file. SendKeys.SendWait("c:\HelloWorld.txt") ' Send Alt S to save the file. SendKeys.SendWait("%S") ------------------------------------------- I hope the above helps :) Life Is A Cipher Substituting "happiness" with "sadness" and Transforming "pleasure" into "pain"
Yes that does help, thanks. I guess I just need to take them on one by one and see what works by trial and error.