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:
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.
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.
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)
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!
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
Change keyboard layout.png (32.14 KiB) Viewed 638 times
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:
^+a::send, aaa ; or ^>:: or ^+,:: or ^+o:: etc
; Triggers keyboard layout change.
; That sends "aaa", and next time "ффф", then "aaa" again.
; So we get after several triggerings of this hotkey a string like "aaaфффaaaфффaaaффф"
^+a:: ; acts like ^+a::send, aaa
Sleep 100
send, aaa
return
^+a::SetTimer, T, -100 ; acts like ^+a::send, aaa
T:
send, aaa
return
^+a::send, {Text}aaa ; Changes keyboard layout and sends always literal "aaa" (not "ффф").
^+a::send, {Raw}aaa ; acts like ^+a::send, aaa
;---------------------------------------------------------------
; The above line triggers keyboard layout change. Change layout, then send {a}{a}{a} with already changed layout.
;================================================================
; But the lines below don't trigger it:
;----------------------------------------------------------------
^+a::ToolTip, aaa ; Keyboard layout it unchanged. The problem exists only with Send commands.
^+a::return ; The same.
^+a:: ; Always sends literal "aaa" (never "ффф"), and keyboard layout is unchanged!
Sleep 400 ; with sleep 100 it would change the layout since I would still hold Ctrl and Shift buttons after 100 ms, but released after 400 ms.
send, aaa
return
^+a::SetTimer, T, -400 ; acts like a script with sleep 400
T:
send, aaa
return
^+a::send, {Blind}{Text}aaa ; sends "aaa", and the layout is unchanged!
^+a::send, {Blind}{Raw}aaa ; nothing happens. At all.
^+a::send, {Blind}aaa ; nothing happens.At all.
^+a::send, ^z ; It is a baseline. It changes keyboard layout and do "undo".
^+a::send, {Blind}{Shift Up}z ; acts the same way (like ^+a::send, ^z)
^+a::send, {vkFF}^z ; We are moving in a right direction by including a mask key in front to prevent keyboard layout change.
; But... not that way, it fails and also acts the same (like ^+a::send, ^z)
^+a::send, {Blind}{vkFF}z ; nothing happens since Shift isn't released because of {Blind} mode
^+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.