2017-10-14 557 views
2

我正在嘗試做一個手掌檢查程序(當我輸入時將禁用鼠標的程序)。我想知道是否有一種方法來分配所有字母(大小寫)和數字來觸發一個代碼來禁用300毫秒的鼠標(我寫了5000來測試它),仍然能夠使用字母和數字使用Autohotkey中的一個鍵禁用鼠標

下面是代碼

lbutton:: 
rbutton:: 
WheelUp:: 
WheelDown:: 
suspend, on 

a:: 
suspend, off 
BlockInput, MouseMove 
sleep 5000 
suspend, on 
BlockInput, MouseMoveoff 
return 

,你可以看到,我把信紙(一)觸發的代碼,但我不能用它+我將不得不一遍又一遍重複的代碼超過50個字符

任何人都可以幫我解決這個問題嗎?

  • 我已經找了2小時的解決方案張貼這使得重複

回答

0

請不要報告你可以嘗試輸入命令之前,將其設置爲1米字符的長度和可見。 您可能需要拆分觸發器部分和暫停/休眠部分,因爲我預計觸發器部分在由於您的睡眠命令未完成早期觸發事件時不能再次觸發。我建議你看看settimer命令來替換睡眠命令。對不起,我無法幫助你處理任何代碼,我正在用手機寫這篇文章,並提出建議。

UPDATE:

經過輸入命令,沒有工作,我所期望的方式。我建議你看看自動定義你的觸發鍵,就像他們在這裏:https://autohotkey.com/board/topic/30294-simple-key-stroke-recorder/page-2

我創建了一些修補程序代碼供您在這裏玩。它目前僅在字母q上觸發,但在擊鍵記錄器中的循環中,您應該能夠實現這一點。

SoundBeep, 1000,100 ; Just to check 
BlockMouse := 0 
return 

$q:: ; $ prevents the next command from triggering this again 
    SendInput, q 
    BlockMouse := 1 
    SetTimer, UnBlockMouse, 5000 ; Run UnBlockMouse after 500 ms 
Return 

UnBlockMouse: 
    SetTimer, UnBlockMouse, off ; Turn timer off 
    SoundBeep, 1000,100 ; Just to check 
    BlockMouse := 0 
Return 

#If (BlockMouse) ; If statement controls the behaviour based on the status of the variable BlockMouse 
    lbutton:: ; Disable button when BlockMouse variable is set to 1 
    rbutton:: ; Disable button when BlockMouse variable is set to 1 
    WheelUp:: ; Disable button when BlockMouse variable is set to 1 
    WheelDown:: ; Disable button when BlockMouse variable is set to 1 
#If 
+1

可以請你告訴我如何將代碼看起來,因爲我嘗試使用命令**輸入**,我不明白它是如何工作 – Mx2002

+0

和MX2002,它有幫助嗎?在哪裏你可以將它與鍵盤記錄技巧結合起來,在簡單的循環中將所有字符定義爲觸發器? –

1

試試這個:

#NoEnv 
#SingleInstance Force 
#InstallkeybdHook 
#InstallMouseHook 
#UseHook 

keys:=["a","b","c","d","1","2","3","4"] ; .... 
for each, key in keys 
{ 
    hotkey,%key%, BlockMouse, on 
    hotkey,+%key%, BlockMouse, on 
} 
return 

BlockMouse: 
    ; suspend, off 
    Mouse_Blocked := true 
    BlockInput, MouseMove 
    Send %A_ThisHotkey% 
    SetTimer, UnBlockMouse, -300 
return 

UnBlockMouse: 
    ; suspend, on 
    BlockInput, MouseMoveoff 
    Mouse_Blocked := false 
return 

#If (Mouse_Blocked) 

    lbutton:: 
    rbutton:: 
    WheelUp:: 
    WheelDown:: 
    ; suspend, on 
    return 

#If 
+0

這是一個很好的解決方案,應該標記爲正確的答案。 – HaveSpacesuit