2013-04-09 177 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