[英]Remapping ctrl+win
The first script works, but the second that should remap ctrl+win does not. 第一个脚本有效,但是第二个脚本应重新映射ctrl + win。 Why is that?
这是为什么?
ctrl::Send {ALT down}{SHIFT down}{SHIFT up}{ALT up}
^lwin::Send {ALT down}{SHIFT down}{SHIFT up}{ALT up}
This works fine for me: 这对我来说很好:
Ctrl & LWin:: msgbox hi
I think the keys Alt
and Shift
are triggering while you still have not released the keys Ctrl
and Win
, therefore it's working all the keys at the same time: Alt
, Shift
, Ctrl
, Win
. 我认为,在您尚未释放
Ctrl
和Win
键的同时,会触发Alt
和Shift
键,因此它可以同时使用所有键: Alt
, Shift
, Ctrl
和Win
。
Because you just should check if the keys are not pressed at that time. 因为您只应检查当时是否未按下键。
To do this, we'll use the function GetKeyState()
. 为此,我们将使用
GetKeyState()
函数。
Ctrl & LWin Up::
while(!GetKeyState("Ctrl", "P"))
continue
send {ALT down}{SHIFT down}
sleep 40
send {SHIFT up}{ALT up}
; or use “Send {ALT down}{SHIFT down}{SHIFT up}{ALT up}”
; if it works for you
return
Because they are both modifier keys. 因为它们都是修饰键。
Try this instead: 尝试以下方法:
Ctrl & LWin::
Edit : 编辑 :
Then, try using SetKeyDelay and possibly SendEvent , too. 然后,尝试使用SetKeyDelay以及可能的SendEvent 。
Wait, I found this working just now: 等等,我发现此功能现在可以正常工作:
Ctrl & LWin::Send {ALT down}{SHIFT down}
Ctrl & LWin Up::Send {SHIFT up}{ALT up}
Of course, being modifier keys, they need special treatment. 当然,作为修饰键,它们需要特殊对待。
Edit 2 : 编辑2 :
My shift+alt combination is for changing the keyboard language
我的shift + alt组合用于更改键盘语言
Why didn't you say so earlier? 你怎么没这么早说 : ) I thought you were just replacing modifier combinations.
:)我以为您只是要替换修饰符组合。
It's much simpler, then. 那么,这要简单得多。
This should work: 这应该工作:
/*
cf. https://www.autohotkey.com/docs/commands/PostMessage.htm
cf. https://msdn.microsoft.com/en-us/library/windows/desktop/ms632630(v=vs.85).aspx
0x50: WM_INPUTLANGCHANGEREQUEST
0x02: INPUTLANGCHANGE_FORWARD
*/
Ctrl & LWin::PostMessage, 0x50, 2,,, A
Alternatively: 或者:
Ctrl & LWin::
KeyWait Ctrl
KeyWait LWin
PostMessage, 0x50, 2,,, A
Return
The above two pieces of code have pros and cons. 上面的两段代码各有利弊。 Experiment and choose what suits your needs.
试用并选择适合您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.