Jump to content

Functions _Send() and _ControlSend() to replace Send() and ControlSend()


Exit
 Share

Recommended Posts

; Functions _Send() and _ControlSend() to replace Send() and ControlSend()
; by Forumer100
; Often you have to pause a small amount of time between two or more Send() or Conrolsend() statements.
; This are at least 3 or more statements:  Send(), Sleep(), Send(), Sleep(), ... , Send().
; I added a special key "{delay mmmm}" mmmm = milliseconds to keep it in 1 statement. See sample below. Just press F5.

$t = Run("Notepad.exe") & WinWait("[Class:Notepad]", "", 1) & WinActivate("[last]") & WinWaitActive("[last]", "", 1)
_send("^{end}{enter}; This{delay 500} is{delay 1000} a comment.{delay 2000}{left 10}really ")
_controlsend("[Class:Notepad]", "", "Edit1", "{end}{enter}{delay 1500}; This{delay 500} is{delay 2000} a controlsend comment.{delay 2000}{left 22}really {end}{enter}{enter}{delay 1500}: End of Demo.{delay 1500} Bye,Bye.")
_send("{delay 4000}!{F4}{delay 1500}{Tab}{delay 2500}{enter}")
Exit MsgBox(48 + 262144, "", @LF & "End of _Send() / _ControlSend Demo()" & @LF, 0)
; end of sample

Func _Send($keys, $flag = 0) ; by forumer100
    ; send keystrokes with embedded delay.
    ; syntax like normal send(), but special key "{delay mmmm}" added. mmmm = milliseconds
    While $keys > ""
        $index = StringInStr($keys, "{delay ")
        If $index Then
            Send(StringLeft($keys, $index - 1), $flag)
            $keys = StringTrimLeft($keys, $index + 6)
            $index = StringInStr($keys, "}")
            Sleep(StringLeft($keys, $index - 1))
            $keys = StringTrimLeft($keys, $index)
            ContinueLoop
        EndIf
        Send($keys, $flag)
        ExitLoop
    WEnd
EndFunc   ;==>_Send

Func _ControlSend($title, $text, $controlID, $keys, $flag = 0) ; by forumer100
    ; send keystrokes with embedded delay.
    ; syntax like normal ControlSend(), but special key "{delay mmmm}" added. mmmm = milliseconds
    While $keys > ""
        $index = StringInStr($keys, "{delay ")
        If $index Then
            ControlSend($title, $text, $controlID, StringLeft($keys, $index - 1), $flag)
            $keys = StringTrimLeft($keys, $index + 6)
            $index = StringInStr($keys, "}")
            Sleep(StringLeft($keys, $index - 1))
            $keys = StringTrimLeft($keys, $index)
            ContinueLoop
        EndIf
        ControlSend($title, $text, $controlID, $keys, $flag)
        ExitLoop
    WEnd
EndFunc   ;==>_ControlSend
; end of script

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...