Simulating a Ctrl key

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKxx
Posts: 75
Joined: 26 Feb 2014, 01:37

Simulating a Ctrl key

Post by AHKxx » 09 May 2021, 17:48

Hi. I am using a new device that does not have a right side Ctrl key. It does have a standard right side Alt key and a standard "right click" context menu key.

Is it possible to use those two keys together to function as a Ctrl key in combination with another randomly variable key, to send standard commands like Ctrl+C, Ctrl+V, etc?

If so, could that alt+menu combo then be combined with the Win, left Shift, and left side Alt key to output, e.g., Ctrl(alt+menu)+Shift+V.

I'm sure I'm not the first person to ask about this.

Thanks!
User avatar
mikeyww
Posts: 26600
Joined: 09 Sep 2014, 18:38

Re: Simulating a Ctrl key

Post by mikeyww » 09 May 2021, 17:55

Code: Select all

AppsKey::AppsKey
AppsKey & RAlt::Ctrl
AHKxx
Posts: 75
Joined: 26 Feb 2014, 01:37

Re: Simulating a Ctrl key

Post by AHKxx » 09 May 2021, 18:50

Thank you!

That didn't work or do anything that I was able to notice. But I had previously used a scan code for the menu key, and when I substituted that for AppsKey in your code, it worked!

Code: Select all

SC15D::SC15D
SC15D & RAlt::Ctrl

But it is dependent on the keys being pressed in that order. And when I swap their order in the code, it no longer works. Any way to do it so that it also works when the Alt key is pressed first?
TAC109
Posts: 1098
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Simulating a Ctrl key

Post by TAC109 » 09 May 2021, 20:13

I had a similar problem on my laptop, and use this code:

Code: Select all

+AppsKey::AppsKey         ; Shift + AppsKey => AppsKey 
 AppsKey::Ctrl            ; AppsKey => Ctrl
It is a bit different from what you requested, but as I don’t need the AppsKey function very much, it is more convenient.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
mikeyww
Posts: 26600
Joined: 09 Sep 2014, 18:38

Re: Simulating a Ctrl key

Post by mikeyww » 09 May 2021, 20:22

Code: Select all

>!AppsKey::Ctrl
#If GetKeyState("AppsKey", "P")
$AppsKey Up::
Sleep, 100
Send {AppsKey up}
Return
*x::
*c::
*v::Send % "^" SubStr(A_ThisHotkey, 0)
#If
I cannot fully explain why this works, but it does seem to work.
Post Reply

Return to “Ask for Help (v1)”