2013-04-09 101 views
0

我有一个AutoHotKey脚本,询问我是否要将我的Win键重新映射到Ctrl或取消它们的重新映射,从而使它们再次赢得键。取消在autohotkey现有的键重映射

但是我找不到取消重新映射的方法。如果我使用命令LWin::Lwin,则会收到错误消息,指出存在“重复密钥”。

我是新来的AutoHotKey,但我确实先搜索,所以请不要咬我的头,这是一个愚蠢的问题。 (这是一款Windows7-64的联想笔记本电脑)。

这里的脚本:

MsgBox, 4, , Remap CTRL for Desktop Keyboard? 
IfMsgBox, Yes 
    LWin::LCtrl 
    RWin::RCtrl 
    return 
; Otherwise, the user picked No 
; LWin::LWin 
; RWin::RWin 
; return 

回答

1

的各种方式。

创建一个热键关闭ahk,例如, ^!x::ExitApp = [Ctrl] + [Alt] + [x]

创建热键以禁用/启用所有热键。 f12::suspend

创建仅适用于特定应用程序的热键。

这里有所有的建议相结合。 正常情况下:LWin::LCtrlRWin::RCtrl是活动的,除非你按下F12。您可以在AHK_L中设置可在#If (Var = 1)中使用的变量,您可以在其中定义仅当该变量设置为1(真)时才起作用的热键。

SetTitleMatchMode, 2 ; Allow the use of a portion of the wintitle 
F12:: 
Suspend 
If A_IsSuspended 
    TrayTip, HotKeys, Off, 3, 0 
Else 
    TrayTip, HotKeys, On, 3, 0 
Return 

^!x::ExitApp 
LWin::LCtrl 
RWin::RCtrl 
F1::MsgBox, Normal Mode 

#IfWinActive, Window title 
    F1::MsgBox, Window X is active 
    F2::MsgBox, You pressed F2 inside Window x 
#IfWinActive 

Toggle := False 
F10::Toggle := !Toggle ; Turns Mouse button ON|Off 
#if Toggle ; ONLY worls in AHK_L 
    LButton::Return ; Disables Mouse button 
#if 
+0

如果你的脚本是逐字运行,它不初始化*切换* - 的'切换:从不执行= FALSE'线。在这种情况下没关系,因为如果它未初始化(空),'Toggle:=!Toggle'会将* Toggle *设置为true。但它似乎延续了误解。此外,'SetTitleMode'无效,当热键关闭时,F12热键显示“热键开启”,并且由于F12热键本身暂停(因为暂停不是热键的第一行),因此无法取消暂停。 – Lexikos 2015-03-02 11:23:14

+0

显然我可以编辑答案,所以我纠正了最糟糕的错误。还加了'''code'''标记。 – Lexikos 2015-03-02 11:27:53

+0

@Lexikos,感谢您的更正和补充。 – 2015-03-03 09:37:53

-1

这里是你可以在命令行驱动版本:

; Allow the script to be reloaded multiple times 
#SingleInstance force 

; Check the command line for input 
NumberOfParameters = %0% 

; If any command line param was passed then just unload the mappings 
If (NumberOfParameters > 0) 
{ 
    MsgBox Command line parameter was passed, unloading... 
    ExitApp 
} 
Else 
{ 
    ; Let's ask the user what they want to do 
    MsgBox, 4, , Remap CTRL for Desktop Keyboard? 

    IfMsgBox, Yes 
    { 
    ; If yes, then remap 
    MsgBox Keys have been mapped. 
    } 
    Else 
    { 
    ; If no, then unload 
    MsgBox Unloading mapping. 
    ExitApp 
    } 
} 

; Keys will be mapped so long as the script remains resident 
LWin::LCtrl 
RWin::RCtrl 
+0

您无法有条件地重新映射密钥。无论MsgBox的结果如何,甚至MsgBox是否显示,重新映射'LWin :: LCtrl'和'RWin :: RCtrl'都将在启动脚本时立即生效。 – Lexikos 2015-03-02 11:17:26

+0

我调整了映射的位置以更好地反映真实的逻辑。只要脚本是常驻的,映射将保持原样。 – Chris 2016-03-05 00:05:01