GUI Req: Local hotkeys
#21
Posted 27 March 2005 - 06:31 PM
#22
Posted 01 April 2005 - 01:22 AM
I extended the function HotKeySet a little bit to this:
HotKeySet( "key" [, "function" [, WindowHandle Or WindowTitle [, WindowText [,MustBeActive]]]] )
So you could it use like:
#include <GUIConstants.au3> Dim $cn = 0 $gui = GUICreate("Test") $label = GUICtrlCreateLabel("",10,10,250,20) $label2 = GUICtrlCreateLabel("info",10,50,250,20) GUISetState() ; HotKeySet("key" [, "function" [, WindowHandle Or WindowTitle [, WindowText [,MustBeActive]]]] ) ; ; HotKeySet("^s", "HotkeyCheck", $gui, "sssss", 1) -> OK, cause of special GUI-handle ; HotKeySet("^s", "HotkeyCheck", $gui) -> OK ; HotKeySet("^s", "HotkeyCheck", "Test, "",0) -> OK ; HotKeySet("^s", "HotkeyCheck", "Test, "sssss") -> ERROR ; HotKeySet("^s","HotkeyCheck",$gui,"",1) While 1 $msg = GUIGetMsg() If $msg = -3 Then ExitLoop WEnd GUIDelete() Exit Func HotkeyCheck() $cn = $cn + 1 GUICtrlSetData($label,"Script " & $cn & " times saved.") EndFunc
So what do you think about this?
So long...
Holger
#23
Posted 01 April 2005 - 03:31 AM
#24
Posted 01 April 2005 - 05:21 AM
I don't see what passing an argument does that using a global variable can't do just as well (That's not condoning the use of global variables, however).Sounds great, any chance we can pass arguments to the Function too?
What I think would be more useful is if the callback function could optionally be passed the hotkey combination that was pressed. What I mean by optional is, if the callback function has a signature like this:
Func Callback($variable) EndFunc
Then the hotkey pressed will be passed in and retrievable through $variable. If the signature is in the current form of:
Func Callback() EndFunc
Then no parameter can be passed so none is passed but the callback is still executed.
I do not like the idea of adding macro's to store this kind of information (A @HotKeySet macro or something similar). I think this sort of information should be passed to the function. There's tons of stuff I would like to see passed to GUI OnEvent callback functions, too, so this has more applications than just this one function.
So what I really am asking for is the capability for callback functions to be passed parameters containing useful (and logical) data for the event they are assigned to.
#25
Posted 01 April 2005 - 06:23 AM
AutoIt gui intuitions would grow in future and one window could easely have three or four menu rows and some controls like 10 or 20 and several child windows also with controls - it's just not posible today to add keyboard accelerator support just to a few child windows without a lot of roundups...
Holger I think that your solution is pointing in the right direction...
Kåre
Edited by kjactive, 01 April 2005 - 06:32 AM.
#26
Posted 01 April 2005 - 12:19 PM
So in my example it would passed: "Test" if I use the declaration with i.e.:
HotKeySet("^s","HotkeyCheck","Test","",1)
So I have to put it then in a separate function.
Instead of going direct to the first the line in the user function we could call the normal "user function parser" you know.
So long...
Holger
#27
Posted 07 May 2005 - 12:37 AM
In the interim, or perhaps even on a permanent basis... I have created a set of UDFs. I've attached a .zip that contains the UDF's, and some rather sketchy documentation (sorry, I'm just not that good at it). Here's some example code:
#include <GUIConstants.au3> #include 'HotKeySetLocal.au3' Run('notepad.exe') WinWait('Untitled - Notepad') $hwnd = WinGetHandle('Untitled - Notepad') _HotKeySetLocal($hwnd, '^1', 'Notepad') $gui = GuiCreate('press ctrl+t') $button = GuiCtrlCreateButton('toggle GUI hotkey', 20, 20, 100, 30) GuiSetState() $hk_GUIHotKey = _HotKeySetLocal($gui, '^t', 'ControlT') $i_HKOn = 1 While 1 _HotKeyCheckLocal() $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit If $msg = $button Then If $i_HKOn Then tooltip('hot key off') _HotKeyToggleLocal($hk_GUIHotKey, 0) $i_HKOn = 0 Else tooltip('hot key on') _HotKeyToggleLocal($hk_GUIHotKey, 1) $i_HKOn = 1 EndIf EndIf WEnd Func Notepad() Send('This is Notepad. You pressed Ctrl+1.', 1) EndFunc Func ControlT() MsgBox(0, 'Message', 'You pressed Ctrl+T in the GUI window!') EndFunc
What do you think?
Attached Files
Edited by Saunders, 22 August 2005 - 05:02 AM.
#28
Posted 07 May 2005 - 01:38 AM
It's great that you made the UDFs for us. Thank you for that.Okay, so nobody's been to this thread in a while, but I'm resurrecting it anyway. We (Holger that is) have already half-solved the problem of sending parameters with hotkeys, with the @HotKeyPressed macro, but GUI/Window specific hotkeys still haven't been implemented (in beta or otherwise).
In the interim, or perhaps even on a permanent basis... I have created a set of UDFs. I've attached a .zip that contains the UDF's, and some rather sketchy documentation (sorry, I'm just not that good at it). Here's some example code:
[-code-]
What do you think?
Anyways, I hope you can make this work without UDFs.
Edited by SlimShady, 07 May 2005 - 01:39 AM.
#29
Posted 09 May 2005 - 12:43 AM
Yes, I can't wait until there is built-in support for these kinds of keys.It's great that you made the UDFs for us. Thank you for that.
Anyways, I hope you can make this work without UDFs.
#30
Posted 21 August 2005 - 11:09 PM
Sorry for the thread revivification, but I was needing this ability again and the workarounds are awfully slow. Has there been any progress in this area? Is it really very difficult to add these local hotkeys?
#31
Posted 21 August 2005 - 11:58 PM
LOL.
#34
Posted 22 August 2005 - 04:57 AM
Holger's post: Apr 1 2005, 04:19 AM
w0uter's reference: Apr 1 2005, 03:22 AM
I could see one number being off, but all three?
#35
Posted 22 August 2005 - 05:07 AM
Edit: So Saunders, you want the post showing up on your system as Mar 31 2005, 05:22 PM according to your profile.
Edited by LxP, 22 August 2005 - 05:12 AM.
#36
Posted 22 August 2005 - 05:27 AM
Wow, I managed to totally derail this thread with all my confusion.
Edit: Even so, I'm still confused as to why.
Edited by Saunders, 22 August 2005 - 05:27 AM.
#37
Posted 22 August 2005 - 12:58 PM
#38
Posted 23 August 2005 - 05:11 PM
I still really want this to come through. Hoping SOMEBODY out there on the developer side of things is looking at this and thinking, "Hey now.. that's an idea."
I'm actually half tempted to start a new topic, but I don't want to be too pushy.
*Edit: Views: 1219 (Just keeping track to see if anybody IS actually checking this thread)
Edited by Saunders, 24 August 2005 - 03:36 AM.
#39
Posted 24 August 2005 - 07:47 AM
I started something but since there was an UDF I didn't do anything on this.
I also didn't 'implement' to use the same HotKey on different windows.
Oh, I started a lot of things but nothing is finished
When I have time again I will take a look the next days what I did in march and tell you again how it goes on.
Regards
Holger
#40
Posted 29 November 2005 - 04:31 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





