Jump to content
Sign in to follow this  
komalo

Pause Script Until Any Window Open ?

Recommended Posts

komalo

hi

i tried to pause script until any window in the screen is opened but the problem is that the script isn't paused when calling it again

that's my script

#NoTrayIcon
HotKeySet("{ESC}", "_Exit")

Winwaitnew()
MsgBox("","",1)

Winwaitnew()
MsgBox("","",2)

Func CompareList($List1, $List2)

    For $i = 1 To $List1[0][0]
        If $List1[$i][0] <> "" And BitAND(WinGetState($List1[$i][1]), 2) Then $List1N = $List1N + 1
    Next

    For $i = 1 To $List2[0][0]
        If $List2[$i][0] <> "" And BitAND(WinGetState($List2[$i][1]), 2) Then $List2N = $List2N + 1
    Next

    If $List1N <> $List2N Then 
        $List1N=0
        $List2N=0
        Return 1
    Else
        $List1N=0
        $List2N=0
        Return 0
    EndIf

EndFunc  ;==>CompareList

Func _Exit()
    Exit
EndFunc  ;==>_Exit

Func Winwaitnew()
    Local $ConstWin,$NewList
    $ConstWin = WinList()
    Do
        $NewList = WinList()
        Sleep(1)
    Until CompareList($ConstWin, $NewList) = 1
EndFunc

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites
Zedna

#NoTrayIcon
HotKeySet("{ESC}", "_Exit")

Winwaitnew()
MsgBox("","",1)

Winwaitnew()
MsgBox("","",2)

...

#NoTrayIcon
HotKeySet("{ESC}", "_Exit")

While 1
 Winwaitnew()
 MsgBox("","",1)
 Sleep(100)
WEnd
...
Edited by Zedna

Share this post


Link to post
Share on other sites
komalo

#NoTrayIcon
HotKeySet("{ESC}", "_Exit")

While 1
 Winwaitnew()
 MsgBox("","",1)
 Sleep(100)
WEnd
...
i know how to write a loop ;) , i made it in the function

that's not what i asked about , try the code i wrote and

you will notice that the 2nd msgbox appears without

waiting a new window , if just there was a function

that waits in autoit until any new window appear

too bad that WinWait don't do that


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites
BrettF

Will this worked...

#NoTrayIcon
$List1N = 0
$List2N = 0

HotKeySet("{ESC}", "_Exit")
While 1
    Winwaitnew()
    MsgBox(0,"","New Window Detected")
WEnd

Func CompareList($List1, $List2)
    For $i = 1 To $List1[0][0]
        If $List1[$i][0] <> "" And BitAND(WinGetState($List1[$i][1]), 2) Then $List1N = $List1N + 1
    Next

    For $i = 1 To $List2[0][0]
        If $List2[$i][0] <> "" And BitAND(WinGetState($List2[$i][1]), 2) Then $List2N = $List2N + 1
    Next

    If $List1N <> $List2N Then
        $List1N=0
        $List2N=0
        Return 1
    Else
        $List1N=0
        $List2N=0
        Return 0
    EndIf

EndFunc ;==>CompareList

Func _Exit()
    Exit
EndFunc ;==>_Exit

Func Winwaitnew()
    Local $ConstWin,$NewList
    $ConstWin = WinList()
    Do
        $NewList = WinList()
        Sleep(1)
    Until CompareList($ConstWin, $NewList) = 1
EndFunc

Can't see what your problem is... ;)

Edited by BrettF

Share this post


Link to post
Share on other sites
komalo

Replace this MsgBox(0,"","New Window Detected") with a run function to any program

but i warn you because it will crashes your memory unless you press ESC (Exit)


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites
BrettF

Share this post


Link to post
Share on other sites
martin

hi

i tried to pause script until any window in the screen is opened but the problem is that the script isn't paused when calling it again

that's my script

#NoTrayIcon
HotKeySet("{ESC}", "_Exit")

Winwaitnew()
MsgBox("","",1)

Winwaitnew()
MsgBox("","",2)

Func CompareList($List1, $List2)

    For $i = 1 To $List1[0][0]
        If $List1[$i][0] <> "" And BitAND(WinGetState($List1[$i][1]), 2) Then $List1N = $List1N + 1
    Next

    For $i = 1 To $List2[0][0]
        If $List2[$i][0] <> "" And BitAND(WinGetState($List2[$i][1]), 2) Then $List2N = $List2N + 1
    Next

    If $List1N <> $List2N Then 
        $List1N=0
        $List2N=0
        Return 1
    Else
        $List1N=0
        $List2N=0
        Return 0
    EndIf

EndFunc ;==>CompareList

Func _Exit()
    Exit
EndFunc ;==>_Exit

Func Winwaitnew()
    Local $ConstWin,$NewList
    $ConstWin = WinList()
    Do
        $NewList = WinList()
        Sleep(1)
    Until CompareList($ConstWin, $NewList) = 1
EndFunc
If the variables $List1N and $List2N are made Local variables in CompareList then the WInWaitNEw function doesn't wait for a new window, it waits untill the number of windows changes.

To make it reliable I think you should make $Lit1N to be a list of of the handles for visible windows, and then if $Newlist contains a handle of a window that isn't in the $List1n then say it's a new window.

Like this

#NoTrayIcon

HotKeySet("{ESC}", "_Exit")


While 1
    MsgBox("", "", Winwaitnew())
WEnd



Func CompareList($List1, $List2)
    Local $List1N = "|"
    For $i = 1 To $List1[0][0]
        If $List1[$i][0] <> "" And BitAND(WinGetState($List1[$i][1]), 2) Then $List1N &= $List1[$i][1] & "|"
    Next

    For $i = 1 To $List2[0][0]
        If $List2[$i][0] <> "" And BitAND(WinGetState($List2[$i][1]), 2) Then
            $search = "|" & $List2[$i][1] & "|"
            If Not StringInStr($List1N, $search) And $List2[$i][0] <> "start menu" Then Return $List2[$i][0]
        EndIf
    Next

    Return ""

EndFunc  ;==>CompareList

Func _Exit()
    Exit
EndFunc  ;==>_Exit

Func Winwaitnew()
    Local $ConstWin, $NewList
    $ConstWin = WinList()
    Do
        $NewList = WinList()
        Sleep(100)
        $Reply = CompareList($ConstWin, $NewList)
    Until $Reply <> ""
    Return $Reply
EndFunc  ;==>Winwaitnew

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
komalo

If the variables $List1N and $List2N are made Local variables in CompareList then the WInWaitNEw function doesn't wait for a new window, it waits untill the number of windows changes.

To make it reliable I think you should make $Lit1N to be a list of of the handles for visible windows, and then if $Newlist contains a handle of a window that isn't in the $List1n then say it's a new window.

Like this

#NoTrayIcon

HotKeySet("{ESC}", "_Exit")


While 1
    MsgBox("", "", Winwaitnew())
WEnd



Func CompareList($List1, $List2)
    Local $List1N = "|"
    For $i = 1 To $List1[0][0]
        If $List1[$i][0] <> "" And BitAND(WinGetState($List1[$i][1]), 2) Then $List1N &= $List1[$i][1] & "|"
    Next

    For $i = 1 To $List2[0][0]
        If $List2[$i][0] <> "" And BitAND(WinGetState($List2[$i][1]), 2) Then
            $search = "|" & $List2[$i][1] & "|"
            If Not StringInStr($List1N, $search) And $List2[$i][0] <> "start menu" Then Return $List2[$i][0]
        EndIf
    Next

    Return ""

EndFunc ;==>CompareList

Func _Exit()
    Exit
EndFunc ;==>_Exit

Func Winwaitnew()
    Local $ConstWin, $NewList
    $ConstWin = WinList()
    Do
        $NewList = WinList()
        Sleep(100)
        $Reply = CompareList($ConstWin, $NewList)
    Until $Reply <> ""
    Return $Reply
EndFunc ;==>Winwaitnew
thank you , it wasn't that ,i got it work

the problem that i had to use WinWaitNotActive

thank you all


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

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  

×