paul1149 Posted October 31, 2010 Share Posted October 31, 2010 Hi,Sorry for what I suspect is a simple question. I have a script (see below) by which I switch Power Plans in Win7. It opens an InputBox, I type in the number of the plan that I want and click OK. It works fine.But I'd like to expand the box and add more options, and I'd like to 1) clean up the options presentation, one option per line, and 2) possibly assign each option to a Control Button.Is something like this possible?Thanks,p.The existing script:$PowerPlan = InputBox( "Choose Power Plan", "1: Energy Star, 2: myNoSleep" ) If $PowerPlan = 1 Then Run("Powercfg -setactive c0ea6ad3-6145-4447-a15e-5fb97be69b98") ExitElse Run("powercfg -setactive c78a5555-aa90-40c0-a554-20788489c55b") ExitEndIf Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2010 Moderators Share Posted October 31, 2010 paul1149, Sounds like you need a combo: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData(-1, "Energy Star|myNoSleep") GUISetState() $sCurrCombo = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hCombo If GUICtrlRead($hCombo) <> $sCurrCombo Then $sCurrCombo = GUICtrlRead($hCombo) MsgBox(0, "Choice", $sCurrCombo) EndIf EndSwitch WEnd 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...
paul1149 Posted October 31, 2010 Author Share Posted October 31, 2010 paul1149,Sounds like you need a combo: Thanks. That's pretty good, and good to know. Is it possible to list the options openly, one per line, with a control button for each one?Thanks again,p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2010 Moderators Share Posted October 31, 2010 paul1149,Is it possible to list the options openly, one per line, with a control button for each one?If that is all you want, just create a GUI with buttons and associated labels. 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...
GEOSoft Posted October 31, 2010 Share Posted October 31, 2010 M23 appears to be asleep at the wheel today. I think he probably meant use RADIO buttons and read the value of those when a Control button is clicked. #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hRadio_1 = GUICtrlCreateRadio("Energy Star", 10, 10, 100, 20) $hRadio_2 = GUICtrlCreateRadio("My No Sleep", 10, 30, 100, 20) $hRadio_3 = GUICtrlCreateRadio("My Other Scheme", 10, 60, 100, 20) $hBtn_Go = GUICtrlCreateButton("Set", 220, 420, 60, 25) GUISetState() $sText = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hBtn_Go For $i = $hRadio_1 To $hRadio_3 If GUICtrlRead($i) = 1 Then $sText = GUICtrlRead($i, 1) MsgBox(0, "Choice", $sText) ExitLoop EndIf Next EndSwitch WEnd George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
paul1149 Posted October 31, 2010 Author Share Posted October 31, 2010 GEOSoft, Thanks much for taking the time to write that. I'm not getting anything from it though. Could there be something missing, or am I doing something wrong? Thanks again, p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2010 Moderators Share Posted October 31, 2010 George, Less of the cheek - I do have other things to do in my life you know! Actually I forgot to log off! paul1149, George was not able to read my mind this time - what I actually had in mind was something like this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel("Energy Star", 100, 15, 100, 20) GUICtrlCreateLabel("My No Sleep", 100, 55, 100, 20) GUICtrlCreateLabel("My Other Scheme", 100, 95, 100, 20) $hButton_1 = GUICtrlCreateButton("Go", 10, 10, 80, 30) $hButton_2 = GUICtrlCreateButton("Go", 10, 50, 80, 30) $hButton_3 = GUICtrlCreateButton("Go", 10, 90, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_1 MsgBox(0, "Choice", "Energy Star") Case $hButton_2 MsgBox(0, "Choice", "My No Sleep") Case $hButton_3 MsgBox(0, "Choice", "My Other Scheme") EndSwitch WEnd As you can see, there are many ways to skin this particular feline. M23 SpecialS 1 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...
paul1149 Posted October 31, 2010 Author Share Posted October 31, 2010 M23 and GEO, Wow - sorry. I had a file mix-up. Somehow the file I was working on in the editor was not the file I was executing from Desktop. Once I got that straightened out these scripts work perfectly. This button one is exactly what I was looking for. Thanks much to both of you for your time on this! Thanks, p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
GEOSoft Posted October 31, 2010 Share Posted October 31, 2010 Darn!!!! M23 wins again. I'll settle that issue on the next one. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
paul1149 Posted October 31, 2010 Author Share Posted October 31, 2010 You guys have a great camaraderie. And it helps us who need to learn! The script is working great now, thanks again. p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
SpecialS Posted July 23, 2015 Share Posted July 23, 2015 Melba23Lets say i would like to make a loop that only gets activated once you pressed Case $hButton_1How would you do it? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 23, 2015 Moderators Share Posted July 23, 2015 SpecialS,Put the loop inside a function which you call when the button is actioned? Without more details I cannot really offer anything more sensible.M2£ 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