Reputation: 3157
Sorry for my bad English.
#IfWinActive, ahk_class PX_WINDOW_CLASS
~^s::
KeyWait, s, U
WinWait, This is an unregistered copy ahk_class #32770,, 500
IfWinExist, This is an unregistered copy ahk_class #32770
WinKill, This is an unregistered copy ahk_class #32770
Return
My problem is sometimes when i press this hotkey (ctrl + s) it makes all autohotkey script hotkeys and autohotkey's tray menu shortcuts inactive (not paused or suspended, just hotkeys don't work). Why is that? How to fix this?
Upvotes: 1
Views: 316
Reputation: 7953
You provide very little information to go on... I could imagine that you might hit Ctrls e.g. to save a file while in PX_WINDOW_CLASS. If no window is activated at that time that matches your winwait, nothing will happen and AutoHotKey will sit and wait and wait...
Suggestion: shorten the timeout in WinWait, add an exit and remove superfluous lines
SetTitleMatchMode=2 ; Find the string "This is an unregistered copy" anywhere in your Title
#IfWinActive, ahk_class PX_WINDOW_CLASS
~^s::
KeyWait, s, U ; Why do you have this in there? are you hanging on your s key for more than 2 seconds?
WinWait, This is an unregistered copy,,2 ; Wait for two seconds (or a bit longer..)
if ErrorLevel ; If timeout of WinWait
Return
WinKill ; uses ID found in WinWait
Return
#IfWinActive
or shorter...
SetTitleMatchMode=2
#IfWinActive, ahk_class PX_WINDOW_CLASS
~^s::
WinWait, This is an unregistered copy,,2
if not ErrorLevel
WinKill ; uses ID found in WinWait
Return
#IfWinActive
Upvotes: 0