CalvinDude Posted August 4, 2010 Share Posted August 4, 2010 hello all, I am trying to read radion button status (checked or not checked) of a windows application (GUI not created by AutoIT) like calculator Scenario : Calculator launched with "Degress" button enabled by default. Reading this status using GUICtrlRead or GUICtrlGetState always return -1 After searching the forum and googling , I tried the following (code below) without any luck. Could anyone confirm, pls 1. Whether GUIxxx functions are meant only for AutoIT GUI, not for other Windows GUI (application) 2. If yes, how we can read these radio buttons Thanks in advance #include <GUIConstants.au3> ; Run Calculator Run("calc.exe") ; Wait for Window to be active WinWaitActive("Calculator") ; Check Radio button - Degress is checked ;Tried with class name ;If BitAnd(GUICtrlRead("[CLASS:Button; INSTANCE:11]"), $GUI_CHECKED) Then ;Tried with Control Id and Bit Operator ;If BitAnd(GUICtrlRead(314), $GUI_CHECKED) Then ;Tried with Control Id ;If GUICtrlRead(314) = $GUI_CHECKED Then ;Tried with Handle Id ;If GUICtrlRead(0x003307A2) = $GUI_CHECKED Then ;Tried with GUICtrlGetState and handle id If GUICtrlGetState(0x003307A2) = $GUI_CHECKED Then MsgBox(64, "Test", "Degress Checked") Else MsgBox(64, "Test", "Degress Not Checked and Checking Radians") GUICtrlSetState("[CLASS:Button; INSTANCE:12]", $GUI_CHECKED) MsgBox(64, "Test", "Degress UnChecked and Checked Radians") EndIf Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2010 Moderators Share Posted August 4, 2010 (edited) CalvinDude,Welcome to the AutoIt forum. You are correct, GUI* functions are meant only for AutoIT GUI controls created in the same script and are not for use in the GUIs of other Windows apps, even AutoIt created ones.To read controls in other apps you need to use Control* commands. This script reads and sets the "Degrees/Radians/Grads" radios in Calculator for me using Vista: For $iInstance = 11 To 13 $iState = ControlCommand ( "Calculator", "", "[CLASS:Button;INSTANCE:" & $iInstance & "]", "IsChecked", "") ConsoleWrite($iInstance & " = " & $iState & @CRLF) Next $iState = ControlCommand ( "Calculator", "", "[CLASS:Button;INSTANCE:13]", "Check", "")You may need to adjust the INSTANCE numbers if you have another OS - use the Au3 Window Info tool to check them if required. M23Edit: Typnig! Edited August 4, 2010 by Melba23 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...
CalvinDude Posted August 4, 2010 Author Share Posted August 4, 2010 M23 -You rock!. I never received such a fast response from any forumThat was really helpful. I will explore Control* commands usingControl Command function referenceIf this is not the right place to look in, please shout.Calvin Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2010 Moderators Share Posted August 4, 2010 CalvinDude,I never received such a fast response from any forumJust do not expect it every time from now on. As I am sure you are aware, this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. But we get around to solving most problems in the end - or at least proving they cannot be done! 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...
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