Reputation: 53
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:
I'm not much experienced at working with aoutohotkey I just found a double tap pressing code on reddit and used it.
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)
Upvotes: 0
Views: 144
Reputation: 6489
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.
Upvotes: 2