Sign in to follow this  
Followers 0
brad25

winactive?

3 posts in this topic

hi, im able to look for an active window but how would i be able to check and see if a window has closed meaning there is no active window then msgbox "there is no active window" thanks in advance

Share this post


Link to post
Share on other sites



check if a window does not exist by using.

If Not WinExists ( "title" [, "text"] ) Then

Endif

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

If the window is not active does not mean that it does not exist. So perhaps WinGetState() may help you.

Here is an example of WinGetState()

; use notepad as an example
$pid = Run('Notepad')
If WinWait('Untitled', '', 5) Then
    While 1
        ; output window state to output pane of editor
        ConsoleWrite(_IsWinState('Untitled') & @CRLF)
        ; if error then window not exists or just use WinExists() instead
        If _IsWinState('Untitled') And @error Then
            SplashTextOn(@ScriptName, 'Window not exists', Default, 80)
            Sleep(2000)
            SplashOff()
            ExitLoop
        EndIf
        ; check if visible and not active and message if true
        If _IsWinState('Untitled', '', 'visible') And Not _IsWinState('Untitled', '', 'active') Then
            SplashTextOn(@ScriptName, 'Window is visible and not active', Default, 80)
            Sleep(1000)
            SplashOff()
        EndIf
        Sleep(1000)
    WEnd
EndIf


Func _IsWinState($title, $text = '', $state_check = '')
    Local $winstate, $state_add = '|'
    If $state_check Then $state_check = '|' & $state_check & '|'
    ; get the state of window
    $winstate = WinGetState($title, $text)
    If @error Then Return SetError(1, 0, '|error|')
    ; collect window state information
    If BitAND($winstate, 32) Then $state_add &= 'maximized|'
    If BitAND($winstate, 16) Then $state_add &= 'minimized|'
    If BitAND($winstate, 8) Then $state_add &= 'active|'
    If BitAND($winstate, 4) Then $state_add &= 'enabled|'
    If BitAND($winstate, 2) Then $state_add &= 'visible|'
    If BitAND($winstate, 1) Then $state_add &= 'exists|'
    ; just return the delimited string if not $state_check
    If Not $state_check Then Return $state_add
    ; return true if state is in the delimited string
    If StringInStr($state_add, $state_check) Then Return True
    Return ''
EndFunc

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  
Followers 0