开发者

WIndows GUI automation on minimized window

开发者 https://www.devze.com 2023-01-22 04:50 出处:网络
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 a开发者_JAVA技

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 a开发者_JAVA技巧utomation 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.


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.


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...


There is a Python solution for such things - pywinauto.

Example: Python - Control window with pywinauto while the window is minimized or hidden

Though WinForms are partially supported, simple actions like silent click (Click method) can be done using relative coordinates for non-recognized controls.

0

精彩评论

暂无评论...
验证码 换一张
取 消