Omga4000 Posted May 4, 2013 Posted May 4, 2013 Hey all I've managed to get GUICtrlSetState working - but I actually didn't understand how I did it! (The full script is 300+ lines, so i will just post what's necessary) This is my script have in my script: $Make_Room = GUICtrlCreateCheckbox("Make Room?", 40, 64, 97, 17) $Make_Room_Read = GUICtrlRead($Make_Room) if $Make_Room_Read = 1 Then GUICtrlSetState(-1,$GUI_UNCHECKED) EndIf So this is working perfectly, but how?! Where exactly did I tell it to uncheck this specific checkbox? What happens in case I more than 1 checkboxes, like this: $Make_Room = GUICtrlCreateCheckbox("Make Room?", 40, 64, 97, 17) $Beep = GUICtrlCreateCheckbox("Beep?", 40, 84, 97, 17) In this case - how do I define which Check box I want to be unchecked? They both return "1" when checked and both return "4" when unchecked. Thank you, Omga4000
BrewManNH Posted May 4, 2013 Posted May 4, 2013 The -1 in the GUICtrlSetState function in your first example will set the last control created, which in your case happens to be that check box. It's always a good idea to use the controlID of the control to do this, so that you know which control you're referencing. In this example it would be $make_room that holds the control ID of the checkbox. If you're going to use -1 in control related items, you should always use it as close to the control creation command as possible so that you know which one you're referencing. Using it with -1 is useful so that you don't have to create unnecessary variables just so you can reference them once right after making it. Omga4000 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
Omga4000 Posted May 4, 2013 Author Posted May 4, 2013 Eureka! My mistake was I accidently thought the controller ID is $Make_Room_Read, however, this is the return for marked or not and not the controller ID. Stupid me! By creating a MsgBox with $Make_Room and $Beep I was able to receive their controller ID (which was 8 and 9 respectively). Now the full script is functioning perfectly. Thank you for directing me BrewManNH! Best Regards, Omga4000.
BrewManNH Posted May 4, 2013 Posted May 4, 2013 Glad I could help. Omga4000 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
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