I am struggling with the WinActivate and WinWaitActive functions for two days and cannot find out why they don't work.
Here is my script.
Code: Select all
^!o::
#WinActivateForce ; This directive shows no effect.
; I only mentioned it here to show to you that I am aware of it.
if !WinExist("ahk_exe notepad.exe") {
; I tried it also with cmd.exe and some other simple applications.
; I get same results when use window titles instead of file names.
MsgBox Window does not exist. ; This works.
return
} else {
MsgBox Window exists. ; This works too.
}
if !WinActive("ahk_exe notepad.exe") {
MsgBox AHK is able to regonize whether a window is active or not. ; This works.
WinActivate, "ahk_exe notepad.exe" ; This doesn't work.
} else {
MsgBox Window already active. ; This works.
}
WinWaitActive, "ahk_exe notepad.exe", , 5 ; This doesn't work.
; If I omit the timeout, the script hangs here.
if Errorlevel
; It ends allways with a timeout even if the window has been activated manually before timeout.
MsgBox Timeout
else
MsgBox Success
return
It doesn't work neither on Win7 nor on Win10. AHK version is 1.1.30.00.
Thanks for your help!