Jump to content

What is the proper way to exit a script?


qwert
 Share

Recommended Posts

I have a script that performs size/move operations on an external application window. When the script finishes, I perform the following steps ($hWnd is the external window):

WinActivate($hWnd)
WinSetState($hWnd, "", @SW_ENABLE)
Exit

The problem is that (with multiple windows on the taskbar at the time my script exits), there is sometimes the inability to click on a specific entry and cause that application window to come to the front -- like Windows thinks it's already the top window, but it's not. Clicking on a different taskbar entry and then going back to the original clears the problem.

What other steps should I include to get things "back to normal" when exiting?

Thanks in advance.

Link to comment
Share on other sites

I have a script that performs size/move operations on an external application window. When the script finishes, I perform the following steps ($hWnd is the external window):

WinActivate($hWnd)
WinSetState($hWnd, "", @SW_ENABLE)
Exit

The problem is that (with multiple windows on the taskbar at the time my script exits), there is sometimes the inability to click on a specific entry and cause that application window to come to the front -- like Windows thinks it's already the top window, but it's not. Clicking on a different taskbar entry and then going back to the original clears the problem.

What other steps should I include to get things "back to normal" when exiting?

Thanks in advance.

Take a look at WinWaitActive() and perhaps putting a short Sleep() delay in your script between window actions.

Other tricks would use something like

While WinExists("My Window")
   WinClose("My Window")
   Sleep(50)
Wend

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Take a look at WinWaitActive()

I added a WinWaitActive($hWnd) after the activate, plus a couple of delays -- but the result stayed the same. Oddly, the "inability to select of the first try" doesn't always happen. It seems to have something to do with which was the last top window. I added a pause as the very last step in my script and found that I can ALWAYS select other windows up until my script times out and exits -- which then brings on the problem. I'll continue to experiment.

Thanks for the response.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...