Jump to content

Pause Script Until Any Window Open ?


 Share

Recommended Posts

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]
Link to comment
Share on other sites

#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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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]
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...