Shift::Send {Shift down} LCtrl::Send {Shift up}
I’d like to be able to press shift, press the buttons that I want shift-modified, and then press shift to release/toggle off, just like caps lock
I want to be able to activate shift and deactivate shift by only pressing shift
Shift:: Send {Shift down} However, if previous key was shift down That is, If previous GetKeyState(shift down) Then Send {Shift up} Return
This is incorrect because GetKeyState always sees that shift is down as soon as I press shift
I need GetKeyState to see any {Shift down} that is not in the remapping
I’m not sure as to how to stop from going around in circles
I just found these 2 posts with code that seem relevant, but I don’t understand them
Of the 2 pieces of code in the 2 posts, which one works for me?
Thanks for any help
<!-- m -->http://www.autohotke... ... ggle shift<!-- m -->
by Icarus
#SingleInstance Force ; Define source keys (on the keyboard) ; Define target keys ; In this example, pressing "a" will send "q" and "b" will send "w" Source := "abcdefghijklmnopqrstuvwxyz1234567890-=[];'\,./" Target := "qwertyuiqwertyuiquwyteriuyqtweriuytiquywetriuy" ; Loop through all source keys and create a hotkey for each Loop parse, Source Hotkey $%A_LoopField%, PressKey Return ; This function handles all hotkeys PressKey: ; First, remove the $ sign StringReplace ThisHotkey, A_ThisHotkey, $ ; Find the position of the pressed key in the "Source" string Position := InStr( Source, ThisHotkey ) ; Pull the "twin" of the source character from the target string TargetChar := SubStr( Target, Position, 1 ) ; If caps lock is on, send Shift+TheKey, else, send only TheKey If( GetKeyState( "CAPSLOCK", "T" ) ) SendInput +%TargetChar% Else SendInput %TargetChar% Return ESC::ExitApp
<!-- m -->http://www.autohotke... ... ggle shift<!-- m -->
by animeaime
thid code looks simpler, but animeaime is replying to someone who only needs "wasd" modified for his game
#SingleInstance Force #NoEnv Shifted := false return ;Toggle <Shifted> Control::Shifted := !Shifted ;Sends wasd $w::Send("w") $a::Send("a") $s::Send("s") $d::Send("d") Send(Key) { ;if <Shifted>, sends +%Key% ;else, sends %Key% global Shifted if Shifted Send, +%Key% else Send, %Key% }