ratacat Posted August 8, 2007 Posted August 8, 2007 Does anyone have any / know of any code that shows a good system for letting a user define their own hotkeys. It seems like it should be easy just tunneling userinput to hotkeyset(), but I have not yet found any elegant methods of doing it and was hoping that someone else already had. much thanks! Jared
DW1 Posted August 8, 2007 Posted August 8, 2007 (edited) This is very simple, but does the basics of what you want: #include <GuiConstants.au3> GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Input_1 = GuiCtrlCreateInput("Input1", 70, 60, 180, 30) $Button_2 = GuiCtrlCreateButton("Button2", 90, 110, 150, 50) $old = "^+q" HotKeySet( $old, "leaveme" ) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else If $msg = $Button_2 Then HotKeySet( $old ) HotKeySet( GUICtrlRead($Input_1), "leaveme") EndIf EndSelect WEnd Exit Func leaveme() MsgBox(0,"test", "GoodBye") Exit EndFunc Does that help? EDIT: Type the hotkey into the edit, and hit the button to set it. The hotkey set should now be the hotkey for exit. I call HotKeySet( $old ) before reassigning so that the old hotkey is removed. Edited August 8, 2007 by danwilli AutoIt3 Online Help
ratacat Posted August 8, 2007 Author Posted August 8, 2007 (edited) Thankyou Danwilli, that helps me think a bit clearer now. It works very well for using alphanumeric hotkeys. I'm going to try and sort of reverse that. IE. Wait for user keypresses, then record to a hotkey, so that we could utilize Function keys and SHIFT/CTRL etc. Perhaps _IsPressed may be useful. But as far as I can tell it requires you to define precisely which key you are watching for, that would be overkill because we would need an if statement for every single key and then some(for combinations) to record what the user wants. Do you know of any functions perhaps that "watch" all keys, and return a value/values based on which may be pressed? Jared Edited August 8, 2007 by xeonz16
DW1 Posted August 8, 2007 Posted August 8, 2007 That would be nice, but if it is "so that we could utilize Function keys and SHIFT/CTRL etc." then you could just add a couple checkboxes to the code I gave you which could add a "^" to the begining if Ctrl is selected, + for Shift, and ! for alt. Otherwise the method mentioned above would best be done with _IsPressed (In my opinion) AutoIt3 Online Help
ratacat Posted August 8, 2007 Author Posted August 8, 2007 good point, perhaps I am trying to make it too concentric. I think using a combination of the checkbox/alphanumeric method, and then perhaps _ispressed for the Function keys might get everything covered. Thanks again for your help. Jared
Zedna Posted August 8, 2007 Posted August 8, 2007 (edited) There are standard Hot Key Controls in Windows but they are not implemetnted in Autoit.Maybe you can use them indirectly by calling it's API somehow (CreateWindowEx,HKM_SETRULES,HKM_SETHOTKEY,HKM_GETHOTKEY,WM_SETHOTKEY,...) Edited August 8, 2007 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search
ratacat Posted August 9, 2007 Author Posted August 9, 2007 thanks Zedna, I will look into that. I appreciate everyone's input, I'll post when I come up with something nice.
Zedna Posted August 9, 2007 Posted August 9, 2007 thanks Zedna, I will look into that. I appreciate everyone's input, I'll post when I come up with something nice.I searched forum and found this.It's exactly what I meant. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search
ratacat Posted August 10, 2007 Author Posted August 10, 2007 Any ideas why I would get a "Cannot redeclare a constant" error message, trying to run this code. on line 7 ->>> Global Const $WM_USER = 0x0400 it seems to balk on the $WM_USER variable, but it doesn't appear to be declared anywhere else. Jared
PsaltyDS Posted August 10, 2007 Posted August 10, 2007 (edited) Any ideas why I would get a "Cannot redeclare a constant" error message, trying to run this code.on line 7 ->>> Global Const $WM_USER = 0x0400it seems to balk on the $WM_USER variable, but it doesn't appear to be declared anywhere else.JaredWhat #include statements are there in your script?That constant is in WindowsConstants.au3, which is included in several other include files. Edited August 10, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
ratacat Posted August 10, 2007 Author Posted August 10, 2007 yeah, apparently its included in autoit these days. Thanks for the help! Jared
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