Windows programming question
July 6, 2005 2:32 PM   Subscribe

Windows Programming: how to simulate mouse clicks, button presses, and how to extract data from windows widgets?

I have a need to automate some of the functions of an existing program. In particular, at regular intervals I need to: fill in a text field, press a button, and read from another text field. I know that things of this kind are possible because programs like WinRunner seem to do this. Also, here is an example of a program that does something quite similar to what I want: UB History (although this is just a general class of problem I'm interested in solving)

Another thing I'd like to be able to do is embed a windows application into another, so that it seems integrated into it. Alternatively, I'd like to be able to take screen dumps of just that window and show them in another program (say, 1-5 times a second). My goal here is to be able to overlay data from my program on top of another program.
posted by RustyBrooks to Computers & Internet (8 answers total)
 
This is a massive pain in the ass. What you're basically asking is for a tutorial on using the Windows API, and then a tutorial on using the Windows API to get a handle for a given window, and then you're looking for a tutorial on using that handle to do various things.

The most I ever did was use the API to manipulate the window itself...move it, bring it to the front. You want to get inside of it and get data. Good luck.

I googled a bit for you...here's a Win32 API Programming tutorial.

You will also want to google around and look for stuff related to Windows Handles and Windows API Handles. It also makes it easier if you know a lot about the application you're trying to pull information out of...I seem to remember having a hard time getting the name of the textbox once I had the handle.

Good Luck!
posted by taumeson at 2:59 PM on July 6, 2005


Response by poster: Oh dear. I'm a seasoned unix programmer but I know pretty much nothing about the windows API and what I DO know is from the good old 16 bit days. I was hoping there was some sort of library that would make this relatively painless.

I know a *little* about the program in question. I do have access to winrunner although I don't know how to use it will, so maybe I can accomplish what I want through that, although, geez, I don't really want to run a THIRD application to get this stuff done.
posted by RustyBrooks at 3:12 PM on July 6, 2005


If you're using Perl on windows (activestate provides a free binary runtime enviroment), then the Win32::GuiTest module gives you a bunch of functions for finding windows, sending them keystrokes, etc.
posted by reishus at 3:22 PM on July 6, 2005


Response by poster: reishus: I'll look into that. I'm using a combination of Tcl/Tk and C but I might be able to mix some perl in that or use the perl module to see how they're doing it
posted by RustyBrooks at 3:29 PM on July 6, 2005


Best answer: I've used AutoIt successfully in the past. It looks like it might be able to do what you want.
posted by joelr at 3:35 PM on July 6, 2005


AutoIt looks awesome. I think I'm gonna check that out myself.

And I totally forgot about Spy++. That's a must have, to be honest.
posted by taumeson at 5:12 PM on July 6, 2005


Response by poster: I have visual c++ so I'll check out Spy++

Also, I'm vaguely remembering something about DDE from the past, using it to get data into and out of windows programs. I have a module for it around somewhere. I seem to recall using it with the MS Spy thing to figure this stuff out but I might be conflating two different things. I do know that we used to use this windows mapping software and you'd get data out by DDE.

I'll check autoit out also. Also I've been trying to contact the makers of some roll-your-own software that do stuff like this, so maybe I'll get some scoops from them.
posted by RustyBrooks at 5:21 PM on July 6, 2005


Response by poster: AutoIt looks like what I'm going to use. I *think* I can even do something fairly clever like have my main program create autoit scripts on the fly and exec them. This is not as slick as like an API I can link into the scripting language but it's not too shabby either.
posted by RustyBrooks at 5:44 PM on July 6, 2005


« Older Learning to play music on a keyboard   |   Do you have any traditional folk music... Newer »
This thread is closed to new comments.