2
votes

Please, bear with me, I'm a autohotkey noob. I want left: control and shift to switch from their current key value to arrow: down and up respectively when pressing the F2 key. And when the F2 key is pressed again, I want left: control and shift to return to their original key value. This is my code so far:

F2::
{
    if LShift = Up
    {
        LShift::Send {LShift}   
    }
    else
    {
       LShift::Send {Up}        
    } 
    if LControl = Down
    {
       LControl::Send {LControl}    
    }
   else
   {
      LControl::Send {Down}     
   }    
}

Regrettably I haven't been able to make it work. Any help will be truly appreciated.

1

1 Answers

0
votes
  • Hotkeys that go over multiple lines don't use curly braces. They start with the hotkey label and end with a simple Return.
  • You can't enclose hotkey labels by normal if statements. You have to use special #If statements instead.
  • Nesting hotkeys is also definitely not what you want to do.
  • To remap a key you can use the single line hotkey syntax.

You can pretty much short your code down to:

F2::(F2Toggle:=!F2Toggle)

#If F2Toggle
    LShift::Up
    LControl::Down
#If

Pressing F2 will toggle the variable F2Toggle between true and false. #If F2Toggle means if the variable F2Toggle is currently set to True then enable the hotkeys below. #If marks the end of the special #If statement.