Jump to content

[Solved]Is CheckBox flagged


Recommended Posts

I have a script that updates information in a given combo box.  Before that combo box can be edited a checkbox must be flagged.  I run into a problem if the check box is already flagged.  Is there a way for auto it to see if a checkbox is flagged then if it is not flag it and continue with the script or if it already flagged skip that step and continue with the script?

 

 

Edited by bremen
Solved
Link to comment
Share on other sites

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

That was just in Help file. Look first in Helpfile^^.

How to use:

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
Case $13
            If _IsChecked($13) Then
                _GUICtrlEdit_AppendText($Console,"Checked" & @CRLF)
            ElseIf Not _IsChecked($13) Then
                _GUICtrlEdit_AppendText($Console,"Unchecked" & @CRLF)
            EndIf

 

Edited by RaiNote
  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

It is named "Function GUICtrlCreateCheckbox" or just search for Checkbox it should be the first one^^

 

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

#include <Array.au3>
#include <Excel.au3>
#include <WinAPI.au3>






; opens excel workbook
;REST THE WORKBOOK FOR YOUR FILE PATH AND NAME
Local $oExcel = _ExcelBookOpen("C:\File Path \File.xls")
; reads data into array
$aArray1 = _ExcelReadSheetToArray($oExcel, 1, 1, 0, 2, True)
; closes the excel workbook
_ExcelBookClose($oExcel)
; displays the array that was read.
_ArrayDisplay($aArray1)
; counts the number of rows in the array
$rows = UBound($aArray1) -1



for $c = 1 to $rows
    



WinActivate("ACCESS - [Stock")
WinWaitActive("ACCESS - [Stock")
ControlClick("ACCESS - [Stock", "Part number:", 905, "left")
controlsend("ACCESS - [Stock", "Part number:", 905, $aArray1[$c][0])
send("{TAB}")
Sleep(700)



ControlCommand("ACCESS - [Stock","Part number","SysTabControl325","TabRight","")

Case $idCheckbox
If _IsChecked($idCheckbox)
Then
sleep(700)
ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
Sleep(700)
send("{TAB}")
Else
sleep(700)
ControlClick("ACCESS - [Stock", "Enable code", 2288, "left")
sleep(700)

sleep(700)
ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
Sleep(700)
send("{TAB}")
EndIf


ControlClick("ACCESS - [Stock", "Apply", 12321, "left")
Sleep(700)
Send("{ALT}f"&"n")

next

Here is my script  I am getting syntax errors for my $c = 1 to $rows and for the case $idcheckbox. 

 

I have search for the case $idcheckbox and got no results returned. 

Link to comment
Share on other sites

Some Functions undefined ^^ but

#include <Array.au3>
#include <Excel.au3>
#include <WinAPI.au3>






; opens excel workbook
;REST THE WORKBOOK FOR YOUR FILE PATH AND NAME
Local $oExcel = _ExcelBookOpen("C:\File Path \File.xls")
; reads data into array
$aArray1 = _ExcelReadSheetToArray($oExcel, 1, 1, 0, 2, True)
; closes the excel workbook
_ExcelBookClose($oExcel)
; displays the array that was read.
_ArrayDisplay($aArray1)
; counts the number of rows in the array
$rows = UBound($aArray1) - 1



For $c = 1 To $rows



    WinActivate("ACCESS - [Stock")
    WinWaitActive("ACCESS - [Stock")
    ControlClick("ACCESS - [Stock", "Part number:", 905, "left")
    ControlSend("ACCESS - [Stock", "Part number:", 905, $aArray1[$c][0])
    Send("{TAB}")
    Sleep(700)
Next


ControlCommand("ACCESS - [Stock", "Part number", "SysTabControl325", "TabRight", "")
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $idCheckbox
            If _IsChecked($idCheckbox) Then
                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            Else
                Sleep(700)
                ControlClick("ACCESS - [Stock", "Enable code", 2288, "left")
                Sleep(700)

                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            EndIf


            ControlClick("ACCESS - [Stock", "Apply", 12321, "left")
            Sleep(700)
            Send("{ALT}f" & "n")
    EndSwitch
WEnd
Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

Without GUI a bit complicated for me but that should work^^ without the Excel Funcs on my side(Haven't the Funcs)^^

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

Some Functions undefined ^^ but

#include <Array.au3>
#include <Excel.au3>
#include <WinAPI.au3>






; opens excel workbook
;REST THE WORKBOOK FOR YOUR FILE PATH AND NAME
Local $oExcel = _ExcelBookOpen("C:\File Path \File.xls")
; reads data into array
$aArray1 = _ExcelReadSheetToArray($oExcel, 1, 1, 0, 2, True)
; closes the excel workbook
_ExcelBookClose($oExcel)
; displays the array that was read.
_ArrayDisplay($aArray1)
; counts the number of rows in the array
$rows = UBound($aArray1) - 1



For $c = 1 To $rows



    WinActivate("ACCESS - [Stock")
    WinWaitActive("ACCESS - [Stock")
    ControlClick("ACCESS - [Stock", "Part number:", 905, "left")
    ControlSend("ACCESS - [Stock", "Part number:", 905, $aArray1[$c][0])
    Send("{TAB}")
    Sleep(700)
Next


ControlCommand("ACCESS - [Stock", "Part number", "SysTabControl325", "TabRight", "")
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $idCheckbox
            If _IsChecked($idCheckbox) Then
                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            Else
                Sleep(700)
                ControlClick("ACCESS - [Stock", "Enable code", 2288, "left")
                Sleep(700)

                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            EndIf


            ControlClick("ACCESS - [Stock", "Apply", 12321, "left")
            Sleep(700)
            Send("{ALT}f" & "n")
    EndSwitch
WEnd
Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

Without GUI a bit complicated for me but that should work^^ without the Excel Funcs on my side(Haven't the Funcs)^^

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

Some Functions undefined ^^ but

#include <Array.au3>
#include <Excel.au3>
#include <WinAPI.au3>






; opens excel workbook
;REST THE WORKBOOK FOR YOUR FILE PATH AND NAME
Local $oExcel = _ExcelBookOpen("C:\File Path \File.xls")
; reads data into array
$aArray1 = _ExcelReadSheetToArray($oExcel, 1, 1, 0, 2, True)
; closes the excel workbook
_ExcelBookClose($oExcel)
; displays the array that was read.
_ArrayDisplay($aArray1)
; counts the number of rows in the array
$rows = UBound($aArray1) - 1



For $c = 1 To $rows



    WinActivate("ACCESS - [Stock")
    WinWaitActive("ACCESS - [Stock")
    ControlClick("ACCESS - [Stock", "Part number:", 905, "left")
    ControlSend("ACCESS - [Stock", "Part number:", 905, $aArray1[$c][0])
    Send("{TAB}")
    Sleep(700)
Next


ControlCommand("ACCESS - [Stock", "Part number", "SysTabControl325", "TabRight", "")
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $idCheckbox
            If _IsChecked($idCheckbox) Then
                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            Else
                Sleep(700)
                ControlClick("ACCESS - [Stock", "Enable code", 2288, "left")
                Sleep(700)

                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            EndIf


            ControlClick("ACCESS - [Stock", "Apply", 12321, "left")
            Sleep(700)
            Send("{ALT}f" & "n")
    EndSwitch
WEnd
Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

Without GUI a bit complicated for me but that should work^^ without the Excel Funcs on my side(Haven't the Funcs)^^

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

You need to create a GUI^^ Like that :

#include <Array.au3>
#include <Excel.au3>
#include <WinAPI.au3>

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 117, 27, 192, 124)
$ThisIsTheCheckBoxID = GUICtrlCreateCheckbox("ThisIsTheCheckBoxID", 0, 0, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; opens excel workbook
;REST THE WORKBOOK FOR YOUR FILE PATH AND NAME
Local $oExcel = _ExcelBookOpen("C:\File Path \File.xls")
; reads data into array
$aArray1 = _ExcelReadSheetToArray($oExcel, 1, 1, 0, 2, True)
; closes the excel workbook
_ExcelBookClose($oExcel)
; displays the array that was read.
_ArrayDisplay($aArray1)
; counts the number of rows in the array
$rows = UBound($aArray1) - 1



For $c = 1 To $rows



    WinActivate("ACCESS - [Stock")
    WinWaitActive("ACCESS - [Stock")
    ControlClick("ACCESS - [Stock", "Part number:", 905, "left")
    ControlSend("ACCESS - [Stock", "Part number:", 905, $aArray1[$c][0])
    Send("{TAB}")
    Sleep(700)
Next


ControlCommand("ACCESS - [Stock", "Part number", "SysTabControl325", "TabRight", "")
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $ThisIsTheCheckBoxID
            If _IsChecked($ThisIsTheCheckBoxID) Then
                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            Else
                Sleep(700)
                ControlClick("ACCESS - [Stock", "Enable code", 2288, "left")
                Sleep(700)

                Sleep(700)
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "ShowDropDown")
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "SelectString", $aArray1[$c][1])
                ControlCommand("ACCESS - [Stock", "Code:", "ComboBox3", "HideDropDown")
                Sleep(700)
                Send("{TAB}")
            EndIf


            ControlClick("ACCESS - [Stock", "Apply", 12321, "left")
            Sleep(700)
            Send("{ALT}f" & "n")
    EndSwitch
WEnd
Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

 

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

So how u should see the ID of the Checkbox is just the $ThisIsTheCheckBoxID

You could also Name it The ID is the same like the Variable-ID :3

Edited by RaiNote
  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

  • Moderators

Bremen,

Looking at the code you posted, and seeing you need to use ControlCommand to action the combo, I assume this checkbox is actually in an external GUI along with the combo. if this indeed the case then you will need to use the same command with the "IsChecked" parameter to see if the checkbox is clicked or not - you get the checkbox ControlID in the same way as you identified the combo CID.

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

Perhaps i should clarify....  The program that this script will be interacting with has a control id of 2288 assigned to this particular checkbox.  I am interacting with a GUI that is already created. 

Link to comment
Share on other sites

If you would post the GUI it would may a bit easier and faster to attach the code with GUI ^-^. But also without you would only have to change the Control ID's^^

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

RaiNote.....

I am using a software with its own GUI.  I can not "attach the GUI". 

 

Melba23

I am trying to find where in the help file this would be documented as I do not understand how to use the "ischecked" function.  Can you please point me in the right direction? 

I have tried searching for " _IsChecked", "IsChecked", and "Checkbox" with no luck

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