简体   繁体   English

重新映射问题自动热键

[英]Remapping issue Autohotkey

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. 我要左键:控制和shift键,从当前键值切换到箭头:按下F2键时分别向下和向上键。 And when the F2 key is pressed again, I want left: control and shift to return to their original key value. 当再次按下F2键时,我想离开:控制并移动到其原始键值。 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. 任何帮助将不胜感激。

  • Hotkeys that go over multiple lines don't use curly braces. 跨多行的热键不使用花括号。 They start with the hotkey label and end with a simple Return . 它们以热键标签开头,以简单的Return结束。
  • You can't enclose hotkey labels by normal if statements. 您不能通过常规的if语句将热键标签括起来。 You have to use special #If statements instead. 您必须使用特殊的#If语句。
  • 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. 按下F2将在真与假之间切换变量F2Toggle #If F2Toggle means if the variable F2Toggle is currently set to True then enable the hotkeys below. #If F2Toggle表示变量F2Toggle当前是否设置为True,则启用下面的热键。 #If marks the end of the special #If statement. #If标记特殊的#If语句的结尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM