mraymond Posted January 15, 2008 Posted January 15, 2008 I don't seem to be able to return values to determine if my radio buttons are on or off. I"m attempting to do some test automation and need to determine default states of these. I've got something that works with checkboxes, so that's not a problem. Some of the lines I've tried that don't seem to work are below. Note that a lot of them I've commented out while trying different approaches. (NOTE: I put a star in front of the important lines I tried) Func Test_Default_Precision_List ( ) ; Purpose: This function tests for the available values in the Default Precision ; list. If radio button for Significant Figures is in the selected state ; then the values should be 1, 2, 3, 4, 5, 6, 7, 8, 9. If the radio button ; for Decimal Places is in the selected state, then the values should be ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. If either of these list conditions are wrong ; then the test fails. It assuems "Application Preferences" dialog is open. _FileWriteLog( "Script_Log.txt", "-- Testing Default Precision list") WinActivate("Application Preferences", "") $handle = ControlGetHandle("Application Preferences", "", "$DEFAULT_PRECISION_DROPDOWN_TAG$") _FileWriteLog( "Script_Log.txt", "-- ComboBox1 Handle is: $handle$") $evaluated = _GUICtrlComboBox_GetCount ($handle) _FileWriteLog( "Script_Log.txt", "-- Dropdown list contains: $evaluated$ items") * ;ControlFocus("Application Preferences", "", "$SIGNIFICANT_FIGURES_RADIO_TAG$") * ;$state1 = BitAnd(GUICtrlRead("[CLASSNN:Button10]"),$GUI_CHECKED) * ;$state1 = GUICtrlRead ("$SIGNIFICANT_FIGURES_RADIO_TAG$" , 0) * $state1 = GUICtrlRead("$Button10", 1) _FileWriteLog( "Script_Log.txt", "-- STATE = $state1$") * ; $state1 = ControlCommand ( "Application Preferences", "", "$SIGNIFICANT_FIGURES_RADIO_BUTTON$", "IsEnabled", "" ) ;If $state1 = 1 Then ; _FileWriteLog( "Script_Log.txt", "-- Significant Figures radio button is currently selected") ;Else ; _FileWriteLog( "Script_Log.txt", "-- Significant Figures radio button is not currently selected") ; EndIf EndFunc
stampy Posted January 15, 2008 Posted January 15, 2008 Per the help file= guictrlread: For Checkbox, Radio control several states can be returned as $GUI_FOCUS and $GUI_CHECKED,. So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the control is checked.
mraymond Posted January 16, 2008 Author Posted January 16, 2008 Per the help file= guictrlread: For Checkbox, Radio control several states can be returned as $GUI_FOCUS and $GUI_CHECKED,. So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the control is checked. Ok, maybe I'm not using the right syntax or something. The following line was in my original post $state1 = BitAnd(GUICtrlRead("[CLASSNN:Button10]"),$GUI_CHECKED) The only thing it seems to return is a "0" to the $state1 variable. Here's a grab from the info window for the dialog the button is located on. >>>> Window <<<< Title: Application Preferences Class: #32770 Position: 272, 116 Size: 489, 489 Style: 0x94C800CC ExStyle: 0x00010101 Handle: 0x0007041A >>>> Control <<<< Class: Button Instance: 10 ClassnameNN: Button10 ID: 2362 Text: Si&gnificant Figures Position: 119, 218 Size: 120, 16 ControlClick Coords: 51, 15 Style: 0x50030009 ExStyle: 0x00000004 Handle: 0x00010468 >>>> Mouse <<<< Position: 445, 378 Cursor ID: 0 Color: 0x000000 >>>> StatusBar <<<< >>>> Visible Text <<<< C:\Program Files\Vernier Software\Logger Pro 3\startup.cmbl &Browse... Open Startup File as T&emplate Open Startup File on File:&New Default Folder: C:\Program Files\Vernier Software\Logger Pro 3\Experiments\ Bro&wse... &Allow Automatic Curve Fit: Default Pre&cision: 7 Deci&mal Places Si&gnificant Figures Presentation: Display &Larger Text on Screen Thic&k Graph Trace Lines Large &Toolbar Buttons Use Color Famil&y For Same Sensor Use One Color &Per Data Set Update Screen Objects For Sensor Change: For New &Files For &Opened Files Other: Enable Motion Detector Li&ve Readouts * Show Most &Recent Files New Data Sets Have (&X, Y) Auto&-backup Automatically Store Runs &Undo Levels: 4 Move Table Selection After Enter: &Down R&ight &Help OK Cancel &Startup File: * Overridden by global setting
GEOSoft Posted January 16, 2008 Posted January 16, 2008 $state1 = GUICtrlRead("$Button10") 1= Checked 4= unChecked 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!"
mraymond Posted January 16, 2008 Author Posted January 16, 2008 $state1 = GUICtrlRead("$Button10")1= Checked4= unCheckedThat doesn't seem to work either. I had already tried that actually, and it seems to return a zero whether the "Significant Figures" radio button is selected or not selected. Do you have to set focus to the thing first or something, because I tried thatearly on and it changed the state of the radio button (which I don't want to happen).
PsaltyDS Posted January 16, 2008 Posted January 16, 2008 The function GuiCtrlRead() takes a control ID as the input. So it would be: $state1 = GUICtrlRead($Button10, 1) ; Without quotes! The option 1 causes it to return the text value of the radio button, not its Checked/Unchecked state. If you just want a boolean reply for Checked/Unchecked, use ControlCommand() with the "IsChecked" option instead. If you want to refer to a control by ClassNameNN, the it would just be "Button10". If you want to specify by Class and Instance, it would be "[CLASS:Button; INSTANCE:10]". I don't think Class and Instance can be used in GuiCtrlRead() but it can in ControlCommand() for sure. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
mraymond Posted January 17, 2008 Author Posted January 17, 2008 Ok, so far I've tried all of these with no success. What is going on? My dialog is up, I can read the ComboBox, and I can tell whether "Significant Figures" or "Decimal Places" radio button is selected because I'll get a different output, so I know that works. When it gets to the point where it needs to find the state of the radio button though, none of these seem to work. I always get the same value in "$state1" whether it's always a "1" or always a "0". Is the fact that I've put focus on the ComboBox1 so I could read it before doing the radio button check causing problems? $state1 = BitAnd(GUICtrlRead("[CLASSNN:Button10]"),$GUI_CHECKED) $state1 = GUICtrlRead ("$SIGNIFICANT_FIGURES_RADIO_TAG$" , 0) $state1 = GUICtrlRead("$Button10", 1) $state1 = GUICtrlRead("$Button10") ; returns a 0 always $state1 = ControlCommand ( "Application Preferences", "", "[CLASSNN:Button10]", "IsEnabled", "" ) ; returns a 1 always $state1 = ControlCommand ( "Application Preferences", "", "[CLASS:Button; INSTANCE:10]", "IsEnabled", "" ) ; always a 1 $state1 = ControlCommand ( "Application Preferences", "", "Button10", "IsEnabled", "" ) ; returns a 1 always $state1 = GUICtrlRead($SIGNIFICANT_FIGURES_RADIO_TAG); returns a 0 always $state1 = GUICtrlRead(Button10) ; returns error dialog $state1 = GUICtrlRead(Button10, 0) ; returns error dialog
GEOSoft Posted January 17, 2008 Posted January 17, 2008 (edited) The one I don't see on that list is $state1 = ControlCommand ( "Application Preferences", "", "[CLASS:Button; INSTANCE:10]", "IsChecked", "" ) Edit: Question, is this an AutoIt GUI or not? Edited January 17, 2008 by GEOSoft 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!"
mraymond Posted January 17, 2008 Author Posted January 17, 2008 Ok, I think we got it. That last one seemed to work. This is it for anyone that might be having the same problem: $state1 = ControlCommand ( "Application Preferences", "", "[CLASS:Button; INSTANCE:10]", "IsChecked", "" ) So all in all it was just a syntax error. In answer to the question about it being an AutoIt GUI... "No", it's an application I'm building some automated scripts for. Thanks for everyone's input on this.
GEOSoft Posted January 17, 2008 Posted January 17, 2008 In answer to the question about it being an AutoIt GUI... "No", it's an application I'm building some automated scripts for.Thanks for everyone's input on this.This accounts for why GUICtrlRead() didn't work.Glad it helped. 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!"
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