gainstaa Posted January 13, 2010 Share Posted January 13, 2010 Ok so what I'm trying to do, is get this program to allow the user to select what he/she wants the hot key to be set as. Then pressing the key will execute the function. I want it so that you can go back and change the key too. Also, this is just for one hot key and function, I want it to be able to do multiple functions at the same time. Is it possible to make it run multiple functions and still have the hot keys to enable/disable the functions? Like the stuff in the function would be in a infinite loop until it is pressed again. Sorry if this is confusing, this is my first program I've tried to make with GUI's lol. #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) Global $KeySelect Global $TheKey ; Create GUI GUICreate("ComboBox Add String", 400, 296) $KeySelect = GuiCtrlCreatecombo("", 51, 1, 53, 15) GUISetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEnd ; Add string _GUICtrlComboBox_AddString($KeySelect, " ") _GUICtrlComboBox_AddString($KeySelect, "5") _GUICtrlComboBox_AddString($KeySelect, "6") _GUICtrlComboBox_AddString($KeySelect, "8") _GUICtrlComboBox_AddString($KeySelect, "9") _GUICtrlComboBox_AddString($KeySelect, "0") _GUICtrlComboBox_AddString($KeySelect, "-") _GUICtrlComboBox_AddString($KeySelect, "=") $TheKey = _GUICtrlComboBox_GetCurSel($KeySelect);Set the variable to the selected box HotKeySet($TheKey, "ShowSelected") Func ShowSelected() MsgBox(4160, "Information", "Cur Sel: " & ($TheKey)) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2010 Moderators Share Posted January 14, 2010 gainstaa, I think this does what you want: expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) Global $KeySelect Global $TheKey = "" Global $KeyList = "|5|6|7|8|9|0|-|=" ; Create GUI GUICreate("ComboBox Add String", 400, 300) $KeySelect = GuiCtrlCreatecombo("", 50, 10, 50, 20) GUICtrlSetData(-1, $KeyList) GUISetState() While 1 If GuiGetMsg() = $GUI_EVENT_CLOSE Then Exit ; See if the combo selection has changed AND the combo is closed If GUICtrlRead($KeySelect) <> $TheKey And _GUICtrlComboBox_GetDroppedState($KeySelect) = False Then ; Check the entered value is in the list If StringInStr($KeyList, GUICtrlRead($KeySelect)) > 0 Then $TheKey = GUICtrlRead($KeySelect) HotKeySet($TheKey, "ShowSelected") Else MsgBox(0, "Error", "Please enter a valid key" & @CRLF & "0, 5-9, - or =" ) GUICtrlSetData($KeySelect, $KeyList, $TheKey) EndIf EndIf WEnd Func ShowSelected() MsgBox(4160, "Information", "Cur Sel: " & ($TheKey)) EndFunc Please ask if anything is unclear. 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...
gainstaa Posted January 15, 2010 Author Share Posted January 15, 2010 (edited) Perfect. But now I am facing two other problems. Firstly, if I set the box to 5 say, then change it to 6 later, it is still registering it as 5 AND 6. So I need a way to clear the previous hotkey or something. Secondly, when I made another combo box using F1-F8 keys, it is causing a mistake. It will eventually get the 'F' Key to work, but only after several tries usually. And when I run it in notepad, it actually types out "F2" or which ever 'F' Key I used. I'm not sure if it has something to do with it being a string value in the combo box, or if the mistake is in my Send command. The combo box code for the F1-F8 keys: If GuiGetMsg() = $GUI_EVENT_CLOSE Then Exit ; See if the combo selection has changed AND the combo is closed If GUICtrlRead($KeySelect3) <> $TheKey3 And _GUICtrlComboBox_GetDroppedState($KeySelect3) = False Then ; Check the entered value is in the list If StringInStr($KeyList3, GUICtrlRead($KeySelect3)) > 0 Then $TheKey3 = GUICtrlRead($KeySelect3) Else MsgBox(0, "Error", "Please enter a valid key" & @CRLF & "F1-F8" ) GUICtrlSetData($KeySelect3, $KeyList3, $TheKey3) EndIf EndIf The Send: Send("{" & $TheKey3 & " down" & "}") Edited January 15, 2010 by gainstaa Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 15, 2010 Moderators Share Posted January 15, 2010 gainstaa, I need a way to clear the previous hotkey or somethingAnd what have you tried yourself? To unset the HotKey before setting the new one just add this line: ; Check the entered value is in the list If StringInStr($KeyList, GUICtrlRead($KeySelect)) > 0 Then HotKeySet($TheKey) ; <<<<<<<<<<<<<<<<<<<<<<<<<< Unset current hotkey $TheKey = GUICtrlRead($KeySelect) HotKeySet($TheKey, "ShowSelected") Else As for the problem with Sending the F keys, I have no idea why it is not working -the syntax seems correct. 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...
gainstaa Posted January 15, 2010 Author Share Posted January 15, 2010 gainstaa, And what have you tried yourself? To unset the HotKey before setting the new one just add this line: ; Check the entered value is in the list If StringInStr($KeyList, GUICtrlRead($KeySelect)) > 0 Then HotKeySet($TheKey) ; <<<<<<<<<<<<<<<<<<<<<<<<<< Unset current hotkey $TheKey = GUICtrlRead($KeySelect) HotKeySet($TheKey, "ShowSelected") Else As for the problem with Sending the F keys, I have no idea why it is not working -the syntax seems correct. M23 Well I just tried searching here on forums, and in the help file about deleting a hotkey, clearing, removing, etc. lol Thank you for the help, any way I could give you some Karma or anything? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 15, 2010 Moderators Share Posted January 15, 2010 gainstaa, any way I could give you some Karma or anything?Thank you for the very kind offer, but.... [serious for a moment] if you really want to give something, I would rather you gave it to the Haiti relief fund. [/serious for a moment] 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