Holepater Posted December 21, 2014 Share Posted December 21, 2014 Hi, I'm quitte new to AutoIT and this is my first project but im now stuck. I've tried several options. What i wanna do is, i have 3 options in my combobox and i wanna link each of one on the right Function and all of them executed with a hotkey. For example i selected Combo4 in the combobox i wanna execute Func Combo4 with hotkey F5 tried several things on different ways but never really working. Thanks so far expandcollapse popup#include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> Global $Combo2 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 433, 280, 192, 124) ;;;;;;;;;;;;;;;;;;;;;;; $Label2 = GUICtrlCreateLabel("Combo", 296, 56, 55, 17) $Combo2 = GUICtrlCreateCombo("", 264, 88, 121, 25) GUICtrlSetData($Combo2, "Combo3 |Combo4 |Combo5", "Combo3") ;//////////////; #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW) ;hotkeys hotkeyset("{F5}", "$Combo2") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Func Func Combo3 () Send("{Tab}") sleep(1) send("w") sleep(1) Mouseclick("left") sleep(1) Send("{tab}") sleep(1) Send("w") sleep(1) MouseClick ("left") sleep(1) Send("{TaB}") sleep(1200) send("z") Sleep(1) mouseclick("left") EndFunc Func Combo4() Send("{Tab}") sleep(1) send("w") sleep(1) Mouseclick("left") sleep(1) Send("{tab}") sleep(1) Send("w") sleep(1) MouseClick ("left") sleep(1) Send("{TaB}") sleep(1) Send("w") Sleep(1) MouseClick("left") sleep(1) send("{tab}") sleep(1200) send("z") Sleep(1) mouseclick("left") EndFunc Func Combo5() Send("{Tab}") sleep(1) send("w") sleep(1) Mouseclick("left") sleep(1) Send("{tab}") sleep(1) Send("w") sleep(1) MouseClick ("left") sleep(1) Send("{TaB}") sleep(1) Send("w") Sleep(1) MouseClick("left") Sleep(1) send("{tab}") Sleep(1) send("w") Sleep(1) MouseClick("left") Sleep(1) Send("{Tab}") sleep(1200) send("z") Sleep(1) mouseclick("left") EndFunc Link to comment Share on other sites More sharing options...
Geir1983 Posted December 21, 2014 Share Posted December 21, 2014 Why do you need to select the function in the gui if you also need to press a specific hotkey to start a function, or do you want the same hotkey to start a function depending on what you have selected in the gui? Link to comment Share on other sites More sharing options...
Holepater Posted December 21, 2014 Author Share Posted December 21, 2014 (edited) Why do you need to select the function in the gui if you also need to press a specific hotkey to start a function, or do you want the same hotkey to start a function depending on what you have selected in the gui? Yes exactly like that, My hotkeys to use are verry limited, F5 is bound to nothing so i thought that was the best way to do it. Edited December 21, 2014 by Holepater Link to comment Share on other sites More sharing options...
Geir1983 Posted December 21, 2014 Share Posted December 21, 2014 (edited) You can do something like this Edit: Added a sleep in your loop so you dont burn your cpu more than needed expandcollapse popup#include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> Global $Combo2 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 433, 280, 192, 124) ;;;;;;;;;;;;;;;;;;;;;;; $Label2 = GUICtrlCreateLabel("Combo", 296, 56, 55, 17) $Combo2 = GUICtrlCreateCombo("", 264, 88, 121, 25) GUICtrlSetData($Combo2, "Combo3|Combo4|Combo5", "Combo3") ;//////////////; #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW) ;hotkeys While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch hotkeyset("{F5}", GUICtrlRead($Combo2)) WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Func Func Combo3 () Send("{Tab}") sleep(1) send("w") sleep(1) Mouseclick("left") sleep(1) Send("{tab}") sleep(1) Send("w") sleep(1) MouseClick ("left") sleep(1) Send("{TaB}") sleep(1200) send("z") Sleep(1) mouseclick("left") EndFunc Func Combo4() Send("{Tab}") sleep(1) send("w") sleep(1) Mouseclick("left") sleep(1) Send("{tab}") sleep(1) Send("w") sleep(1) MouseClick ("left") sleep(1) Send("{TaB}") sleep(1) Send("w") Sleep(1) MouseClick("left") sleep(1) send("{tab}") sleep(1200) send("z") Sleep(1) mouseclick("left") EndFunc Func Combo5() Send("{Tab}") sleep(1) send("w") sleep(1) Mouseclick("left") sleep(1) Send("{tab}") sleep(1) Send("w") sleep(1) MouseClick ("left") sleep(1) Send("{TaB}") sleep(1) Send("w") Sleep(1) MouseClick("left") Sleep(1) send("{tab}") Sleep(1) send("w") Sleep(1) MouseClick("left") Sleep(1) Send("{Tab}") sleep(1200) send("z") Sleep(1) mouseclick("left") EndFunc Edited December 21, 2014 by Geir1983 Link to comment Share on other sites More sharing options...
grzesiek Posted December 21, 2014 Share Posted December 21, 2014 Check also for the control: While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Combo2 hotkeyset("{F5}", GUICtrlRead($Combo2)) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Holepater Posted December 21, 2014 Author Share Posted December 21, 2014 Thank you for the solution, now i can finish my project and i've learned how to deal with that in the future 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