Jump to content

Send keystrokes quickly


oMBRa
 Share

Recommended Posts

... I want a speed like when u do Ctrl + V to paste some text

The sample code posted by Nahuel should work for you unless your app (like some apps I work with) ignores* ControlSetText. In that case, use ClipPut("text") and ControlSend("^v") [or if you must - just use Send("^v")]

ClipPut("This is a pretty long text that should appear in notepad really fast")
Run("notepad.exe")
WinWait("[Class:Notepad]")
ControlSend("[Class:Notepad]","","[CLASS:Edit; INSTANCE:1]", "^v")
Sleep(1500)
WinClose("[Class:Notepad]")oÝ÷ ØKÞÚ-z  è­ë-ë^ÆÛ§¶)r¢ë½ëayø¥xò¢èî²×%¢Ç­ì"Ú06^¥§pYg¢Úk¢jmÊ­¢Æ¯y©òµìmªê-±éíªê-¶­¾&¢{k¢Tµ7±µ«­¢+ØÀÌØíÑáÐôÅÕ½ÐíQ¡¥Ì¥ÌÁÉÑÑä±½¹ÑáÐÑ¡ÐÍ¡½Õ±ÁÁÈ¥¸¹½ÑÁɱ±äÍÐÅÕ½Ðì)IÕ¸ ÅÕ½Ðí¹½ÑÁ¹áÅÕ½Ðì¤)]¥¹]¥Ð ÅÕ½Ðím
±ÍÌé9½ÑÁtÅÕ½Ðì¤)
½¹Ñɽ±MÑQáÐ ÅÕ½Ðím
±ÍÌé9½ÑÁtÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðím
1MLé¥Ðì%9MQ9
èÅtÅÕ½Ðì°ÀÌØíÑáФ)M±À ÄÔÀÀ¤)]¥¹
±½Í ÅÕ½Ðím
±ÍÌé9½ÑÁtÅÕ½Ðì

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

AutoItSetOption("SendKeyDelay", 1)

AutoItSetOption("SendKeyDownDelay", 1)

Welcome to the forum.

It would depend on the volume of data being sent as to the speed delta between the fastest Send and the other methods. Try this code.

AutoItSetOption("SendKeyDelay", 1)
AutoItSetOption("SendKeyDownDelay", 1)

Dim $t
For $i = 1 To 500
    $t &= String($i)
Next

Run("notepad.exe")
WinWait("[Class:Notepad]")
Send("Send  " & $t)
Sleep(1000)
ControlSend("[Class:Notepad]", "", "[CLASS:Edit; INSTANCE:1]", "^a{BS}")
Sleep(1000)

ClipPut($t)
Sleep(50)
ControlSend("[Class:Notepad]", "", "[CLASS:Edit; INSTANCE:1]", "Paste  " & "^v")
Sleep(2000)
ControlSend("[Class:Notepad]", "", "[CLASS:Edit; INSTANCE:1]", "^a{BS}")
Sleep(1000)

ControlSetText("[Class:Notepad]", "", "[CLASS:Edit; INSTANCE:1]", "ControlSetText  " & $t)
Sleep(2000)
WinClose("[Class:Notepad]")

@oMBra,

You can overwhelm the Windows clipboard if you repeatedly transfer data to and from it as fast as AutoIt can. The OS clipboard may fail you at max speed... It would be best to use a Sleep of about 50 or a 100 ms between each repeated clipboard operation.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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...