How to send an addition sequence after a series of input?

断了今生、忘了曾经 提交于 2019-12-11 10:05:29

问题


I want every time the series Ctrl GUpEnter and Ctrl GDownEnter are pressed, it will Send !wi afterward. Normal hotkeys work:

~^PgUp::
~^PgDn::Send !wi

But this doesn't work, although ~^g down enter isn't an invalid hotkey:

~^PgUp::
~^PgDn::
::~^g down enter::
::~^g up enter::Send !wi

Also, since I don't know many times Up and Down will be pressed before Enter, is there a way to make it skips the middle keys?


回答1:


Try:

~^PgUp::
~^PgDn::Send !wi
~^g::
    Input, key, V L1, {Enter}
    if (ErrorLevel == "EndKey:Enter")
        Send {Enter}!wi
return



回答2:


A simple solution is to set a boolean flag when ^g is pressed. Then check this flag when enter is pressed and fire !wi if it is set. This however require that the flag is reset - so if some other key can end the sequence, it must be also reset by those keys (see bottom section of code for examples).

await := 0

~^g::
    await := 1              ; set flag 
    tooltip %await%
return

~enter::
    if (await = 1) {
        await := 0          ; reset flag  
        sleep 300           ; safety pause 
        send !wi
        tooltip %await%
    }
return


; note: the 'await' flag must be reset if other
; key can end the sequence.
; here for example escape or mouse click

~esc::
    await := 0
    tooltip  %await%
return

~lbutton::
    await := 0
    tooltip %await%
return


来源:https://stackoverflow.com/questions/51165720/how-to-send-an-addition-sequence-after-a-series-of-input

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!