使用Autohotkey中的一个键禁用鼠标
我正在尝试做一个手掌检查程序(当我输入时将禁用鼠标的程序)。我想知道是否有一种方法来分配所有字母(大小写)和数字来触发一个代码来禁用300毫秒的鼠标(我写了5000来测试它),仍然能够使用字母和数字使用Autohotkey中的一个键禁用鼠标
下面是代码
lbutton::
rbutton::
WheelUp::
WheelDown::
suspend, on
a::
suspend, off
BlockInput, MouseMove
sleep 5000
suspend, on
BlockInput, MouseMoveoff
return
,你可以看到,我把信纸(一)触发的代码,但我不能用它+我将不得不一遍又一遍重复的代码超过50个字符
任何人都可以帮我解决这个问题吗?
- 我已经找了2小时的解决方案张贴这使得重复
请不要报告你可以尝试输入命令之前,将其设置为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
试试这个:
#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
这是一个很好的解决方案,应该标记为正确的答案。 – HaveSpacesuit
可以请你告诉我如何将代码看起来,因为我尝试使用命令**输入**,我不明白它是如何工作 – Mx2002
和MX2002,它有帮助吗?在哪里你可以将它与键盘记录技巧结合起来,在简单的循环中将所有字符定义为触发器? –