DarkBoost Posted September 27, 2010 Share Posted September 27, 2010 I added HotKeySet() within the "Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)" so that a user can adjust a hotkey realtime however it is not overwriting/updating the Hotkey instead it is adding a new HotKeySet(). Could someone please advise of a better approach to this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 27, 2010 Moderators Share Posted September 27, 2010 DarkBoost, I posted some code yesterday which does exactly what you want. Take a look and come back if you have any questions or you run into difficulty incorporating the idea into your script. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DarkBoost Posted September 28, 2010 Author Share Posted September 28, 2010 (edited) ah I see... you set the existing hotkey to "" and then create a new hotkey. I would think that this would still end up creating many hotkeys which are unassigned but maybe still not affecting the scripts performance? here is my working example: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> Dim $msg, $input[5] Dim $hotkey = "x" GUICreate("hotkey-example", 300, 60) $input[0] = 4 $input[1] = GUICtrlCreateInput($hotkey, 10, 20, 50, 20, $ES_CENTER) $input[2] = GUICtrlCreateCheckbox("CTRL", 90, 20, 60, 20, $BS_CENTER) $input[3] = GUICtrlCreateCheckbox("ALT", 160, 20, 60, 20, $BS_CENTER) $input[4] = GUICtrlCreateCheckbox("SHIFT", 230, 20, 60, 20, $BS_CENTER) GUICtrlSetState($input[2], $GUI_FOCUS) HotKeySet($hotkey, "hotkey_display") GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam HotKeySet($hotkey, "hotkey_empty") $hotkey = "" If GUICtrlRead($input[2]) = 1 Then $hotkey &= "^" If GUICtrlRead($input[3]) = 1 Then $hotkey &= "!" If GUICtrlRead($input[4]) = 1 Then $hotkey &= "+" If GUICtrlRead($input[1]) <> "" Then $hotkey &= GUICtrlRead($input[1]) HotKeySet($hotkey, "hotkey_display") EndFunc Func hotkey_empty() EndFunc Func hotkey_display() MsgBox(0, "", $hotkey) EndFunc Edited September 28, 2010 by DarkBoost Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 28, 2010 Moderators Share Posted September 28, 2010 DarkBoost,If you think about it, you start with all the possible HotKey combinations unassigned - using HotKeySet just tells Windows that a particular function should be associated with a particular key combination. Unsetting the HotKey just returns that key combination to its original state, so it will certainly not affect performance. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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