ledigeine Posted May 2, 2012 Share Posted May 2, 2012 Ok so I am trying to learn how to use autoit to make a nice utility for myself at work. What the user will do is choose a radio button, click a line of text in a list view, then pick another item in another radio button group. Then a button press will run an exe that is at a path based on those option picked earlier. So I already have an XML setup with paths and all that, right now im making the UI of the tool. I am learning each little piece as I come to it, what i don't get is the number returning for my variable that is assigned to my radio buttons. If i do guictrlread then i get the text of the radio button... which is ok i guess but why does just the variable itself show up as 5.. I would think if the radio is selected it would say true/1. Also if anybody knows off hand, how do i make the radio buttons unselectable as well, not huge but it annoys me when testing what im trying to do. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> EBMAIN() Func EBMAIN() Local $main GUICreate("My GUI", 600, 400) GUICtrlCreateGroup("Path", 20, 14, 160, 90) $assR = GUICtrlCreateRadio("Test Assigned", 24, 30, 150, 20) $appR = GUICtrlCreateRadio("Testing Approved", 24, 50, 150, 20) $mapB = GUICtrlCreateButton("Map", 20, 200, 100, 35) GUISetState(@SW_SHOW) While 1 $main = GUIGetMsg() Select Case $main = $GUI_EVENT_CLOSE Exit Case $main = $mapB If GUICtrlRead($assR) = 1 Then ; guictrl read displays test assigned msgbox(0, "Button clicked", "radio button = " & GUictrlread($assR, 1)) ElseIf GUICtrlRead($appR) = 1 Then ; why is this returning 5? msgbox(0, "button clicked", "radio button = " & $appR) Else MsgBox(0, "try again", "try again!") EndIf EndSelect WEnd GUIDelete() EndFunc Link to comment Share on other sites More sharing options...
ledigeine Posted May 2, 2012 Author Share Posted May 2, 2012 Hmm ok i think i figured out some of my issue, GUICtrlRead(var, 1) will return the radio buttons name... the one in quotes. Then guictrlread(var) will return 1 as i was looking for and expected to see. while just the variable will return 5... why? no clue but hopefully i wont need to use that. Link to comment Share on other sites More sharing options...
BrewManNH Posted May 2, 2012 Share Posted May 2, 2012 A radio button when checked equals $GUI_CHECKED (1), when it's not selected it will return $GUI_UNCHECKED (4) when you use GUICtrlRead($radio). If you want it to return only 0 and 1 you would need to use something like this BitAND(GUICtrlRead($radio), $GUI_CHECKED) = $GUI_CHECKED, this will return 1 if checked, and 0 if it's not checked. 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...
ledigeine Posted May 2, 2012 Author Share Posted May 2, 2012 Turns out when i use guictrlread($radio) it is returning a 1. Which i think is all i need as of now. The new issue I seem to be having is, my 3 radio buttons, when one is enabled/checked i need it to load a different list of data in this list i have. So i tried that: if guictrlread($radio1) = 1 then guictrlsetdata(-1, "a set ofdata") elseif guictrlread($radio2) = 1 then ect When enabling/checking a radio button the list box does not populate with any data. I am guessing its because I am not telling the setdata part what list to set the data to? Thats what i plan on checking next, see if that -1 is really like "pick the list that was just created above this setdata command. I just saw this post and wanted to reply before starting my search. Thnx for the reply! Link to comment Share on other sites More sharing options...
ledigeine Posted May 2, 2012 Author Share Posted May 2, 2012 worked on this last night, couldnt figure out how to make a radio button create items to be loaded in a list. any help? Link to comment Share on other sites More sharing options...
ledigeine Posted May 2, 2012 Author Share Posted May 2, 2012 Now I can kinda get this working but its still broken. I can add something like: If GUICtrlRead($assR) = 1 Then GUICtrlSetData($versL, "12.0|11.1|11.0|10.8|10.7|10.6|10.5|10.4|10.3|10.2|10.1|10.0") EndIf THis is in my While 1 loop, so when i click the radio button it will keep checking the radio button and keep filling in the list i have. If i take it out of the while loop it will never fill the list. I am not sure why it doesnt detect that the radio button was clicked... maybe theres some sort of buttonactivate or something... ill keep looking. Link to comment Share on other sites More sharing options...
BrewManNH Posted May 2, 2012 Share Posted May 2, 2012 Try this, I don't have the information for your $versL so I commented it out, but it should work as written to demonstrate how to see that the radio button was clicked. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> EBMAIN() Func EBMAIN() Local $main GUICreate("My GUI", 600, 400) GUICtrlCreateGroup("Path", 20, 14, 160, 90) $assR = GUICtrlCreateRadio("Test Assigned", 24, 30, 150, 20) $appR = GUICtrlCreateRadio("Testing Approved", 24, 50, 150, 20) $mapB = GUICtrlCreateButton("Map", 20, 200, 100, 35) GUISetState(@SW_SHOW) While 1 $main = GUIGetMsg() Switch $main Case $GUI_EVENT_CLOSE Exit Case $mapB If GUICtrlRead($assR) = 1 Then ; guictrl read displays test assigned MsgBox(0, "Button clicked", "radio button = " & GUICtrlRead($assR, 1)) ElseIf GUICtrlRead($appR) = 1 Then ; why is this returning 5? MsgBox(0, "button clicked", "radio button = " & GUICtrlRead($appR, 1)) Else MsgBox(0, "try again", "try again!") EndIf Case $assR MsgBox(64, "", "Test Assigned clicked") ;~ GUICtrlSetData($versL, "12.0|11.1|11.0|10.8|10.7|10.6|10.5|10.4|10.3|10.2|10.1|10.0") Case $appR MsgBox(64, "", "Testing Approved clicked") EndSwitch WEnd GUIDelete() EndFunc ;==>EBMAIN ledigeine 1 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...
ledigeine Posted May 2, 2012 Author Share Posted May 2, 2012 THANK YOU!!!! I dont really get these switch/case type things yet. The only reason TRYING to write this stuff up is to learn and it will be a tool a few of my co-workers can use. Mainly to map drives and run an exe from the mapped location. The locations are held in an XML file so im sure i will be posting again soon asking for help . Thank you again sir! Link to comment Share on other sites More sharing options...
ledigeine Posted May 2, 2012 Author Share Posted May 2, 2012 (edited) Another issue with this same thing, I click the first radio that fills in the versions of 12.0 11.1 11.0 ect. But after setting up another radio button that will list similar version but not exactly the same it leaves what was previously caused by hitting the first button. SO click the first radio, i get 12.0 11.1 then click the other button i get 12.0 12.0 11.1 11.1 in the list. I think for each case I will have to start with clearing the list. I will start looking to find how to do that. Just posting now before leaving work incase somebody has an idea for this so i can see it when i get home. I was thinking about doing something like: ($assR is a radio button, $versL is a list for version that assR should enter the versions in that list.) Case $assR GUICtrlSetData($versL, "") GUICtrlSetData($versL, "all my versions here") This just seems like a crappy way of doing it... setting it to blank? Edit: apparently i just got rights to edit... i didnt know. I would have edited my past post if i knew that Edited May 2, 2012 by ledigeine Link to comment Share on other sites More sharing options...
BrewManNH Posted May 2, 2012 Share Posted May 2, 2012 (edited) From the help file: For Combo or List control : If the "data" corresponds to an already existing entry it is set as the default. If the "data" starts with GUIDataSeparatorChar "|" or is an empty string "" the previous list is destroyed. GUICtrlSetData($versL, "|all my versions here") Start the string with "|" to clear the listbox before adding the new information. Edited May 2, 2012 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...
ledigeine Posted May 3, 2012 Author Share Posted May 3, 2012 Thank you once again, that worked perfectly. Also was having an issue with not seeing a scroll bar but i just had to set the style to -1... i thought it was saying by default the style should have it. but that was not the case. 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