WinActivate

首页  后退  前进

WinActivate
down2

WinActivate

激活指定窗口.

 

WinActivate ( "title" [, "text"] )

参数

title

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

text

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

返回值

成功:

返回目标窗口句柄.

失败:

返回 0, 窗口没有找到或不能被激活.

备注

可以使用 WinActive() 函数检查 WinActivate 是否成功.

若同时有多个窗口符合匹配条件, 则激活最近被激活的窗口.

WinActivate 对最小化窗口仍能正常工作.

但"置顶"可能会掩盖你激活的窗口.

 

成功激活后 @extended 设置为 1, 如果未激活则 @extended 设置为 2.

 

函数示例

Example()
Func Example()
    ; Run Notepad
    Run("notepad.exe")
    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
    ; Activate the Notepad window using the handle returned by WinWait.
    WinActivate($hWnd)
    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

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

 

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

参见:

WinClose, WinSetState, WinTitleMatchMode (选项), WinKill, WinMove

例子
copy

exect=$var_h=WinActivate('Безымянный~~~~Блокнот')||ControlSend(Eval('var_h'),'''','[CLASS:Edit;INSTANCE:1]','Это~~некоторый~~текст') ;; 激活"记事本"窗口并插入指定的文本(应该启动)

 

exect=WinActivate('[CLASS:Notepad]') ;; 激活记事本窗口

 

exect=$var_h=WinActivate('[CLASS:AkelPad4]')||WinWaitActive(Eval('var_h')) ;; 激活AkelPad窗口,暂停操作直到窗口被激活

up2

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