views:

25

answers:

2

Hello,

As a disclaimer I am not at all familiar with Win32 development. I was wondering if there was any way to automate control input to a GUI application if that application is minimized. Most automation tools I have seen specifically use coordinate offsets from the window (tlx,tly). I don't need a testing framework, I simply want my own application to cause some action on the minimized (different - closed source) application. The I talk about it, the less it seems possible. Any input is appreciated on how this might be accomplished.

A: 

You might be able to do this with PostMessage or SendMessage, I do know its possible, as I've seen game bots that do this sort of thing...

Necrolis
+2  A: 

Ok, the simplest way for you to become acquainted with default minimization behavior is to play with something simple, e.g. Calculator. Just start it and use Microsoft Spy++ to see the properties of a window representing some button within the calculator window.

In my case I see:

  • in normal state: rectangle (1096, 222)-(1130, 249), 34x27
  • in minimized state: rectangle (-31911, -31839)-(-31877, -31812), 34x27

So by default, minimization changes window position by moving it far far away. If you were able to keep the HWND then you are still able to send whatever window message you need.

Things to keep in mind:

  • applications may customize their behavior on minimization, e.g. destroy the window at all - switch to tray.
  • even if you succeed to send necessary messages to the controls you need - application's logic might be an obstacle - e.g. it might depend on results of IsWindowVisible, it might assume that window rectangle coordinates are always positive and so on.
Andrey