Jump to content

check radio buttons


gal9
 Share

Recommended Posts

I hope I'm not spamming.
I'm trying to check if a radio button is checked

If $setting = "enabled"  Then
            If ControlCommand($mtric, "Not &Configured", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad13]", "Check", "") = 1 Then
                Send("{down 1}{ENTER}")
                            Sleep(2000)
            
            ElseIf ControlCommand($mtric, "&Enabled", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad14]", "Check", "") = 1 Then
                            Sleep(2000)
                
            ElseIf ControlCommand($mtric, "&Disabled", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad15]", "Check", "") = 1 Then
                Send("{up 1}{ENTER}")
                            Sleep(2000)
            EndIf
EndIf
        
        
If $setting = "disable"  Then
    If ControlCommand($mtric, "Not &Configured", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad13]", "Check", "") = 1 Then
            Send("{down 2}{ENTER}")
    
    ElseIf ControlCommand($mtric, "&Enabled", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad14]","Check", "") = 1 Then
                Send("{down 1}{ENTER}")
    
    ElseIf ControlCommand($mtric, "&Disabled", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad15]", "Check", "") = 1 Then
                Send("{ENTER}") 
            Sleep(2000)
    EndIf
EndIf

it not work. i see this exmple https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateRadio.htm but I do not want to create radio buttons I want to read 
image.png.f84b4b61d27a29e97861d6edab38c8e8.png

Edited by gal9
Link to comment
Share on other sites

Did you try it?  What did it return?

 

Otherwise, I think you can use the GuiCtrl commands if you pass the control handle to them.

#include <GUIConstantsEx.au3>
$hRdo1 = ControlGetHandle($mtric, "Not &Configured", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad13]",)
If BitAND(GUICtrlRead($hRdo1), $GUI_CHECKED) = $GUI_CHECKED Then
    MsgBox(0, "", "It's Checked")
Else
    MsgBox(0, "", "It's NOT checked")
EndIf

 

Link to comment
Share on other sites

On 10/25/2022 at 5:39 PM, BigDaddyO said:

Did you try it?  What did it return?

 

Otherwise, I think you can use the GuiCtrl commands if you pass the control handle to them.

#include <GUIConstantsEx.au3>
$hRdo1 = ControlGetHandle($mtric, "Not &Configured", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad13]",)
If BitAND(GUICtrlRead($hRdo1), $GUI_CHECKED) = $GUI_CHECKED Then
    MsgBox(0, "", "It's Checked")
Else
    MsgBox(0, "", "It's NOT checked")
EndIf

 

it is work thanks!!!

editing:

no is not 
image.png.dc79b09b6e489140add39ed91a7f1b52.png

Edited by gal9
Link to comment
Share on other sites

18 hours ago, BigDaddyO said:

Did you try it?  What did it return?

 

Otherwise, I think you can use the GuiCtrl commands if you pass the control handle to them.

#include <GUIConstantsEx.au3>
$hRdo1 = ControlGetHandle($mtric, "Not &Configured", "[WindowsForms10.BUTTON.app.0.297b065_r64_ad13]",)
If BitAND(GUICtrlRead($hRdo1), $GUI_CHECKED) = $GUI_CHECKED Then
    MsgBox(0, "", "It's Checked")
Else
    MsgBox(0, "", "It's NOT checked")
EndIf

 

$notConfigured = ControlGetHandle($mtric, "Not &Configured", "WindowsForms10.BUTTON.app.0.297b065_r64_ad13")
$enabled = ControlGetHandle($mtric, "&Enabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad14")
$disabled = ControlGetHandle($mtric, "&Disabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad15")


If $setting = "enabled"  Then
    Sleep(3500)
    WinWaitActive("[WindowsForms10.Window.8.app.0.297b065_r69_ad16]")
    If BitAND(GUICtrlRead($notConfigured), $GUI_CHECKED) = $GUI_CHECKED Then
        Send("{down 1}{ENTER}")
    ElseIf BitAND(GUICtrlRead($disabled), $GUI_CHECKED) = $GUI_CHECKED Then
        Send("{up 1}{ENTER}")
    ElseIf BitAND(GUICtrlRead($enabled), $GUI_CHECKED) = $GUI_CHECKED Then
        Send("{ENTER}")
    EndIf
EndIf


If $setting = "disable"  Then
    Sleep(3500)
    WinWaitActive("[WindowsForms10.Window.8.app.0.297b065_r69_ad16]")
    If BitAND(GUICtrlRead($notConfigured), $GUI_CHECKED) = $GUI_CHECKED Then
            Send("{down 2}{ENTER}")
    ElseIf BitAND(GUICtrlRead($disabled), $GUI_CHECKED) = $GUI_CHECKED Then
        Send("{ENTER}")
    ElseIf BitAND(GUICtrlRead($enabled), $GUI_CHECKED) = $GUI_CHECKED Then
                Send("{down 1}{ENTER}")
    EndIf
EndIf


If $setting = "$not configured"  Then
    Sleep(3500)
    If BitAND(GUICtrlRead($notConfigured), $GUI_CHECKED) = $GUI_CHECKED Then
            Send("{ENTER}")
    ElseIf BitAND(GUICtrlRead($disabled), $GUI_CHECKED) = $GUI_CHECKED Then
        Send("{up 1}{ENTER}")
    ElseIf BitAND(GUICtrlRead($enabled), $GUI_CHECKED) = $GUI_CHECKED Then
                Send("{down 1}{ENTER}")
    EndIf
EndIf

i try to do this but is stuck 

image.png.4c8cd1cd9a901e254bcf85495970ff25.png

 

 

not work 
image.png.dc79b09b6e489140add39ed91a7f1b52.png

Edited by gal9
Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

3 minutes ago, Nine said:

I don't understand what you are saying.  Just use the function with the handle of your radio button, not that complicated, is it ?

 

I am using the "Autoit v3 Windows Info", and I found the "Class" and the "Instances" of the radio button.
Now I need to do 2 things:
1) I want to select the radio button by using the "class" and the "instances".

2) I need to validate the status of the same radio button. If the radio button is selected or not selected.

 

 

Link to comment
Share on other sites

On 10/28/2022 at 3:03 PM, BigDaddyO said:

Nine did help you.  you need to look in the help file at _GUICtrlButton_GetCheck it even has an example.

if that function is not working for you, post the code you use as a test and show what the return from the function is.

 

But in the example they use coordinates I want to use  class and instances

Link to comment
Share on other sites

On 10/28/2022 at 3:03 PM, BigDaddyO said:

Nine did help you.  you need to look in the help file at _GUICtrlButton_GetCheck it even has an example.

if that function is not working for you, post the code you use as a test and show what the return from the function is.

 

I get three times Button is cleared for not configured enabled disabled

image.png.61da9aac954c9e2f211e3e49da331a47.png

this is my code i try to do like example
 

#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win9x/NT
; Author:         Jonathan Bennett (jon at autoitscript dot com)
; Modified:       mLipok
;
; Script Function:
;   Opens Notepad, types in some text and then quits the application.
;




If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable")

MsgBox(4096, "message", "The setting  "& $CmdLine[1] & " set to " & $CmdLine[2] & " This box will time out in 3 seconds", 3)
    Sleep(5000)

        Local $mtric =$CmdLine[1] 
;       "Allow Adobe Flash"
        Local $setting = $CmdLine[2]
        ;"disable"
_Example($mtric,$setting)
MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 3 seconds", 3)
Exit(0) 

; Finished!


Func _Example($mtric,$setting)


    ; Run gpedit.msc
    ; Run("c:\Windows\system32\mmc.exe c:\Windows\system32\gpedit.msc /a")
    Run("c:\Windows\system32\mmc.exe C:\Users\gal.dahan\Desktop\script\gpedit_v1.msc /a")

    Sleep(2500)

    WinWaitActive("[CLASS:MMCMainFrame]")

    Sleep(500)

    Send("{ALT}{A}{O}")
    While ControlGetFocus("[TITLE:Filter Options]") = ""
        sleep(1)
    WEnd
    WinWaitActive("[TITLE:Filter Options]")

    Sleep(3500)

If ControlCommand("Filter Options", "Enable &Keyword Filters", "Button2", "IsChecked", "") = 0 Then
    Send("{ALT down}{K}{F}{ALT up}")
Else
    Send("{ALT down}{F}{ALT up}")
EndIf

Sleep(3500)
    ;;Type search
Send($mtric)
Sleep(3500)

Send("{ENTER}")
Sleep(5500)
                Send("{tab}{down 1}{ENTER}")
                Sleep(2000)
        Send("{down 2}{ENTER}")
        Sleep(4000)

             Local $notConfigured = ControlGetHandle($mtric, "Not &Configured", "WindowsForms10.BUTTON.app.0.297b065_r64_ad13")
             Local $enabled = ControlGetHandle($mtric, "&Enabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad14")
             Local $disabled = ControlGetHandle($mtric, "&Disabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad15")
            Example2()


Sleep(3500)

Send ("{Ctrl}{S}") 
Send("^s")
;_Validation($mtric,$setting)
Sleep(3500)

WinWaitActive("[CLASS:MMCMainFrame]")
Send("{ALT down}{F4}{ALT up}")
Sleep(2000)

;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10)

EndFunc   

Global $g_idMemo

Func Example2()
        Local $idRdo, $idRdo2, $idChk
        Local $notConfigured = ControlGetHandle($mtric, "Not &Configured", "WindowsForms10.BUTTON.app.0.297b065_r64_ad13")
        Local $enabled = ControlGetHandle($mtric, "&Enabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad14")
        Local $disabled = ControlGetHandle($mtric, "&Disabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad15")


        _GUICtrlButton_SetCheck($notConfigured)
        _GUICtrlButton_SetFocus($notConfigured) ; set focus, shows this doesn't affect _GUICtrlButton_GetCheck


        GUISetState(@SW_SHOW)

        MemoWrite("$idRdo checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($enabled)) & @CRLF)
        MemoWrite("$idRdo2 checked status: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($notConfigured)) & @CRLF)
        MemoWrite("$idChk checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($disabled)) & @CRLF)

        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                ExitLoop
                EndSwitch
        WEnd

        Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    Local $g_idMemo
        GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func _ExplainCheckState($iState)
        Switch $iState
                Case $BST_CHECKED
                        MsgBox(4096, "message", "Button is checked.", 3)
                        Return "Button is checked."
                    Case $BST_INDETERMINATE
                        MsgBox(4096, "message", "Button is grayed, indicating an indeterminate state (applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style).", 3)
                        Return "Button is grayed, indicating an indeterminate state (applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style)."
                    Case $BST_UNCHECKED
                        MsgBox(4096, "message", "Button is cleared", 3)
                        Return "Button is cleared"
        EndSwitch
EndFunc   ;==>_ExplainCheckState

it works until the moment I call  Example2() to check the radio buttons. I get three times  "Button is cleared"  I need to check  If it is checked

Edited by gal9
Link to comment
Share on other sites

I have also problem with the radio button. There is any good example how to click on a radio button, but without using cordinate.
This is odd. because the autoit tool find the radio button instances and the class easly.

If there is a way to take the cordinate of class ?  and then I can use to click on it.

Please help.

Link to comment
Share on other sites

You did not set any error handling, how do you know that any statement is working ?

Now we gonna do a small test, you're gonna run your application manually, then set the radio button "Not configured" manually also.  Then run the following script from Scite :

#include <GuiButton.au3>

Local $hWnd = WinWaitActive("[CLASS:MMCMainFrame]", "", 5)
ConsoleWrite("WinWaitActive " & @error & "/" & $hWnd & @CRLF)
Local $hControl = ControlGetHandle($hWnd, "", "WindowsForms10.BUTTON.app.0.297b065_r64_ad13")
ConsoleWrite("Not configured " & @error & "/" & $hControl & @CRLF)
Local $iResult = _GUICtrlButton_GetCheck($hControl)
If $iResult = $BST_CHECKED Then MsgBox($MB_SYSTEMMODAL, "", "Checked")
If $iResult = $BST_INDETERMINATE  Then MsgBox($MB_SYSTEMMODAL, "", "Inderterminate")
If $iResult = $BST_UNCHECKED  Then MsgBox($MB_SYSTEMMODAL, "", "Cleared")

Report Scite console.

Edited by Nine
Link to comment
Share on other sites

8 minutes ago, Nine said:

You did not set any error handling, how do you know that any statement is working ?

Now we gonna do a small test, you're gonna run your application manually, then set the radio button "Not configured" manually also.  Then run the following script from Scite :

#include <GuiButton.au3>

Local $hWnd = WinWaitActive("[CLASS:MMCMainFrame]", "", 5)
ConsoleWrite("WinWaitActive " & @error & "/" & $hWnd & @CRLF)
Local $hControl = ControlGetHandle($hWnd, "", "WindowsForms10.BUTTON.app.0.297b065_r64_ad13")
ConsoleWrite("Not configured " & @error & "/" & $hControl & @CRLF)
Local $iResult = _GUICtrlButton_GetCheck($hControl)
If $iResult = $BST_CHECKED Then MsgBox($MB_SYSTEMMODAL, "", "Checked")
If $iResult = $BST_INDETERMINATE  Then MsgBox($MB_SYSTEMMODAL, "", "Inderterminate")
If $iResult = $BST_UNCHECKED  Then MsgBox($MB_SYSTEMMODAL, "", "Cleared")

Report Scite console.

"Not configured" is marked I get Cleared.
"Enabled" is marked I get Cleared.
"Disabled" is marked I get Cleared.image.thumb.png.d3e258783512364aad8480b8eb64f908.png

 

 

in the console  i get:
image.png.529f59c77bbb45ee4718f63f7479e4fe.png

Edited by gal9
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...