Jump to content

Help to read radio button status of Win application like Calculator


Recommended Posts

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

  • Moderators

CalvinDude,

Welcome to the AutoIt forum. :blink:

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. :P

M23

Edit: Typnig!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

CalvinDude,

I never received such a fast response from any forum

Just 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! :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...