chenxu Posted July 18, 2008 Posted July 18, 2008 We can define a hot key in our scripts by HotKeySet(), but, it is a global hot key, I now need to make a private one, which is only work when the AutoIt GUI is activated? How to do this?
JFee Posted July 18, 2008 Posted July 18, 2008 In your GUI's while loop make a condition: Global $hotKeyIsSet ;Create $GUI here While 1 If WinActive("Title of window") AND $hotKeyIsSet = 0 Then HotkeySet("^+Q", "hotkeyfunc") $hotKeyIsSet = 1 EndIf If Not WinActive("Title of window") AND $hotKeyIsSet = Then HotkeySet("^+Q") $hotKeyIsSet = 0 EndIf WEnd Regards,Josh
ProgAndy Posted July 18, 2008 Posted July 18, 2008 (edited) Use GUISetAccelerators muttley Or do the Check in WM_ACTIVATEAPP 0x001C Edited July 18, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Xand3r Posted July 18, 2008 Posted July 18, 2008 HotKetSet("key" , "func") Func func() HotKeySet("key") Send("key") If WinActive($yourgui) then ;action EndIf HotKetSet("key" , "func") EndFunc Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
JFee Posted July 18, 2008 Posted July 18, 2008 HotKetSet("key" , "func") Func func() HotKeySet("key") Send("key") If WinActive($yourgui) then ;action EndIf HotKetSet("key" , "func") EndFunc When are you suggesting calling that function? If you do it every time it loops through the while, then you are doing a ton of redundant hotkeysets. Also why the Send? (Not being critical, just curious) That also seems to be redundant because you are clearing the hotkey, then resetting it if the window is open instead of setting the hotkey once when the window becomes active, and clearing it once when it isn't. Regards,Josh
NELyon Posted July 19, 2008 Posted July 19, 2008 Why is everyone putting too much thought into this? $hGUI = GUICreate("Test", 500, 500) $hDummy = GUICtrlCreateDummy() $hDummy2 = GUICtrlCreateDummy() Dim $azAccelerators[2][2] = [["^e", $hDummy],["^y", $hDummy2]] GUISetAccelerators($azAccelerators) GUISetState() While 1 Switch GUIGetMsg() Case - 3, $hDummy Exit Case $hDummy2 MsgBox(0, "Hey", "Sup") EndSwitch WEnd Ctrl+E Exits, Ctrl+Y Greets you.
chenxu Posted July 19, 2008 Author Posted July 19, 2008 Why is everyone putting too much thought into this? $hGUI = GUICreate("Test", 500, 500) $hDummy = GUICtrlCreateDummy() $hDummy2 = GUICtrlCreateDummy() Dim $azAccelerators[2][2] = [["^e", $hDummy],["^y", $hDummy2]] GUISetAccelerators($azAccelerators) GUISetState() While 1 Switch GUIGetMsg() Case - 3, $hDummy Exit Case $hDummy2 MsgBox(0, "Hey", "Sup") EndSwitch WEnd Ctrl+E Exits, Ctrl+Y Greets you. My AutoIt claim the error: ERROR: GUISetAccelerators(): undefined function. Why?
NELyon Posted July 19, 2008 Posted July 19, 2008 My AutoIt claim the error:ERROR: GUISetAccelerators(): undefined function.Why?You must have an old version. Update.
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