Raw modifier key (<) in a hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
doo2aan
Posts: 3
Joined: 24 Jan 2022, 11:36

Raw modifier key (<) in a hotkey

Post by doo2aan » 24 Jan 2022, 12:11

Hello,
I need help. I want to use Ctrl+"<" as a shortcut, and remap it to Ctrl+Z. However, "<" is a modifier key, and I didn't find a way to use it in a shortcut on its own. I tried:

Code: Select all

^<::Send ^z
^{<}::Send ^z
I tried to google and search forums but didn't find the answer. Thanks in advance.

User avatar
mikeyww
Posts: 26612
Joined: 09 Sep 2014, 18:38

Re: Raw modifier key (<) in a hotkey

Post by mikeyww » 24 Jan 2022, 12:19

The first hotkey is fine. On my keyboard, I must also press Shift to get the <, because that key is a shifted key. If you want ,, then use it instead.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Raw modifier key (<) in a hotkey

Post by amateur+ » 24 Jan 2022, 12:25

mikeyww, on my PC it also switches keyboard layout because it is set up to Ctrl + Shift.
And ^+, too.
Last edited by amateur+ on 24 Jan 2022, 12:27, edited 1 time in total.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

User avatar
mikeyww
Posts: 26612
Joined: 09 Sep 2014, 18:38

Re: Raw modifier key (<) in a hotkey

Post by mikeyww » 24 Jan 2022, 12:26

If you have already established a different action for Ctrl+Shift, then so be it!

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Raw modifier key (<) in a hotkey

Post by amateur+ » 24 Jan 2022, 12:31

mikeyww, the problem exists only with Send commands like even Send, aaa. For example, ToolTip or MsgBox don't trigger keyboard layout change.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

User avatar
mikeyww
Posts: 26612
Joined: 09 Sep 2014, 18:38

Re: Raw modifier key (<) in a hotkey

Post by mikeyww » 24 Jan 2022, 12:36

OK, thanks. I had no trouble with the script here.

doo2aan
Posts: 3
Joined: 24 Jan 2022, 11:36

Re: Raw modifier key (<) in a hotkey

Post by doo2aan » 24 Jan 2022, 13:22

Code: Select all

^<::Send ^z
doesn't have any effect by me. I want to assign it to undo function (generally, that's why I want to send ctrl+z).

User avatar
mikeyww
Posts: 26612
Joined: 09 Sep 2014, 18:38

Re: Raw modifier key (<) in a hotkey

Post by mikeyww » 24 Jan 2022, 13:37

You pressed Ctrl+Shift+,?

gregster
Posts: 8930
Joined: 30 Sep 2013, 06:48

Re: Raw modifier key (<) in a hotkey

Post by gregster » 24 Jan 2022, 15:04

If < is a shifted key depends on the keyboard layout, on a german layout (and a number of other layouts) it is not.
Also, you could try the scan code of the key: please compare viewtopic.php?f=76&t=98948#p439414 (your scan code might be different to the one used in that example)

User avatar
mikeyww
Posts: 26612
Joined: 09 Sep 2014, 18:38

Re: Raw modifier key (<) in a hotkey

Post by mikeyww » 24 Jan 2022, 15:31

Good point, gregster.

I sometimes also ask, too: that is the entire script, and no other scripts are running at the same time? Test in Notepad as a first step.

doo2aan
Posts: 3
Joined: 24 Jan 2022, 11:36

Re: Raw modifier key (<) in a hotkey

Post by doo2aan » 24 Jan 2022, 15:55

Problem solved, thank you, people! Firstly I didn't understand mikeyww and why he mentions "shift" :) I have a German keyboard layout, "<" is not shifted - gregster helped me realize that. Scan code works well. Thanks!

User avatar
mikeyww
Posts: 26612
Joined: 09 Sep 2014, 18:38

Re: Raw modifier key (<) in a hotkey

Post by mikeyww » 24 Jan 2022, 16:12

I will try to be more German next time! :)

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Raw modifier key (<) in a hotkey

Post by amateur+ » 24 Jan 2022, 16:54

mikeyww wrote:
24 Jan 2022, 12:36
OK, thanks. I had no trouble with the script here.
mikeyww, for you I'm sure this solution would be easy to find and maybe not that interesting, but I'll show it for someone who would like to beat that ^+ problem with Ctrl+Shift being set for changing keyboard layout. Here what I discovered:
First of all, I meant Ctrl+Shift being set in OS preferences, not by some ahk-hotkey:
Spoiler
Next. Layout changing happens after user releases either Ctrl or Shift.
So when we send something after ^+,:: (or ^+a:: or ^>:: or ^+,:: or ^+o:: etc) like Send, aaa or Send, ^z then the script releases those or just one of Ctrl and Shift buttons to send then aaa or ^z. And at that moment layout changes and {a}{a}{a} would be sent already in a new layout. And ^z would make "undo", but keyboard layout is now changed.
Below are observations for Send, aaa:
Spoiler
And now below are my observations for Send, ^z:
Spoiler
And finally, the solution:

Code: Select all

^+a::send, {Blind}{vkFF}{Shift Up}z  ; - the solution! 
; We used a mask key vkFF that does nothing and then we logically released Shift in a Blind mode, 
; so as soon as Ctrl is still logically pressed then we just need to add {z} for success. 
; Keyboard layout it unchanged and we've done "undo" via Ctrl+Z. Hallelujah!
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

User avatar
mikeyww
Posts: 26612
Joined: 09 Sep 2014, 18:38

Re: Raw modifier key (<) in a hotkey

Post by mikeyww » 24 Jan 2022, 17:28

It looks interesting. Thanks for sharing the solution.

Post Reply

Return to “Ask for Help (v1)”