简体   繁体   中英

Trying to fix autohotkey code which do a function when I press a key twice

I want to write a code in aoutohotkey to do this: If the my dictionary application is active, then when I press the key " j " it clicks on a specific coordinate (in this coordinate there is an open Kmplayer window ) then send Enter and then send Space. here is my code:

#IfWinActive Oxford Advanced Learner's Dictionary
j::
    If (A_ThisHotkey = A_PriorHotkey) && (A_TimeSincePriorHotkey < 500)
        Click, 1149,305
        sleep,100
        send,{Enter}
        sleep,100
        send,{space}
return

But it doesn't work perfectly. sometimes it works but most of the times when I press the key " j " twice, it just send space and enter.

Some details:

  1. I'm not much experienced at working with aoutohotkey I just found a double tap pressing code on reddit and used it.

  2. For swiping window to the open Kmplayer I didn't find a better solution than just Click, 1149,305 because unlike many applications, the key combination Alt+Esc doesn't swap windows for Oxford dictionary app. (maybe this clicking cause the problem)

If your if-statement's body has more than one line, you need { } s.

#IfWinActive Oxford Advanced Learner's Dictionary
j::
    if (A_ThisHotkey = A_PriorHotkey && A_TimeSincePriorHotkey < 500)
    {
        Click, 1149,305
        sleep,100
        send,{Enter}
        sleep,100
        send,{space}
    }
return

Not sure if this is your only problem though.
I wasn't able to make sense of what your second detail was trying to say.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM