Trent Posted September 18, 2010 Share Posted September 18, 2010 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $Combo1 = GUICtrlCreateCombo("Select Bind", 120, 128, 145, 25) GUICtrlSetData(-1, $Combo1) $Button1 = GUICtrlCreateButton("Set", 144, 184, 75, 25, $WS_GROUP) $Button1 = GUICtrlCreateButton("Load", 190, 210, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $Combo1 = "|1|2|3|4|5" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 SAVEINI() EndSwitch WEnd HotKeySet( $Combo1 , "MSG") Func MSG() msgbox(0,"Test","Working") EndFunc func SAVEINI() IniWrite(@ScriptDir & "\settings.ini", "CONFIGURATION", "Hotkey", $Combo1) EndFunc func LOADINI() $Combo1 = IniRead(@ScriptDir & "\settings.ini", "CONFIGURATION", "Hotkey", 1) EndFunc Right now I'm trying to use a ComboBox to set a hotkey to a function. What I want the program to do is the user selects the hotkey from a list in the combobox then presses button1. Which then writes the hotkey he selected to settings.ini. When the user presses button2 it will then load the hotkey from settings.ini. I already know I'm doing something wrong with the variables. It would be greatly appreciated if someone could help me out on this . Thanks edit : I meant to put the title as " ComboBox to set hotkey to a function " Sorry about that. Edited September 18, 2010 by Trent Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 18, 2010 Moderators Share Posted September 18, 2010 Trent, Welcome to the AutoIt forum. This should give you an idea of how to go about it: expandcollapse popup#include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 625, 445, 192, 124) GUICtrlCreateLabel("Select Bind", 120, 108, 145, 15) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Or it always appears as a Combo option $Combo1 = GUICtrlCreateCombo("", 120, 128, 145, 25) ;GUICtrlSetData(-1, $Combo1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< What is this supposed to do? $Button1 = GUICtrlCreateButton("Set", 144, 184, 75, 25) $Button2 = GUICtrlCreateButton("Load", 190, 210, 75, 25) ; <<<<<<<<<< You need unique variable names GUISetState(@SW_SHOW) GUICtrlSetData($Combo1, "|1|2|3|4|5") ; Set the values in the combo While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 SAVEINI() HotKeySet("1") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Unset a previous hotkey HotKeySet("2") HotKeySet("3") HotKeySet("4") HotKeySet("5") HotKeySet(GUICtrlRead($Combo1), "MSG") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< And set the one you have just chosen Case $Button2 LOADINI() EndSwitch WEnd HotKeySet($Combo1, "MSG") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< This never gets actioned as it is after the infinite loop Func MSG() MsgBox(0, "Test", "Working") EndFunc ;==>MSG Func SAVEINI() IniWrite(@ScriptDir & "\settings.ini", "CONFIGURATION", "Hotkey", GUICtrlRead($Combo1)) EndFunc ;==>SAVEINI Func LOADINI() $sKey =IniRead(@ScriptDir & "\settings.ini", "CONFIGURATION", "Hotkey", 1) ; Set the saved HotKey (default = 1) HotKeySet($sKey, "MSG") EndFunc ;==>LOADINI Please ask if you have any questions. 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...
Trent Posted September 18, 2010 Author Share Posted September 18, 2010 Ah, now I see what I should of done. Thanks a lot! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 18, 2010 Moderators Share Posted September 18, 2010 Trent, Glad I could help. 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