最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

autohotkey - How do I break a while-loop with setTimer? - Stack Overflow

programmeradmin3浏览0评论

B needs to run 1000ms after the most recent press of A (if B is pressed 100ms after A then B must first sleep 900ms). It should also run normally if no instance of A is detected in the last 1000ms of pressing B. How do I achieve this using AutoHotkey v2?

a_var:=false

a::{
    global a_var
    if a_var=false{
        a_var:=true
        setTimer a_timer, -1000
    }
}

a_timer(){
    global a_var:=false
}

b::{
    global a_var
    while a_var{
        sleep 10 ;setTimer stops working, loop turns infinite
    }
    msgbox "success" ;needs to run 1000 ms after the most recent instance of a is pressed
}

setTimer stops running once it enters the while loop.

发布评论

评论列表(0)

  1. 暂无评论