[auto hot key]部分实现_合集

一键启用,一键关闭

实现1

;创建2个线程
#maxThreadsPerHotkey, 2
setKeyDelay, 50, 50
setMouseDelay, 50
banana:=0
Down::
; banana:=!banana .... This assigns banana to the value of NOT (!) banana. so lets
; say banana starts out FALSE (0). you then turn banana to NOT FALSE. which is
; TRUE (1). so now banana is set to TRUE. and then lets say you toggle it again.
; you set banana to NOT TRUE, which is FALSE. banana is now set to FALSE.
; .... 1 is true, 0 is false. ! is NOT.
banana:=!banana

while (banana=1)
{
    ;执行
}
return

实现2

v_Enable=0
Up::
{
    v_Enable:=!v_Enable
    If(v_Enable=0)
    {
        ;关闭
    }
    else
    {
        ;执行
    }
}
return

实现3

#MaxThreadsPerHotkey 2

IniWrite, 0, config.ini, section_1, _loop

[Key]::
    IniRead, _loop, config.ini, section_1, _loop
    _loop := !_loop
    IniWrite, %_loop%, config.ini, section_1, _loop
    Loop, 
    {
        IniRead, _loop, config.ini, section_1, _loop
        if _loop = 0
            break
        [执行内容]
    }
Return

单键双击触发

; 双击Ctrl,切换窗口
~LCtrl::
KeyWait Ctrl
if (A_PriorHotkey=A_ThisHotkey && A_TimeSincePriorHotkey < 400 && A_TimeSincePriorHotkey > 100)
[执行内容]
return

通过单键的三种触发方式实现一键剪切复制粘贴

; F8触发
F8::
    KeyWait,F8,T0.4
    if not(ErrorLevel){
        ; 双击剪切
        if (A_PriorHotkey=A_ThisHotkey && A_TimeSincePriorHotkey < 400 && A_TimeSincePriorHotkey > 100)
            Send, ^{x}
        ; 单击复制
        Else
            Send, ^{c}
    }else{
        ; 长按粘贴
        Send, ^{v}
        KeyWait,F8
    }
return

长按触发

; 长按空格触发连点
#NoEnv
#SingleInstance, Force
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%

$Space::
    while GetKeyState("Space", "P")
    {
        Send {Space}
        sleep 1000
    }
return
posted @ 2022-12-25 11:48  DwightValentine  阅读(28)  评论(0)    收藏  举报