WinWait

首页  后退  前进

WinWait
down2

WinWait

暂停脚本执行,直到请求的窗口出现.

 

WinWait ( "title" [, "text" [, timeout = 0]] )

参数

title

目标窗口标题, 或句柄, 或类名. 参考 窗口标题与文本.

text

[可选] 目标窗口文本. 默认值为空字符串. 参考 窗口标题与文本.

timeout

[可选] 等待可能窗口不存在的限制时间(秒), 默认为 0(无超时).

返回值

成功:

返回请求窗口的句柄.

失败:

返回 0, 已超时.

备注

窗口每 250 毫秒左右轮询一次.

 

函数示例

Example()
Func Example()
    ; Run Notepad
    Run("notepad.exe")
    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)
    ; Wait for 2 seconds to display the Notepad window.
    Sleep(2000)
    ; Close the Notepad window using the classname of Notepad.
    WinClose("[CLASS:Notepad]")
EndFunc   ;==>Example

----------------------------------------

 

该函数可以通过命令调用 exect

参见:

WinActive, WinExists, WinWaitActive, WinWaitClose, WinWaitNotActive, WinWaitDelay (Опция), ProcessWait

例子
copy

exect=Run('notepad.exe')||WinWait('[CLASS:Notepad]')||Sleep(3000)||WinClose('[CLASS:Notepad]') ;; 运行"记事本",等待指定的窗口出现,3秒钟后关闭窗口

 

exect=Run('notepad.exe')||$var_h=WinWait('[CLASS:Notepad]','''',5)||WinSetState(HWnd($var_h),'''',@SW_MINIMIZE) ;; 开始"记事本",等待出现并关闭

 

exect=Run('notepad.exe')||$var_h=WinWait('[CLASS:Notepad]','''',5)||SendKeepActive(HWnd($var_h)) <FOR> 1 <TO> 10 exect=Send('Hello')||Sleep(500) <NEXT> exect=SendKeepActive('''')||WinClose(HWnd($var_h)) ;; 使用Send()函数运行记事本并保持记事本窗口处于活动状态

 

exect=Run('notepad.exe')||$var_h=WinWait('[CLASS:Notepad]','''',5)||IsHWnd(Eval('var_h'))?_ViewValues('Это~~дескриптор~~HWND'):_ViewValues('Это~~НЕ~~дескриптор~~HWND') ;; 运行记事本和检查窗口句柄的有效性

up2

tcimage © Аверин Андрей для Total Commander Image Averin-And@yandex.ru