abdulrahmanok Posted November 18, 2019 Posted November 18, 2019 (edited) Hi all.. My application Idea is to check for window, If the windows is exist then set hotkeyset(control+c) , and if not then unregister that hotkey. but whatever I tried It keeps stuck with registered hotkey, that's what I have tried: #Include <WinAPI.au3> While 1 $GetActive= _WinAPI_GetClassName(WinGetHandle("[ACTIVE]")); Get window Class Select Case $GetActive= 'ThunderRT6MDIForm' ConsoleWrite($GetActive &@crlf) HotKeySet("^c", "_Func") Case Else ConsoleWrite('Else Print '& $GetActive &@crlf) HotKeySet("^c") EndSelect Sleep(500) WEnd Func _Func() MsgBox(0,0,0) EndFunc #Include <WinAPI.au3> While 1 $GetActive= _WinAPI_GetClassName(WinGetHandle("[ACTIVE]")); Get window Class If $GetActive= 'ThunderRT6MDIForm' Then ConsoleWrite($GetActive&@crlf) HotKeySet("^c", "_Func") Else ConsoleWrite('Else Print '& $GetActive&@crlf) HotKeySet("^c") EndIf Sleep(500) WEnd Func _Func() MsgBox(0,0,0) EndFunc Edited November 19, 2019 by abdulrahmanok
Guest Posted November 18, 2019 Posted November 18, 2019 2 hours ago, abdulrahmanok said: but whatever I tried It keeps stuck with registered hotkey For me this works : #Include <WinAPI.au3> HotKeySet("{ESC}", "_Exit") While True $GetActive= _WinAPI_GetClassName(WinGetHandle("[ACTIVE]")); Get window Class If $GetActive= 'Notepad' Then ConsoleWrite($GetActive & @CRLF) HotKeySet("^c", "_Func") ; (control+c) ;~ HotKeySet("{PAUSE}", "_Func") Else ConsoleWrite('Else : '& $GetActive & @CRLF) HotKeySet("^c") ;~ HotKeySet("{PAUSE}", "_Func") EndIf Sleep(500) WEnd Func _Func() MsgBox(0,0,0) EndFunc Func _Exit() ConsoleWrite("! EXIT" & @CRLF) Exit EndFunc
abdulrahmanok Posted November 18, 2019 Author Posted November 18, 2019 (edited) 4 hours ago, Musashi said: For me this works : #Include <WinAPI.au3> HotKeySet("{ESC}", "_Exit") While True $GetActive= _WinAPI_GetClassName(WinGetHandle("[ACTIVE]")); Get window Class If $GetActive= 'Notepad' Then ConsoleWrite($GetActive & @CRLF) HotKeySet("^c", "_Func") ; (control+c) ;~ HotKeySet("{PAUSE}", "_Func") Else ConsoleWrite('Else : '& $GetActive & @CRLF) HotKeySet("^c") ;~ HotKeySet("{PAUSE}", "_Func") EndIf Sleep(500) WEnd Func _Func() MsgBox(0,0,0) EndFunc Func _Exit() ConsoleWrite("! EXIT" & @CRLF) Exit EndFunc Thanks for response, after test I found that console write is reading active window correct, but it still Ignore code: HotKeySet("^c", "_Func") so I don't receive any MsgBox Its working now ... very strange anyway, thanks for help 😊 Edited November 18, 2019 by abdulrahmanok
abdulrahmanok Posted November 19, 2019 Author Posted November 19, 2019 I have found the issue... it was caused because of Language layout , because the target application is in (Arabic) so the solution was very simple: I Only changed this: HotKeySet("^c", "_Func") ; (control+c) HotKeySet("^c") To be like this: HotKeySet("^ؤ", "_Func") ; (control+c) HotKeySet("^ؤ") So this is the final code: #Include <WinAPI.au3> HotKeySet("{ESC}", "_Exit") While True $GetActive= _WinAPI_GetClassName(WinGetHandle("[ACTIVE]")); Get window Class If $GetActive= 'ThunderRT6MDIForm' Then ConsoleWrite($GetActive & @CRLF) HotKeySet("^ؤ", "_Func") ; (control+c) ;~ HotKeySet("{PAUSE}", "_Func") Else ConsoleWrite('Else : '& $GetActive & @CRLF) HotKeySet("^ؤ") ;~ HotKeySet("{PAUSE}", "_Func") EndIf Sleep(500) WEnd Func _Func() MsgBox(0,0,0) EndFunc Func _Exit() ConsoleWrite("! EXIT" & @CRLF) Exit EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now