Chimaera Posted March 19, 2015 Share Posted March 19, 2015 Ok not particularly a solve needed more advice i guess Im building a gui with lots of buttons on it (prob 100) Now each of them has a choice scenario (Yes/No/NA) mostly, i've managed to automate quite a few of them but some are manual checks a tech has to perform. And here is the problem I don't know which is the best way to do it from these 2 examples Should i create three button one for each choice like this Case $TimeButton Local $SetTime = _SyncTime() GUICtrlSetImage($TimeIcon, $tick) RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Time', 'REG_SZ', _Date_Time_SystemTimeToDateTimeStr($CuDate)) Case $TimeButton2 GUICtrlSetImage($TimeIcon, $cross) RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Time', 'REG_SZ', 'NotCompleted') ShellExecute('timedate.cpl') Case $TimeButton2 GUICtrlSetImage($TimeIcon, $cross) RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Time', 'REG_SZ', 'NotAvailable') This obviously increases my button count in a major way Or do i create a single button with a Yes/No/Cancel checkbox behind it like this Local $MicCheck = MsgBox($MB_YESNOCANCEL + $MB_ICONWARNING + $MB_DEFBUTTON2, 'Microphone Test', 'Does The Microphone Work') If $MicCheck = $IDCANCEL Then RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Microphone', 'REG_SZ', 'NotAvailable') GUICtrlSetImage($MicIcon, $maybe) ElseIf $MicCheck = $IDYES Then GUICtrlSetImage($MicIcon, $tick) RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Microphone', 'REG_SZ', _Date_Time_SystemTimeToDateTimeStr($CuDate)) ElseIf $MicCheck = $IDNO Then GUICtrlSetImage($MicIcon, $cross) RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Microphone', 'REG_SZ', 'NotCompleted') EndIf Obviously these are chopped out as examples So which is the most sensible way to go, my boss likes a button for each choice but im not sure due to the amount of creation needed Any thoughts? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JohnOne Posted March 19, 2015 Share Posted March 19, 2015 You give your boss what he wants. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Chimaera Posted March 19, 2015 Author Share Posted March 19, 2015 (edited) @John Not always.. Another thought that occured to me If ive got 6 tabs with 20-50 buttons per tab is there a limit on the While Wend that has to contain them all. Or is it the more i add it will take 10 mins to load the GUI? Edited March 20, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted March 20, 2015 Share Posted March 20, 2015 Sounds like you need checkboxes, or radio controls more than you need all these buttons. It sounds massively inefficient doing whatever it is you're doing with that many buttons. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted March 20, 2015 Author Share Posted March 20, 2015 (edited) Ok i hadn't considered Checkboxes,ill mock up a few and see how it looks This is the current one just for Ref The cross changes based on the choice. N/A gives a different coloured tick because its been checked but it was unavailable like a dcjack on a desktop isnt there but on a laptop is valid Edited March 20, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted March 20, 2015 Share Posted March 20, 2015 For something like your image, I'd use 3 radio controls, because you only can have one legitimate option for that. It's either yes, no, or n/a, it can't be yes AND no or any other combination. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted March 20, 2015 Author Share Posted March 20, 2015 Its a shame you cant tie 3 controls under 1 header so they work together so it can only be one choice out of three circles I was trying to get them more old school but i cant seem to find a way to make them more basic and have no background but then something melba gave me for groups i inadvertanly used it on a radio box like this Local $FNKeysButton = GUICtrlCreateRadio('Yes', 595, 189, 45, 30) _Font() DllCall('UxTheme.dll', 'int', 'SetWindowTheme', 'hwnd', GUICtrlGetHandle($FNKeysButton), 'wstr', 0, 'wstr', 0) and it gives me this Is there a way to make the radios like the bottom example in the pic through normal settings Or am i safe using the melba addon for radios? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
sherkas Posted March 20, 2015 Share Posted March 20, 2015 Personally, I would use the button method. I think both are great but I think the button method is best. Sometimes you just have alot of buttons. I dont think anything about 200 or less button checks in a loop is going to have much effect but if your concerned. Do them in sections. One gui screen has 20 options, next has 20 etc. Then they just flip through them and then the loops should be faster. Link to comment Share on other sites More sharing options...
BrewManNH Posted March 20, 2015 Share Posted March 20, 2015 (edited) Its a shame you cant tie 3 controls under 1 header so they work together so it can only be one choice out of three circles Of course you can, you put the linked ones inside a group, if you want the group outline use GUICtrlCreateGroup, without the line use GUIStartGroup. This script will create 2 groups of radio buttons and the 2 different groups don't interact with each other. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered GUIStartGroup() Local $idRadio1 = GUICtrlCreateRadio("Radio 1", 10, 10, 120, 20) Local $idRadio2 = GUICtrlCreateRadio("Radio 2", 10, 40, 120, 20) GUICtrlSetState($idRadio2, $GUI_CHECKED) GUIStartGroup() Local $idRadio3 = GUICtrlCreateRadio("Radio 3", 200, 10, 120, 20) Local $idRadio4 = GUICtrlCreateRadio("Radio 4", 200, 40, 120, 20) GUICtrlSetState($idRadio3, $GUI_CHECKED) GUISetState(@SW_SHOW) ; will display an dialog box with 1 checkbox Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE ExitLoop Case $idMsg = $idRadio1 And BitAND(GUICtrlRead($idRadio1), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'You clicked the Radio 1 and it is Checked.') Case $idMsg = $idRadio2 And BitAND(GUICtrlRead($idRadio2), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'You clicked on Radio 2 and it is Checked.') Case $idMsg = $idRadio3 And BitAND(GUICtrlRead($idRadio3), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'You clicked the Radio 3 and it is Checked.') Case $idMsg = $idRadio4 And BitAND(GUICtrlRead($idRadio4), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'You clicked on Radio 4 and it is Checked.') EndSelect WEnd EndFunc ;==>Example Edited March 20, 2015 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted March 20, 2015 Author Share Posted March 20, 2015 (edited) Well bugger me ive never ever seen that option lol edit probably because i dont use radio options Thx ill see what i can come up with #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered GUIStartGroup() Local $idRadio1 = GUICtrlCreateRadio("Yes", 10, 10, 40, 20) Local $idRadio2 = GUICtrlCreateRadio("No", 50, 10, 40, 20) Local $idRadio3 = GUICtrlCreateRadio("N/A", 90, 10, 40, 20) GUICtrlSetState($idRadio2, $GUI_CHECKED) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE ExitLoop Case $idMsg = $idRadio1 And BitAND(GUICtrlRead($idRadio1), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'Set Yes',1) Case $idMsg = $idRadio2 And BitAND(GUICtrlRead($idRadio2), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'Set No.',1) Case $idMsg = $idRadio3 And BitAND(GUICtrlRead($idRadio3), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'Set N/A.',1) EndSelect WEnd EndFunc ;==>Example Something i dont get. I see that the 3 are tied together in the gui but on the cases they still need adding as single entities, is there a way to make it so i can only add 1 Case but it gives the choice whatever it maybe from the group? Or am i thinking of this the wrong way? Edited March 20, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
sherkas Posted March 20, 2015 Share Posted March 20, 2015 Your right. your case I think can do a if radio 1 is check, or radio 2 or 3. (Or operator) Link to comment Share on other sites More sharing options...
BrewManNH Posted March 20, 2015 Share Posted March 20, 2015 Without knowing what you're going to do with the GUI and the radio buttons I can't really say for sure what you need to do. If you are just looking to see if there was a change you can do it this way. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered GUIStartGroup() Local $idRadio1 = GUICtrlCreateRadio("Yes", 10, 10, 40, 20) Local $idRadio2 = GUICtrlCreateRadio("No", 50, 10, 40, 20) Local $idRadio3 = GUICtrlCreateRadio("N/A", 90, 10, 40, 20) GUICtrlSetState($idRadio2, $GUI_CHECKED) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idRadio1, $idRadio2, $idRadio3 If GUICtrlRead($idRadio1) = $GUI_CHECKED Then MsgBox($MB_SYSTEMMODAL, 'Info:', 'Set Yes', 1) ElseIf GUICtrlRead($idRadio2) = $GUI_CHECKED Then MsgBox($MB_SYSTEMMODAL, 'Info:', 'Set No.', 1) ElseIf GUICtrlRead($idRadio3) = $GUI_CHECKED Then MsgBox($MB_SYSTEMMODAL, 'Info:', 'Set N/A.', 1) EndIf EndSwitch WEnd EndFunc ;==>Example If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted March 20, 2015 Author Share Posted March 20, 2015 (edited) Sorry i should have said each set of three radios (Yes No N/A) has only one outcome of the three And i change a label based upon that outcome Like your example I didnt know you could tie three things under one case Thx ill have a trail tommoz at work when i get time Edited March 20, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted March 21, 2015 Share Posted March 21, 2015 Just take notice that I changed it from a Select/Case to a Switch/Case. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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