Briefly, I use a program (called Execute) which processes data and creates multiple tables. I generally work on other pieces of work whilst this runs (say in word or excel). Execute has about 20 tables to run. After finishing each table it closes and brings another little window up to show it's progress (see pic). The problem is if I am typing away and don't notice that a new instance of Execute has appeared I can be prone to causing it to stop, eg pressing the space bar will cause the Cancel button to be pressed! I would like to use WinWarden to return the focus back to the previous application (say excel for example). So far I've been able to setup a line in the ini file that moves the Execute window to the bottom of the sreen but I've been unable to make it lose focus / unactivate it.

This line works fine - it detect the correct window when it pops up and moves it to the bottom of the screen.Active ,Execute,,,,,-Bottom,,,,,,,,,,,,,

in the ini file it stated the 18th or higher attribute can contain the following features. I'm guessing I need to use Bottom, as I want the previous application to have the focus back - is this the correct one?

;>17 Maximize Maximizes the window; Minimize Minimizes the window; Restore Restores the window; Show Shows the window; Hide Hides the window; Top Moves the window on top of the other windows; Bottom Moves the window to the bottom of the other windows; Enable Enables mouse and keyboard input; Disable Disables mouse and keyboard input; Ghost Makes mouse clicks go through to the underlying window

Active ,Execute,,,,,,,,,,,,,,,,Bottom,,

The problem is this doesn't work and infact none of the other ones seem to work, eg Minimize.

Thanks very much for the guidance and script - that worked a treat and the focus is returned back to the previous application it seems. There is one slight change I need. I need the script to only run when the Execute window is first activated / created. Currently as soon as I click on the window manually (eg to manually cancel it) the AHK script runs meaning it's hard to click the cancel button. I could increase the sleep time but then this would impact the response time for when the window pops up initially.

I'm thinking that you could put a line in detecting if the mouse position intersects the same area as the Execute window or if the script registers some sort of session ID that is unique to that instance. Could you help me with that additional condition?

Many thanks in advance.

Rodp

EDIT...... just came across this example: http://stackoverflow...timer-runs-only-once. See Update 2. Do you think this is on the right tracks?Or... (just reading the syntax list available) would WinWait actually do all what I need or is this more CPU intensive compared to a normal loop?

« Last Edit: September 25, 2014, 03:53 AM by rodp, Reason: google search returned something that might help »

ah yes, that would work - sorry wasn't thinking! Is it possible then to place a brief message (balloon message!) from the H icon in the task bar to state that the window has been deactivated, press Ctrl+Esc to stop the script (incase you need to cancel), or something to that effect? I might roll this out to other people and they would need to know what's going on you see.

To further my understanding however, are there drawbacks if I was to try using WinWait?

adding a TrayTip command would provide a visual clue to the users as to what is happening, which I have already added in the above code.

I don't see any drawbacks between using WinWait and Loop, it is just a matter of personal preference. feel free to try out the example you linked, and see if there are any differences. you can use WinWaitActive/WinWaitNotActive.