Click to See Complete Forum and Search --> : Control another program's flow ...?
jleandroperez
August 29th, 2009, 11:43 AM
Hello,
I'd like to know how if it's possible to write a program to 'control' another program.
For instance, let's say i'd like to open Word, change the font, and insert some text. Is there any way to 'get a hook' on another running program's resource, and trigger events like keystrokes or a mouse click ?
Thank you!!
Shuja Ali
August 29th, 2009, 12:45 PM
Welcome to the forum :wave:
yes it is very much possible. I would take an example of Word itself. MS Word exposes an COM Object Library that you can use to automate MS Word application. You can all that you have mentioned and much more.
If you want to automate some other program that not expose an object library, you will have to rely on SendMessage API. Do a search here and you will numerous examples of how to use SendMessage to control another application.
jleandroperez
August 29th, 2009, 12:58 PM
Thanks a lot for your reply..!!. I'll take a look on SendMessage.
jleandroperez
August 29th, 2009, 01:38 PM
Sorry to bother here again...
SendKeys would work great for what i need to do. However i'm having trouble opening a 3rd party program which is minimized to tray.
I've been testing the MS API... ShowWindow and SetForegroundWindow are both not working.
I'm using it this way...
Process[] processes = Process.GetProcessesByName("test");
foreach (Process p in processes) {
ShowWindow(p.Handle, 5);
}
Also tested with p.MainWindowHandle... any idea?
Thanks a lot in advance =D
vcdebugger
August 31st, 2009, 05:21 AM
There might be some other APIS to do a search which are there in the tray minimized. Just do a search you may get a API related to that ...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.