SendKeepActive

首页  后退  前进

SendKeepActive
down2

SendKeepActive

使用 Send() 函数时,保持窗口激活状态.

 

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

参数

title

窗口标题, 或句柄, 或类名. 参考 窗口标题与文本. 使用空标题可禁用此函数.

text

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

返回值

成功:

返回 1.

失败:

返回 0, 窗口不存在.

备注

每次使用 Send() 模拟键击时, 都必须使用 SendKeepActive("") 保持窗口激活状态.

 

函数示例

Example()
Func Example()
    ; Run Notepad
    Run("notepad.exe")
    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
    ; Keep the Notepad window active when using the Send function.
    SendKeepActive("[CLASS:Notepad]")
    ; Simulate entering a string of text. If you try to change to a different window other than Notepad, then the Notepad window will
    ; be brought to focus again.
    For $i = 1 To 10
        Sleep(500)
        Send("notepad - ")
    Next
    ; Disable the Notepad window being active when using the Send function.
    SendKeepActive("")
    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
    ; Now a screen will pop up and ask to save the changes, the classname of the window is called
    ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
    WinWaitActive("[CLASS:#32770]")
    Sleep(500)
    Send("{TAB}{ENTER}")
EndFunc   ;==>Example

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

 

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

参见:

Send

例子
copy

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()函数运行记事本并保持记事本窗口处于活动状态

up2

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