ControlSend sends wrong characters

Report problems with documented functionality
enthused
Posts: 94
Joined: 27 Dec 2014, 03:28

ControlSend sends wrong characters

12 Feb 2015, 23:20

This was discussed here:
http://ahkscript.org/boards/viewtopic.php?f=5&t=6372

Code: Select all

#singleinstance,force
pr=notepad
sc=ahk_exe Notepad.exe

Gui,2: Add, Button, x10 y60 h25 w160 gA1,Write to Notepad
Gui,2: Show,x10 y10 h90 w200,Run_Notepad
Gui,2: Add, Edit, x10 y10 h40 w180 vE1, TEST1 `nTEST2 `n
return
2Guiclose:
exitapp

A1:
Gui,2: Submit, nohide
IfWinNotExist,%sc%
  {
  Run, %pr%,,,pid1
   WinWait,%SC%
   IfWinNotActive ,%SC%,,WinActivate,%SC%
      WinWaitActive,%SC%
  }
ControlSend,,%e1%,%sc%
return
Output:
TEST1 ; first send good
TEST2 ; first send good
tEST! ; second send note lower "T" and "!" instead of "1"
[email protected]; second send note lower "T" and "@" instead of "2"
AHK 1.1.19.03 64 bit
Win 7 64 bit
lexikos
Posts: 6490
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: ControlSend sends wrong characters

13 Feb 2015, 01:02

Sending keystrokes is inherently unreliable. This is not a bug. See below.
ControlSend wrote:The value of SetKeyDelay determines the speed at which keys are sent. If the target window does not receive the keystrokes reliably, try increasing the press duration via the second parameter of SetKeyDelay as in these examples:

Code: Select all

SetKeyDelay, 10, 10
SetKeyDelay, 0, 10
Note: ControlSend does not send characters. It sends keystroke messages.
enthused
Posts: 94
Joined: 27 Dec 2014, 03:28

Re: ControlSend sends wrong characters

13 Feb 2015, 01:07

Thank you Lexikos :D
Works well with: SetKeyDelay

edit:
lexikos wrote:Note: ControlSend does not send characters. It sends keystroke messages.
Thank you for the clarification. Important distinction.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 10 guests