0

I want to write a script for my dictionary application, so that when I hold the key j for a short time then it active the existed KMPlayer window and send space and maximize it( by sending middle button of the mouse) and if KMPlayer doesn't exist it sends Alt+Esc.

Here is my script :

#IfWinActive Oxford Advanced Learner's Dictionary
~$j::
KeyWait,j,T0.2
 If (ErrorLevel) 
 {
  If WinExist ("KMPlayer 64X")
  {
   WinActivate
   sleep,50
   SendInput,{space}
   sleep,50
   sendinput,{MButton}
  }
 else
 {
 SendInput,!{Esc} 
 }
}
return

But unfortunately when I hold the button in the search bar of my dictionary it just type something like

j jjjjjj j jjj j jjjjjj j jj

Rather than doing the functions. I don't know how to fix the script.

1 Answer 1

0

I found the answer by asking on autohotkey.com (this post ).

Here is the script by the user @mikeyww that solved my problem:

#IfWinActive Oxford Advanced Learner
$j::
KeyWait, j, T.2
If !ErrorLevel
{ Send j
  Return
}
If WinExist("ahk_exe KMPlayer64.exe")
{ WinActivate
  Send {Space}{Enter}
} Else Send !{Esc}
KeyWait, j
Return
#IfWinActive
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.