Function Reference


SendKeepActive

Attempts to keep a specified window active during Send().

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

Parameters

title The title/hWnd/class of the window to activate. See Title special definition. Use a blank title to disable the function.
text [optional] The text of the window. . Default is an empty string. See Text special definition.

Return Value

Success: 1.
Failure: 0 if window is not found.

Remarks

Using SendKeepActive("") attempts to reset the active window in between each simulated keystroke from Send().

Related

Send

Example

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