1

我想;成为一个新的修饰键。以下工作几乎完美。

`;::
if GetKeyState("LShift", "P")
    Send `:
else
    Send `;
return

`; & x::
if GetKeyState("LShift", "P")
    ...
else
    ...
return

以下愿望清单中只有第 2 点不起作用。有人知道如何修复此代码吗?

  1. ;;单独按下时
  2. shift ;:单独按下时
  3. ;x成为第二个...
  4. shift与成为第;一个x...
4

3 回答 3

1

以下工作完美,但由于代码重复而代码难看。也许更简洁的代码是可能的。

started := 0
LShift & `;::
if started = 0
    started := A_TickCount
return
`;::
if started = 0
    started := A_TickCount
return

LShift & `; Up::
if A_TickCount - started < 500
    Send `:
started = 0
return

`; Up::
if A_TickCount - started < 500
    Send `;
started = 0
return

`; & x::
started = 0 ; <==== !
if GetKeyState("LShift", "P")
    ...
else
    ...
return

现在,只要与(无延迟)组合使用或按下超过半秒,该键;就可以用作修饰键。x延迟不是必须的,可以消除;它只是在那里防止将意外的修饰键误解为;. 冒号:也可以正常工作。

于 2020-04-13T13:51:02.990 回答
1
#MaxThreadsPerHotkey 2 ; allow 2 "instances" of the hotkey subroutine to exist simultaneously

`;::
If (A_PriorKey = "`;") ; ; was pressed alone
    Send `;
return

LShift & `;:: Send :

`; & x::
if GetKeyState("LShift", "P") ;  ; & LShift & x
    Send a
else                          ; ; & x
   Send b
return
于 2020-04-13T16:04:46.467 回答
1

在我看来,有两种可能的方法可以使第 2 点起作用。

方法一:保持左Shift键的默认行为

移位+ ; 结果冒号键被按下。您可以通过在`;之前添加波浪号“~”键来使第 2 点起作用 并删除

else 
    send `;

使用 ~ 您可以保持密钥的默认行为。新脚本看起来像这样

~`;::
    if GetKeyState("LShift", "P") 
        Send `:
return 

`; & x::
    if GetKeyState("LShift", "P")
        ...
    else
        ...
return

通过使用此方法脚本将能够发送: with shift+; .

方法二: 去掉左Shift键的默认行为

在您的代码中添加以下代码段

LShift::
    Send, {} 
return 

此代码段将使第 2 点起作用,但会使左 Shift键对其他所有内容几乎无用。

编辑

方法3;等待x

添加KeyWait到脚本中会使其在执行代码之前等待一定的时间。其次,使用Lshift+;作为单独的热键组合将输出到:,而无需使用~返回。

`;::
KeyWait, `;, T0.2
    Send `;
return

LShift & `;::
    Send `:
return 

`; & x::
KeyWait, `;, T0.2 
if GetKeyState("LShift", "P")
    ...
else
    ...
return 
于 2020-04-12T16:51:36.060 回答