kor Posted August 1, 2012 Share Posted August 1, 2012 (edited) my entire script removed If you run it, you will see that while the script just sits there and the mouse moves around inside the gui window you will see the console write just writing "test" over and over again. I only want the "test" action that is inside the case statement to trigger if the "student" and "delete" radio boxes are checked. Why does it perform the action if the radios aren't selected? Edited August 1, 2012 by kor Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 1, 2012 Moderators Share Posted August 1, 2012 kor,Are you sure thisis the correct syntax: Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit [...] Case $aControls[2] Or $aControls[5] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("test")The way you have written it, the Case statement is always True as both controls exist - so you get it firing permamently. If you use the correct syntax:Case $aControls[2], $aControls[5]then it will work as you wish. 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...
Mechaflash Posted August 1, 2012 Share Posted August 1, 2012 (edited) kor, Are you sure thisis the correct syntax: Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit [...] Case $aControls[2] Or $aControls[5] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("test") The way you have written it, the Case statement is always True as both controls exist - so you get it firing permamently. If you use the correct syntax: Case $aControls[2], $aControls[5] then it will work as you wish. M23 Expanding on Melba's post, $aControls are the handle to the control itself. It doesn't give you the state of the control (checked/unchecked) To get the value of the checkbox control to see if it's checked/unchecked, Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit [...] Case $aControls[2] Or $aControls[5] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If GUICtrlRead($aControls[2]) = $GUI_CHECKED And GUICtrlRead($aControls[5]) = $GUI_CHECKED Then ConsoleWrite("test") EndIf EDIT: I would like to add, a safer method of using switches/checkboxes and the like, allow the user to select/deselect the boxes at will, and then use something like a "Submit" button to read the status of the checkboxes. EDIT2: Changed 'Or' to 'And' for GUICtrlRead() statements Edited August 1, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
BrewManNH Posted August 1, 2012 Share Posted August 1, 2012 Try this: Case $aControls[2] , $aControls[5] 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...
kor Posted August 1, 2012 Author Share Posted August 1, 2012 Try this: Case $aControls[2] , $aControls[5] This "works" but as soon as you click on either [2] or [4] the "test" appears. How do you set an "AND" in the case. I've tried Case GUICtrlRead($aControls[2]) = $GUI_CHECKED And GUICtrlRead($aControls[5]) = $GUI_CHECKED but it results in an endless loop. @mecha, yes, I do have a "go" box. However the point of this particular trigger if certain radio boxes are checked or unchecked before the "go" button is pressed is to disable or enable certain inputs for only the boxes are needed depending on what radio button combination you have selected. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 1, 2012 Moderators Share Posted August 1, 2012 kor,You need the Case line written as both I and BrewManNH suggested and then you check for both radios being selected inside the Case code (not tested):Case $aControls[2] , $aControls[5] If GUICtrlRead($aControls[2]) = $GUI_CHECKED And GUICtrlRead($aControls[5]) = $GUI_CHECKED Then ; Do what you want here EndIfNow you run the check whenever one of them is clicked, but only action the code if both of them are selected. 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...
kor Posted August 1, 2012 Author Share Posted August 1, 2012 kor, You need the Case line written as both I and BrewManNH suggested and then you check for both radios being selected inside the Case code (not tested): Case $aControls[2] , $aControls[5] If GUICtrlRead($aControls[2]) = $GUI_CHECKED And GUICtrlRead($aControls[5]) = $GUI_CHECKED Then ; Do what you want here EndIf Now you run the check whenever one of them is clicked, but only action the code if both of them are selected. M23 Yes, I tried that solution and its working now as expected. I thought I could get away with doing all the logic inside the Case. But understand now it must be in the case... then further logic checking for the state of the buttons. Thanks! Link to comment Share on other sites More sharing options...
Mechaflash Posted August 1, 2012 Share Posted August 1, 2012 Yes, I tried that solution and its working now as expected. I thought I could get away with doing all the logic inside the Case. But understand now it must be in the case... then further logic checking for the state of the buttons. Thanks! Here's the code to the Edit Configuration area in my program (linked in my sig). ;Part for the Case ;Changes in Default File Name Scheme Case $igMultiFile If GUICtrlRead($igMultiFile) = $GUI_CHECKED Then _ShowFileInput($asDefCapFile) Else _HideFileInput($asDefCapFile) EndIf ............................................. ;Functions to show/hide controls based on the state of the checkbox, where $asDefCapFile is an array that holds the handle to the controls I want to show/hide. Func _ShowFileInput(Const $asDefCapFile) $sFile = IniRead($sIni, "Parameters", "Cap File Scheme", "") If Not $sFile Then _Error(3, 2) For $i = 1 To 3 GUICtrlSetState($asDefCapFile[$i], $GUI_SHOW) If $i = 2 Then GUICtrlSetData($sFile, $asDefCapFile[1]) Next Return True EndFunc ;==>_ShowFileInput Func _HideFileInput(Const $asDefCapFile) For $i = 1 To 3 GUICtrlSetState($asDefCapFile[$i], $GUI_HIDE) Next Return True EndFunc ;==>_HideFileInput Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” 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