这个问题似乎折腾了几个月了…… 对于疑难杂症,要勤于添加调试代码
#include <Array.au3>
Local $hWin = _WinWaitDebug('Uninstall Microsoft Office', '下一步(&N)', 10) ;10秒内检测等待
If Not @error Then MsgBox(0, '已检测到窗口', $hWin)
Func _WinWaitDebug($sTitle, $sText = '', $iTimeout = 0)
Opt('WinTitleMatchMode', -1)
Local $hWin, $iTs = TimerInit()
If $iTimeout > 0 Then
$iTimeout *= 1000
Do
Sleep(100)
If TimerDiff($iTs) >= $iTimeout Then
Local $aList = WinList(), $aWShow[UBound($aList) + 1][2], $ix = 0
For $i = 1 To $aList[0][0]
If $aList[$i][0] <> '' And BitAND(WinGetState($aList[$i][1]), 2) Then
$ix += 1
$aWShow[$ix][0] = $aList[$i][0]
$aWShow[$ix][1] = $aList[$i][1]
EndIf
Next
If Not $ix Then Return SetError(2, 0, 0)
$aWShow[0][0] = $ix
ReDim $aWShow[$ix + 1][2]
_ArrayDisplay($aWShow, '已超时,未检测到窗口.当前可见窗口')
Return SetError(1, 0, 0)
EndIf
$hWin = WinGetHandle($sTitle, $sText)
Until $hWin
Else
Do
Sleep(100)
$hWin = WinGetHandle($sTitle, $sText)
Until $hWin
EndIf
Return $hWin
EndFunc ;==>_WinWaitDebug
|