Windows move Window Example
Aus ExpeccoWiki
Inhaltsverzeichnis |
Motivation
A common stupid situation when working with multiple screens under Windows happens, when the secondary screen is removed while some application is still open on that screen. Windows (in its unbelievable stupidity) remembers the position of the application and will - even with no secondary screen attached - always position this application at that last position. Even when this application is killed and started anew. It does not verify, if the position is actually visible, if there is a screen and does not ask for a new position either.
And of course, you have not the slightest chance to interact with that window, unless you go grab and reconnect a secondary screen. Which might be impossible, if your secondary screen is only available in the office, while you and your laptop are now on the road or at home...
Even the windows move/maximize/minimize and other menu items from the icon-taskbar are not working.
This happened this morning with my VMware client; a nice chance to use expecco as a scripting engine.
Enumerating Windows
First, I created an empty new project, imported the Windows-Access-Library, created an empty step, and finally placed the "Enumerate Top Windows" and "Get Window Title" blocks into it:
this gives me the list of windows; the trouble-maker is found by looking at the output of this:
from this output, I copied the name of the invisible window ("exeptn.bh.exept.de...") into the clipboard.
Positioning a Window
Next, I created another step, which is taking a window handle as input, fetches the window's title, compares this against the above string, and positions it then to a save-known location on the screen. Here is the network of that compound (which I called "Move VMware Window"):
because I am lazy, I simply pasted the window-title as a freeze value - for a better (reusable) block, this should be made another input pin. We'll see if there will ever be a need for that; for now, I expect this to be a throw-away script, so I don't care.
Final Solution
Finally, connect this new block to the window enumerator:
and run it. This moved my invisible window back to 10@10, where I can fetch, resize, move and use it.
Voilà - less than a minute to implement !
Back to the Examples page.
Back to the english main page.
Zurück zur deutschen Hauptseite.



