获取指定窗口的状态.
WinGetState ( "窗口标题" [, "窗口文本"] )
窗口标题 | 目标窗口标题.参考标题特殊定义 |
窗口文本 | [可选参数] 指定窗口包含的文本. |
成功: | 返回一个指示窗口状态的值.多个状态值被加到一起,因此要检查该窗口是否具有指定状态请使用 BitAND() 函数: |
1 = 窗口存在 | |
2 = 窗口可见 | |
4 = 窗口可用(未被禁用) | |
8 = 窗口为激活状态 | |
16 = 窗口为最小化状态 | |
32 = 窗口为最大化状态 | |
失败: | 返回值为0,并把 @error 设为 1,说明未找到目标窗口. |
Example()
Func Example()
; Run Notepad
Run("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
; Retrieve the state of the Notepad window using the handle returned by WinWait.
Local $iState = WinGetState($hWnd)
; Check if the Notepad window is minimized and display the appropriate message box.
If BitAND($iState, 16) Then
MsgBox(4096, "", "Notepad is minimized and the state returned by WinGetState was - " & $iState)
Else
MsgBox(4096, "", "Notepad isn't minimized and the state returned by WinGetState was - " & $iState)
EndIf
; Close the Notepad window using the handle returned by WinWait.
WinClose($hWnd)
EndFunc ;==>Example