Jump to content
Sign in to follow this  
EricL

problem with control clicks if users put window to background during loop

Recommended Posts

During my last while statement (takes installer a good minute to finish on a fast machine) users tend to click on new emails/ or alt tab to continue working.

Then for whatever reason the scrip does not always finish. sometimes if they click it and makeit forground again, it click "exit" button and closes. Once and a while the script just hangs.

I tried to force the window to forground, but its not working everytime. can i do this w/o it being in the forground? Any ways to handle this I will consider.

-lock user input

-force window to active

-do the click while minimized or background.

-whatever...

; ##Wait for progress bar to hide indicating install complete
            While StringInStr($sText, "Progress Bar")
            WinActivate($pHandle)
            WinWaitActive($pHandle)
            $sText = WinGetText($pHandle);get current text
            Sleep(20)
        WEnd

    ;
    ; ##Exit Install
            WinActivate($pHandle)
            WinActivate("Application Installer")
            WinWaitActive($pHandle)
        ControlClick($pHandle, "", "ThunderRT6CommandButton3")

Share this post


Link to post
Share on other sites

can i do this w/o it being in the forground?

Yes. Control* functions do not require for the window to be active. Just use WinWait to wait for the window title to appear and then use your Control* function on the window. If you use Send or Mouse* functions then you would need to activate the window first. Using Control functions can allow you to hide the windows, use WinSetTrans or even WinMove the window off screen and manipulate the controls.

A sample of your changed code would be like the below

; ##Wait for progress bar to hide indicating install complete
While StringInStr($sText, "Progress Bar")
    WinWait($pHandle)
    $sText = WinGetText($pHandle);get current text
    Sleep(20)
WEnd

;
; ##Exit Install
WinWait($pHandle)
ControlClick($pHandle, "", "ThunderRT6CommandButton3")

:)

Share this post


Link to post
Share on other sites

First time I was able to mess it up. I removed the winwait and it worked.

the window is open for the entire routine up to this part, so that was not needed anyway I dont think?

Thanks for your help. this community is amazing.. I would never learned this much w/o everyones help.

Share this post


Link to post
Share on other sites

First time I was able to mess it up. I removed the winwait and it worked.

the window is open for the entire routine up to this part, so that was not needed anyway I dont think?

I believe you are correct. The WinWait does hinder the purpose of the loop. Good decision.

:)

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...