Jump to content

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

Send ^c vs Send {Ctrl Down}c{Ctrl Up}


  • Please log in to reply
11 replies to this topic
himanshu
  • Members
  • 95 posts
  • Last active: Jan 04 2013 03:35 PM
  • Joined: 18 Jul 2011
What is the difference between the following Send commands:

Send ^c
Send {Ctrl Down}c{Ctrl Up}

I have found them to behave differently occasionally. Earlier, I found the latter alternative to be more robust (in releasing the ctrl key after Send is over) when a VMWare window was active, but now, for some other application (Console2), I am finding that the former is more robust, while the latter sometimes only Sends the keystroke 'c' instead of 'ctrl c'.

Confused :O

Any suggestions anyone?

  • Guests
  • Last active:
  • Joined: --
Each program will react a bit different to AutoHotkey "input" so it may indeed be the case where one works and the other doesn't for the same program, you'll have to experiment a bit and can "set" various methods using #IfWinActive or IfWinActive commands to see which window is active before pasting. There is no one solution.

himanshu
  • Members
  • 95 posts
  • Last active: Jan 04 2013 03:35 PM
  • Joined: 18 Jul 2011
Makes sense. And I am already using #If conditions etc to determine which one I am using.
But I was wondering if any one knows how Send is implemented, and can tell me exactly how these are different. So that I have some idea of which one to use in a new situation, instead of by first coming across inconsistent behavior in the script and then experimenting randomly.

  • Guests
  • Last active:
  • Joined: --
You can also try various send modes (input, play, event) - you can check out the AutoHotkey source code here <!-- m -->https://github.com/Lexikos/<!-- m -->

himanshu
  • Members
  • 95 posts
  • Last active: Jan 04 2013 03:35 PM
  • Joined: 18 Jul 2011
Thanks, but I know about the different Send modes. The Send mode in effect should anyway be applicable to both of the following code fragments below (assuming it is not being changed in between)
Send ^c
and
Send {Ctrl down}c{Ctrl up}
. I have "SendMode Input" specified near the top of my script and it remains the same throughout.

Does anyone know the specific difference in how these two Send commands are implemented?
I would have thought the first code fragment is identical to (and is just syntactic sugar for) the second one. But apparently that's not true.

Again, to repeat, I am not so interested in playing around with different Send modes etc (because at the moment everything is working fine). I just wanted to know -- for the future mainly -- how exactly are the two Send commands written above different.

himanshu
  • Members
  • 95 posts
  • Last active: Jan 04 2013 03:35 PM
  • Joined: 18 Jul 2011
Anyone?

himanshu
  • Members
  • 95 posts
  • Last active: Jan 04 2013 03:35 PM
  • Joined: 18 Jul 2011
bump. ahem ahem. anyone?

(I know I can quit being lazy and look up the source code myself, but I thought I'd try the easy route one last time :)

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
i dont know, maybe lexikos can chime in

bettyj
  • Members
  • 40 posts
  • Last active: Apr 03 2016 12:42 PM
  • Joined: 22 Aug 2012
It has to do with the way the key commands are sent I think.

for example " c ", " ctrl", and " ctrl + c " are three different commands. If you have ever opened up a keyboard and looked at it you would understand, but basically when you if you hit Ctrl then c it will first send the signal for the CTRL key then the signal for both. If you hit both at the same time then it only sends the signal for both. I know that AHK isn't exactly the the slowest typer in the world but It may act differently to applications that already use the CTRL key for something "like a game that uses the CTRL key for crouch"

Soubhi Sabbagh
  • Members
  • 3 posts
  • Last active: Feb 14 2014 03:15 PM
  • Joined: 10 Feb 2014

Hi,

I read more about the use of windows ^c shortcut with Autohotkey.

all the following methods are not working properly:

 

1-

Send ^c

2-

SetKeyDelay, 40        ;Any number you want (milliseconds)
SendEvent {Clrtl Down}c{Ctrl Up}; Also I get the same unstable issue with SendPlay and SendInput

So the best way is to work directly with the text field. I developed a very nice example below

/*As Send ^c is not accurate at all. I edited the file C:\Program Files\AutoHotkey\SciTE\tools\ActiveWindowInfo.ahk and I collected this nice info.
Perhaps this was caused by hiperthreading
I noticed that in case of unstable ^c , the Windows LogOff and  LogOn helped to temporary solve the issue
Also, changing Send to SenEvent or SendPlay didn't help for the same issue ,and even if we slowed down the writing speed!

The best way is to collect the data from the working ClassNN  
1- Edit this program using SciTE4AutoHotkey
2- Press F1 to open the AHK Help file where we want to try our tool
3- Run the program
Title : AutoHotkey Help
ClassNN : Edit1

Used commands:
ControlGetText, OutputVar [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlSetText [, Control, NewText, WinTitle, WinText, ExcludeTitle, ExcludeText]
*/

^!z:: ; press Control + ALt + z to run the program
{
	ControlGetText, CText, Edit1, AutoHotkey Help ;Copy The Content of Edit1 (ClassNN SearchBox) of AHK Help to new Variable Named CText
	MsgBox, 64, Text Copy, Edit1: %CText% ;Display the copied content to the user
	MsgBox, 64, Info, Search Text Will be set to ControlSetText ;Display Info To The User
	ControlSetText , Edit1, ControlSetText, AutoHotkey Help ;Set The Content of Edit1 (ClassNN  SearchBox) of AHK Help using "ControlSetText"
	ControlGetText, CText, Edit1, AutoHotkey Help ;verify the new Content of Edit1 (ClassNN SearchBox) at AHK Help to new Variable Named CText
	MsgBox, 64, Text Copy, New Edit1: %CText% ;Display the copied content to the user
}


Soubhi Sabbagh
  • Members
  • 3 posts
  • Last active: Feb 14 2014 03:15 PM
  • Joined: 10 Feb 2014

Don't you think that the issue of ^c is:

 

1- caused by HyperThreading of dual core or newer processor? So, did anyone try to stop the Hyperthreading while using AutoHotKey?  :S

2- Or cause of the way Autohotkey process keyboard scanning?

3- Or an interrupt process!

4- What if we used RUN AS --> compatibility --> older windows!



Soubhi Sabbagh
  • Members
  • 3 posts
  • Last active: Feb 14 2014 03:15 PM
  • Joined: 10 Feb 2014

Don't you think that the issue of ^c is:

 

1- caused by HyperThreading of dual core or newer processor? So, did anyone try to stop the Hyperthreading while using AutoHotKey?  :S

2- Or cause of the way Autohotkey process keyboard scanning?

3- Or an interrupt process!

4- What if we used RUN AS --> compatibility --> older windows!