Jump to content

How would I find out if a tick box is already ticked? ?


Recommended Posts

Hey guys

I have this tick box and on my test if it's already ticked I want to do nothing but if it's not ticked I want to tick it

I do this via a mouse click which is fine.

However the problem I have is the test needs to run 30+ times and the tickbox remains ticked if it was ticked the last time

I suppose I could tick it once then leave it however it'd be nice if there was  a way to tell if the tick box was ticked instead of relying on MouseClicks

 

 

 

1.PNG

2.PNG

Link to comment
Share on other sites

@CaptainBeardsEyesBeard,

Can you post your code with issue so we can further see what you want. And if the tick box you mean is a check box, maybe $GUI_CHECKED and $GUI_UNCHECKED is the one you are looking for. Or maybe not.^_^

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

If GuiCtrlRead("ThunderRT6CheckBox")=$GUI_CHECKED Then
   Navigation_Click_Billing_Manager_ProformaEdit_InfoOnlyProforma_OverrideProformaTemplateField()
Else

EndIf

 

Link to comment
Share on other sites

Hmm I tried that. However it stills seems to click the tickbox regardless? Is there a better command for clicking a tickbox rather than using MouseClicks?

 

Local $Gui_Checked = false

If GuiCtrlRead("ThunderRT6CheckBox")= $Gui_Checked Then
   Navigation_Click_Billing_Manager_ProformaEdit_InfoOnlyProforma_UseBillTemplate()
Else

EndIf

Navigation_Click_Billing_Manager_ProformaEdit_InfoOnlyProforma_OverrideProformaTemplateField()

 

Edited by CaptainBeardsEyesBeard
Link to comment
Share on other sites

GUICtrlRead($idControl) only reads GUI controls written from your AutoIt script.

To read the state of the 3rd party checkbox, maybe something like this?  

$isChecked = ControlCommand("[CLASS:#32770]", "", "[CLASS:Button; INSTANCE:4]", "IsChecked"))

Ref Link

You'll need to replace parameters with your control specifications.

Edited by Xandy
Link to comment
Share on other sites

You asked about ticking checkboxs.  ControlCommand() above with a different Command parameter, or ControlSend(), ControlClick(), there are other methods that I have forgotten about.

Edited by Xandy
Link to comment
Share on other sites

@CaptainBeardsEyesBeard is this what you are looking for? 

 

What I have done is wrap the If...Then into a Function. This allows for fluid checking of the box. Each time the box is ticked, you get notified. 

To understand this better, each time you click on the check box, A status which the GuiCtrlRead collects, is inserted into the Func (Function).
The Func (Function) then parsing this information into the If...Then...Else "query" which entails sets off an action. In this case, changes the label.

 

Code below:

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 210, 220, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("", 40, 112, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Checkbox1
            $Read = GUICtrlRead($Checkbox1)
            Marker()

    EndSwitch
WEnd


Func Marker()
    If $Read = $GUI_CHECKED Then
        GUICtrlSetData($Checkbox1, "It is checked")
    Else
        GUICtrlSetData($Checkbox1, "It is empty")
    EndIf
EndFunc   ;==>Marker

 

 

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Link to comment
Share on other sites

@CaptainBeardsEyesBeard,

You are asking on how to ticked and unticked these checkboxes, so it would be this way (example from help file)::)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a checkbox control.
    Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idCheckbox
                If _IsChecked($idCheckbox) Then
                    MsgBox($MB_SYSTEMMODAL, "", "The checkbox is checked.", 0, $hGUI)
                Else
                    MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.", 0, $hGUI)
                EndIf

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

Now if you want something aside from ticking these checkboxes, please elaborate more on your concern so that we can provide more suggestions and if possible to help you more.^_^

 

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

I think we are confusing ourselves if OP wants to check if a checkbox is ticked in the GUI created by his script or if he is trying to automate another application. It looks like the latter but to just make sure:

@CaptainBeardsEyesBeard Are you trying to automate a program or are you working with your own GUI?

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

@TheDcoder, You right... The OP wants to make a program that will click a handle. The handle been a check box... 
Hmmm. I think the OP will need to look more into the AU3Info, tell Autoit to bring that to the for-front and execute the command to find the checkboxes...

I think!

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Link to comment
Share on other sites

15 hours ago, TheDcoder said:

I think we are confusing ourselves if OP wants to check if a checkbox is ticked in the GUI created by his script or if he is trying to automate another application. It looks like the latter but to just make sure:

AutoIt doesn't produce windows with that type of class shown in the original post, so it's certain it's not an AutoIt program being automated. Seeing as how the checkbox has an ID of ThunderRT6CheckBox, there's no way to use GUICtrlRead on it either, so lets stop posting code using it.

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 Gude
How 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

A quick Google search shows this question has been appearing in many forums... most common in the Visual Studio forum.
Weird... wonder what form or application is this ThunderRT6CheckBox belonging to for it to have so many posts and all relating to "ticking the box".

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Link to comment
Share on other sites

That type of gui and control are created by visual basic if I remember correctly.

Use the following to see if it helps.

 

 

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 Gude
How 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

I have worked with applications that use Thunder Forms.  You can use ControlCommand to work with them.  Give this code sample a try.  

Global Const $sDialogTitle = "[CLASS:ThunderRT6MDIForm]"
Global Const $sDialogText = ""
Global Const $sControlUseBillTemplate = "[CLASS:ThunderRT6CheckBox; TEXT:Use Bill Template]"

If ControlCommand($sDialogTitle, $sDialogText, $sControlUseBillTemplate, "IsChecked", "") Then
    ControlCommand($sDialogTitle, $sDialogText, $sControlUseBillTemplate, "UnCheck", "")
    
    MsgBox(0, "Test", ControlCommand($sDialogTitle, $sDialogText, $sControlUseBillTemplate, "IsChecked", ""))
EndIf

 

Adam

 

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