开发者

Is there a way to make AutoIt's WinWaitActive care about if a window is visible

开发者 https://www.devze.com 2023-01-29 03:32 出处:网络
My script is supposed to wait for the "Select File" dialog of IE to appear, then make it go away and replace it with a custom select file interfa开发者_JAVA百科ce. I\'ve gotten it all workin

My script is supposed to wait for the "Select File" dialog of IE to appear, then make it go away and replace it with a custom select file interfa开发者_JAVA百科ce. I've gotten it all working, but there is one thing nagging me. The code is as following:

WinWaitActive("Select File")
WinSetState("Select File", "", @SW_HIDE)

The problem seems to be that the "Select File" dialog is (invisibly) created by IE, made active, then made visible. It's a basic threading problem really:

In some cases, IE makes the dialog active (but not visible yet!). My script picks that up, Hides the dialog (which actually is already hidden), and then IE makes the dialog visible which results in a visible dialog(!).

Is there any option I can set which makes the WinWaitActive command also wait for the window the be visible, not just active?


you can use the function below to know if the window is visible.

Func IsWindowVisible($handle)
    If BitAnd(WinGetState($handle), 2) Then 
        Return 1
    Else
        Return 0
    EndIf
EndFunc

then you can use a loop like this to do what you want:

While 1
    If IsWindowVisible(FindWindow("Select File", "")) Then ; I'm not sure about FindWindow syntax
        WinSetState("Select File", "", @SW_HIDE)
        Break
    Else
        Sleep (1000)
    EndIf
EndWhile

Hope this helps.

0

精彩评论

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