Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Autohotkey 使用自动热键的基于图层的键盘:更改修改器单按、按住和双击行为_Autohotkey - Fatal编程技术网

Autohotkey 使用自动热键的基于图层的键盘:更改修改器单按、按住和双击行为

Autohotkey 使用自动热键的基于图层的键盘:更改修改器单按、按住和双击行为,autohotkey,Autohotkey,各位 我想使用自动热键创建一个基于图层的键盘。基本上,我想实现shift已经完成的功能:在使用修改器时修改每个关键点 我想在以下方面改进定期轮班: 按一次修改器:仅为下一个角色更改图层 按住修改器:只要修改器处于关闭状态,就更改图层 按修改器两次:进入图层模式,如capslock。(另按一次结束) 修改器:LAlt、RAlt、L控制、R控制(CapsLock、Shift) 我如何做到这一点 到目前为止,我在stackoverflow上发现了: 此代码允许按下shift键并释放下一个字符 $

各位

我想使用自动热键创建一个基于图层的键盘。基本上,我想实现shift已经完成的功能:在使用修改器时修改每个关键点

我想在以下方面改进定期轮班:

  • 按一次修改器:仅为下一个角色更改图层
  • 按住修改器:只要修改器处于关闭状态,就更改图层
  • 按修改器两次:进入图层模式,如capslock。(另按一次结束)
修改器:LAlt、RAlt、L控制、R控制(CapsLock、Shift)

我如何做到这一点


到目前为止,我在stackoverflow上发现了: 此代码允许按下shift键并释放下一个字符

$*LShift:: 
    SendInput, {LShift Down}      ; press shift
    Input, Key, L1 M V            ; wait for input character
    If GetKeyState("LShift", "P") ; if shift still pressed, wait for release
        KeyWait, LShift
    SendInput, {LShift Up}        ; send input with shift down, the shift up
Return
此代码将双档压力机转换为CapsLock

LShift::
   KeyWait, CapsLock                      ; wait to be released
   KeyWait, CapsLock, D T0.2              ; and pressed again within 0.2 seconds
   if ErrorLevel
      return
   else if (A_PriorKey = "CapsLock")
      SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On"
   return

#If, GetKeyState("CapsLock", "P")         ; hotkeys go below
    a::b
#If
但我对AHK的经验不足,无法将其结合起来。我的目标是拥有像

Modifier::
    ; code that makes the modifier behave like expected: single press, hold, double press
Return

#If, GetKeyState("Modifier", "P")  ; List of key remaps in specific layer
#If  
我希望这是足够具体的,你可以在这里帮助我


谢谢

将相应的布尔值(true或false)分配给变量“Double_LAlt”和“Double_LAlt_holding”,以便根据其值创建上下文相关热键:

LAlt::
    ToolTip,,,, 3
    ToolTip,,,, 4
    Double_LAlt := false
    ; Press twice or press twice and hold LAlt within 0,2 seconds
    If (A_PriorHotKey = "~LAlt Up" AND A_TimeSincePriorHotkey < 200)
    {
        Sleep, 200      
        If GetKeyState("LAlt","P")
        {               
            ToolTip,,,, 4
            ToolTip, Double_LAlt_holding,,, 2
            Double_LAlt_holding := true
        }
        else
        {   
            ToolTip,,,, 4
            ToolTip, Double_LAlt,,, 3   
            Double_LAlt := true             
        }
    }
    If !((Double_LAlt_holding) || (Double_LAlt))    ; "!" means "NOT" and "||" means "OR"
        ToolTip, LAlt_holding,,, 1
return

~LAlt Up::
    ToolTip,,,, 1
    ToolTip,,,, 2
    Double_LAlt_holding := false
    Sleep, 100
    If (A_TimeIdlePhysical > 100)
        Tooltip, PriorHotKey = LAlt Up,,, 4
    SetTimer, RemoveTooltip, 1000
return


#If (Double_LAlt_holding)   ; If  this variable has the value "true"

    <!a:: MsgBox, a while Double_LAlt_holding       ; "<!" means "LAlt"
    <!1:: MsgBox, 1 while Double_LAlt_holding

#If (Double_LAlt)

    a:: MsgBox, a after Double_LAlt
    1:: MsgBox, 1 after Double_LAlt

    ; Press a key within 2 seconds after releasing LAlt:
#If (A_PriorHotKey = "~LAlt Up" AND A_TimeSincePriorHotkey < 2000)

    a:: MsgBox, a after LAlt Up
    1:: MsgBox, 1 after LAlt Up

#If GetKeyState("LAlt","P")

    a:: MsgBox, a while LAlt_holding
    1:: MsgBox, 1 while LAlt_holding

#If 

RemoveTooltip:
    If (A_TimeSincePriorHotkey > 2000) ;  2 seconds
        ToolTip,,,, 4
return
LAlt::
工具提示,,,,3
工具提示,,,,4
双重逻辑:=假
; 按两次或按两次并在0.2秒内按住LAlt
如果(A_prior热键=“~LAlt Up”和A_timesince prior热键<200)
{
睡吧,200
如果GetKeyState(“LAlt”、“P”)
{               
工具提示,,,,4
工具提示,双左左左左右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右右
Double_LAlt_holding:=真
}
其他的
{   
工具提示,,,,4
工具提示,双击,,,3
双对数:=真
}
}
如果!((双倍控股)双倍控股);“!”表示“不”,而“||”表示“或”
工具提示,LAlt_holding,,,1
返回
~LAlt Up::
工具提示,,,,1
工具提示,,,,2
Double_LAlt_holding:=假
睡吧,100
如果(A_TimeIdlePhysical>100)
工具提示,优先级热键=LAlt Up,,,4
SetTimer,RemoveTooltip,1000
返回
#If(双重持股);如果此变量的值为“true”
2000) ;  2秒
工具提示,,,,4
返回

这是非常巧妙的方法,谢谢。如果我没有弄错的话,我可以把If语句和#If(Double_LAlt_holding)| | GetKeyState(“LAlt”,“P”),对吗?我怎样才能使一次LAlt按键只在下一次按键时激活?我需要先退出热键If-statement。是的,非常有效。现在,我会想办法弄清楚你到底做了什么。。。谢谢:)