Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

controlsend


  • Please log in to reply
9 replies to this topic
slemma
  • Members
  • 45 posts
  • Last active: Aug 05 2013 11:24 PM
  • Joined: 24 Aug 2011
some times controlsend change the slash to dash and sends it. Why is it doing that. Please help

Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009
That results seems very strange. Please post an example of the code you use.

slemma
  • Members
  • 45 posts
  • Last active: Aug 05 2013 11:24 PM
  • Joined: 24 Aug 2011
for example i was trying to send the following to the IVT window and sometimes it injects a different character, like replace the slash with dash or underscore. but if i run it again, it is fine. Very strange.

controlsend,,K:\sapphire\tools\BKM\SBFT\mci_fix_updated_v2.pl -mask_sigmode {enter}, IVT

G. Sperotto
  • Members
  • 539 posts
  • Last active: Jun 20 2015 04:54 PM
  • Joined: 12 Dec 2011
Hi Slemma.

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


slemma
  • Members
  • 45 posts
  • Last active: Aug 05 2013 11:24 PM
  • Joined: 24 Aug 2011
That is not working. Here is the actual result i just saw

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.

  • Guests
  • Last active:
  • Joined: --
Fairly common, try to send the clipboard
clipboard:="youstring"
ControlSen, ^v...


EatNoMeat
  • Members
  • 5 posts
  • Last active: Feb 25 2019 10:43 PM
  • Joined: 28 Jul 2012

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



RHCP
  • Members
  • 1228 posts
  • Last active: Apr 08 2017 06:17 PM
  • Joined: 29 May 2006

 

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



EatNoMeat
  • Members
  • 5 posts
  • Last active: Feb 25 2019 10:43 PM
  • Joined: 28 Jul 2012

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.



EatNoMeat
  • Members
  • 5 posts
  • Last active: Feb 25 2019 10:43 PM
  • Joined: 28 Jul 2012

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
}