controlsend
controlsend,,K:\sapphire\tools\BKM\SBFT\mci_fix_updated_v2.pl -mask_sigmode {enter}, IVT
Perhaps you can deal away with the issue by using ControlSendRaw instead:
ControlSendRaw,,K:\sapphire\tools\BKM\SBFT\mci_fix_updated_v2.pl -mask_sigmode, IVT ControlSend,, {enter}, IVT
Best wishes :wink:
"What is a suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
controlsend,,K:\sapphire\data\A0\FC\slemma\DefaultName.pl {enter}, IVT
returned or sends the following on IVT window.
K:|sapphire\data\A0\FC\slemma\DefaultName.pl
it just replaced the slash with straight line. It is very strange.
clipboard:="youstring" ControlSen, ^v...
This bug is still present.
Has nobody been able to track down the cause?
edit: I'll run some tests tonight to see what I can find
This bug is still present.
Has nobody been able to track down the cause?
The manual clearly states the problem.
https://autohotkey.c...?p=38107#p38107
I figured out the cause a couple of days ago. Was going to post about it but a storm took down my region's Internet for two days.
Thanks for the link though.
Now there's an answer for anyone else who finds this thread.
I'll add that setting SetKeyDelay to -1 results very frequent errors, and setting it to 5 results in very few errors.
Also, Control, EditPaste is an excellent alternative if you happen to be sending to a compatible window.
btw, I found nothing in the help file about the cause of this problem and this thread was the only thing that came up when I searched the site.
Just wanted to share my more recent findings:
The second parameter of SetKeyDelay (the PressDuration parameter) is the one that makes the biggest difference when it comes to reliably sending shift characters (eg, uppercase letters and underscores).
Using SetKeyDelay 1, 40 I was able to send a string of characters (----M-M-) to a Notepad window (and a cmd window) 10000 times with no errors. However, I wasn't using the mouse or keyboard while the script was running.
Upon running the script a second time, I fiddled with the mouse & keyboard and found that minimizing & restoring the target window while the script was running would fairly often cause errors to occur (shift characters would be sent as regular characters and vice versa).
Personally, I need 100% accuracy so I now use the BlockInput on command just before each ControlSend command, and BlockInput off once the ControlSend command completes, just to make sure I don't do anything with the keyboard or mouse that might cause a send error.
The AutoHotkey help file has the following warning about using BlockInput with ControlSend:
BlockInput should be avoided when using ControlSend against a console window such as command prompt. This is because it might prevent capitalization and modifier keys such as Control from working properly.
Personally, I've turned on BlockInput and sent keys (using ControlSend) to the cmd prompt and Telnet prompt without errors, but that's just two prompts and I'm only using regular characters and shift characters (no control characters). Though I did try sending a single control command (^d) to the Telnet prompt and it worked fine.
When sending only regular, non-shift characters (eg, lowercase letters and hyphens) I never encountered any send errors, regardless of what values were used for SetKeyDelay.
I made the following function because I send mostly non-shift characters and didn't want to dramatically slow down all of my sending just for an occasional shift character. The function slows down sending only for shift characters and allows all other characters to be sent at full speed. It also blocks user input while the characters are being sent (if you don't want that, you can just remove the blockinput on line).
I'm an amateur AutoHotkey user so this may not be the best solution but it's working well for me.
/* ;USAGE EXAMPLE 1 ControlSendX("","My_____sHiFtY----------TeXt","Untitled - Notepad","","","") ;USAGE EXAMPLE 2 myControl = Edit1 myKeys = My_____sHiFtY----------TeXt myWinTitle = Untitled - Notepad myWinText = myExcludeTitle = myExcludeText = ControlSendX(myControl,myKeys,myWinTitle,myWinText,myExcludeTitle,myExcludeText) ;USAGE EXAMPLE 3 useraw := 1 myControl = Edit1 myKeys = My_____sHiFtY----------TeXt______WiTh_An_eScApEd_pLuS_sIgN___`+ myWinTitle = Untitled - Notepad ControlSendX(myControl,myKeys,myWinTitle,myWinText,myExcludeTitle,myExcludeText) */ ControlSendX(Control,Keys,WinTitle,WinText,ExcludeTitle,ExcludeText) { blockinput on ;Increases reliability by preventing user interference while keys are being sent to window. However, according to the help file, this 'might prevent capitalization and modifier keys such as Control from working properly when using ControlSend against a console window such as command prompt' prvcase := A_StringCaseSense prvdelay := A_KeyDelay stringcasesense, on global shiftchars global useraw if (shiftchars = "") { shiftchars=ABCDEFGHIJKLMNOPQRSTUVWXYZ`!`@`#`$`%`^`&`*`(`)`_`+`{`}`|`:`"`<`>`?`~ } loop, parse, Keys { ifinstring, shiftchars, %a_loopfield% { setkeydelay 1, 100 ;100 might be overkill - had good results with 40 } else { setkeydelay -1, 10 } if (useraw = 1) { controlsendraw,%Control%,%a_loopfield%,%WinTitle%,%WinText%,%ExcludeTitle%,%ExcludeText% } else { controlsend,%Control%,%a_loopfield%,%WinTitle%,%WinText%,%ExcludeTitle%,%ExcludeText% } } stringcasesense, %prvcase% setkeydelay %prvdelay%, -1 blockinput off useraw := 0 }