[英]; as a new modifier key
I want ;
我要;
to be a new modifier key.成为一个新的修饰键。 The following works almost perfectly.以下工作几乎完美。
`;::
if GetKeyState("LShift", "P")
Send `:
else
Send `;
return
`; & x::
if GetKeyState("LShift", "P")
...
else
...
return
Only point 2. of the following wishlist does not work.以下愿望清单中只有第 2 点不起作用。 Does anybody know how to fix this code?有人知道如何修复此代码吗?
;
to be ;
成为;
when pressed alone单独按下时shift;
to be :
when pressed alone to be :
当单独按下时;
with x
to be the second ...
x
是第二个...
shift
with ;
shift
;
with x
to be the first ...
x
是第一个...
In my opinion, there are two possible ways to make point 2 work.在我看来,有两种可能的方法可以使第 2 点起作用。
Method 1: keeps the Left Shift key's default behavior方法一:保持左Shift键的默认行为
shift + ;移位+ ; results in : colon key being pressed.结果:冒号键被按下。 You can get point 2 to work by adding tilde "~" key before `;您可以通过在`;之前添加波浪号“~”键来使第 2 点起作用and removing并删除
else
send `;
With ~ you can keep the key's default behavior.使用 ~ 您可以保持密钥的默认行为。 The new script will look something like this新脚本看起来像这样
~`;::
if GetKeyState("LShift", "P")
Send `:
return
`; & x::
if GetKeyState("LShift", "P")
...
else
...
return
By using this method script will be able to send : with shift+;通过使用此方法脚本将能够发送: with shift+; . .
Method 2: removing the Left Shift key's default behavior方法二:去掉左Shift键的默认行为
Add the following snippet in your code在您的代码中添加以下代码段
LShift::
Send, {}
return
This snippet will make the point 2 work but will render Left Shift key pretty much useless for everything else.此代码段将使第 2 点起作用,但会使左 Shift键对其他所有内容几乎无用。
EDIT编辑
Method 3 : Making ;
方法三:制作;
wait for x
等待x
Adding KeyWait
into the script will make it wait a certain amount of time before executing the code.将KeyWait
添加到脚本中会使其在执行代码之前等待一定的时间。 Secondly using Lshift
+ ;
其次使用Lshift
+ ;
as an individual hotkey combination will output to :
, removing the need for using ~
in return.作为单独的热键组合,将 output 转换为:
,无需使用~
作为回报。
`;::
KeyWait, `;, T0.2
Send `;
return
LShift & `;::
Send `:
return
`; & x::
KeyWait, `;, T0.2
if GetKeyState("LShift", "P")
...
else
...
return
The following works perfectly, but is ugly code due to code duplication.以下工作完美,但由于代码重复而代码难看。 Maybe cleaner code is possible.也许更简洁的代码是可能的。
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
The key ;
关键;
now works as modifier key whenever it is used in a combination with x
(without delay) or if it is pressed more than half a second.现在,只要它与x
组合使用(无延迟)或按下超过半秒,就可以用作修饰键。 The delay is not neccesary and can be removed;延迟不是必须的,可以消除; it's just there prevent misinterpretation of an accidental modifier keypress as a ;
它只是在那里防止将意外的修饰键误解为;
. . The colon :
works correctly too.冒号:
也可以正常工作。
#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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.