Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jun 26, 1998

Controlling other programs

Question:
How can I make a program that controls other programs? For example, I've seen programs that can change the text in a text box of another program.

Answer:
Sounds like it should be pretty easy, and in the end it often is. In general, to alter another window you must first obtain its handle. The example you suggest is extremely general, so I can't be very specific, of course.

Were this task something I was trying to accomplish, I'd likely use EnumWindows or FindWindow to search all the top-level windows until I came across the application I was looking for. At that point, I'd probably call upon either EnumChildWindows or FindWindowEx to zoom in on the specific window I wanted to alter.

At each step along the way, any number of API calls may be required to determine whether the window you were examining might be the one you sought. Once you obtain the handle for the target window, you're free to do whatever you need to with it. For example, to change its text, you'd probably want to call SendMessage with WM_SETTEXT.

As you can see, there are no "one size fits all" answers here. You'll need to carefully define what you're trying to do, then break it down into manageable pieces. Hope this helps!

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date