1

I'm currently the following code to launch the Program SpeedCrunch when pressing Win+C

#c::
IfWinExist, SpeedCrunch
{
    WinActivate
}
IfWinNotExist, SpeedCrunch
{
    Run, speedcrunch.exe, C:\Program Files (x86)\SpeedCrunch, UseErrorLevel
    WinActivate
}
return

Activating the window when the program is running works perfectly. When the program is not running, however, the program is launched minimized, and not activated, meaning that it's necessary to press Win+C two times to launch and bring into focus Speedcrunch, even though I have "WinActivate" in the launch command. Why doesn't it work?

  • Should work. Try it in a stand-alone script and run the script as administrator. – user3419297 Mar 16 at 19:39
0

Your test conditions are not precise enough.

I suggest the following formulation:

#c::
IfWinExist, ahk_exe SpeedCrunch.exe
{
    WinActivate
}
IfWinNotExist, ahk_exe SpeedCrunch.exe
{
    Run, C:\Program Files (x86)\SpeedCrunch, , UseErrorLevel, process_id
    WinWait, ahk_pid %process_id%
    WinActivate, ahk_pid %process_id%
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.