Jump to content

ControlCommand works sometimes and sometimes not


Recommended Posts

Hello,

I'm a newcommer to this forum. The following script does sometimes work and sometimes not. It should uncheck the check box of Button21 and check the check box of Button22.

I tested this firstly in a separat testfile, where it worked correctly. Then I included the script in a greater au3.-script, where it didn't work. Then I tested the separate testfile and there it did not  work. I found that the @error variable was 1.

Could you pleas help me?

tia

Regards

 

_WinWaitActivate("Artikel bearbeiten","Serien-/Chargennu&mm")
 If  (ControlCommand("Artikel bearbeiten","","[CLASSNN:Button21]", "IsChecked") )Then
    ConsoleWrite(@error&@CRLF)
       ControlCommand("Artikel bearbeiten","","[CLASSNN:Button21]","Uncheck")
EndIf
ConsoleWrite(@error&@CRLF)

Sleep(2000)
;#cs
_WinWaitActivate("Artikel bearbeiten","Serien-/Chargennu&mm")
ConsoleWrite(ControlCommand("Artikel bearbeiten","","[CLASSNN:Button22]", "IsChecked"))
 If Not ControlCommand("Artikel bearbeiten","","[CLASSNN:Button22]", "IsChecked") Then
       ControlCommand("Artikel bearbeiten","","[CLASSNN:Button22]", "Check")
EndIf

ConsoleWrite(@error&@CRLF)

Link to comment
Share on other sites

Hello,

I tried to use the following scripts. The console output is the following:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Andreas\AutoIt\Work\Test_Checkbox_002.au3"    
Test1Test2Tool pree: 0
Tool past: 1
"C:\Andreas\AutoIt\Work\CheckboxTool.au3" (89) : ==> Subscript used on non-accessible variable.:
$rgblBaseline = GetColorAsRGBL($rectControl[0]+$posX,$rectControl[1]+$posY)
$rgblBaseline = GetColorAsRGBL($rectControl^ ERROR
>Exit code: 1    Time: 0.5946

So ther must be an error when executing CheckboxTool.au3

lines: 77-79

ConsoleWrite("Tool pree: "&@error&@CRLF)
$rectControl = ControlGetPos($strWindowTitle, $strWindowText, $strCheckboxId)
 ConsoleWrite("Tool past: "&@error&@CRLF)
 

Using CheckboxTool.au3 also ran without @error equal to zero. But the result of the the CheckboxIsChecked($strWindowTitle, $strWindowText, $strCheckboxId) Function was always the same if the checkbox was checkt or not.

But now there is the mentiones error caused by line 78.

 

What can I do to check if the checkbox is checked?

 

tia

Regards

Test_Checkbox_002.au3

Link to comment
Share on other sites

  • Moderators

AmicusLinguae,

Stick to just the one thread please - I have deleted the others.

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

Sorry don't know the software can you try this:

$hWnd = WinWaitActive("Artikel bearbeiten","Serien-/Chargennu&mm")
 If ControlCommand($hWnd, "", "Button21", "IsChecked") Then
    ConsoleWrite(@error & @CRLF)
    ControlCommand($hWnd,"","Button21", "Uncheck")
EndIf
ConsoleWrite(@error&@CRLF)

Sleep(2000)
;#cs
WinWaitActive($hWnd ,"Serien-/Chargennu&mm")
ConsoleWrite(ControlCommand($hWnd, "", "Button22", "IsChecked") & @CRLF)
If Not ControlCommand($hWnd, "", "Button22", "IsChecked") Then
    ControlCommand($hWnd, "", "Button22", "Check")
EndIf
ConsoleWrite(@error&@CRLF)

 

Link to comment
Share on other sites

Thank you Subz.

I made it the following way: using:  Au3Recorder_Functions.au3

#include <Au3Recorder_Functions.au3>
 

ConsoleWrite(@error & @CRLF)

 

$hWnd = _WinWaitActivate("Artikel bearbeiten","",10)
 If ControlCommand($hWnd, "", "Button21", "IsChecked") Then
    ConsoleWrite(@error & @CRLF)
    ControlCommand($hWnd,"","Button21", "Uncheck")
EndIf
ConsoleWrite(@error&@CRLF)

;Sleep(2000)
;#cs
_WinWaitActivate($hWnd ,"Serien-/Chargennu&mm")
ConsoleWrite(ControlCommand($hWnd, "", "Button22", "IsChecked") & @CRLF)
If Not ControlCommand($hWnd, "", "Button22", "IsChecked") Then
    ControlCommand($hWnd, "", "Button22", "Check")
EndIf
ConsoleWrite(@error&@CRLF)

Au3Recorder_Functions.au3

Link to comment
Share on other sites

Thank you Subz.

I made it the following way: using:  Au3Recorder_Functions.au3

#include <Au3Recorder_Functions.au3>
 

ConsoleWrite(@error & @CRLF)

 

$hWnd = _WinWaitActivate("Artikel bearbeiten","",10)
 If ControlCommand($hWnd, "", "Button21", "IsChecked") Then
    ConsoleWrite(@error & @CRLF)
    ControlCommand($hWnd,"","Button21", "Uncheck")
EndIf
ConsoleWrite(@error&@CRLF)

;Sleep(2000)
;#cs
_WinWaitActivate($hWnd ,"Serien-/Chargennu&mm")
ConsoleWrite(ControlCommand($hWnd, "", "Button22", "IsChecked") & @CRLF)
If Not ControlCommand($hWnd, "", "Button22", "IsChecked") Then
    ControlCommand($hWnd, "", "Button22", "Check")
EndIf
ConsoleWrite(@error&@CRLF)

Link to comment
Share on other sites

I found out that not every time I open the window "Artikel bearbeitet" the button number changes from 14 to 22 and  vice versa (may be also some other values which I have not tested till now).

So I cannot predict if it is changed or not. How can I predict the button number without AutoIt_Info.exe

Link to comment
Share on other sites

Using the Au3Info I found out, that the ClassnameNN is mostly "Button14" sometimes "Buttton22" I have a kind of wizard, which opens a window for a database.

This wizard opens a new dataset out of a displayed list. If I advance in this list the ClassnameNN is "Button14", if I go back is sometimes "Button22".

What could I do?

 

ScreeShots_Au3Info.doc

ScreeShots_Au3Info.pdf

Link to comment
Share on other sites

So look for unique identifiers for example is the text of the button unique, then use  ControlCommand($hWnd, "Text of Button Here", "", "IsChecked") or if one fails you could check the other instance for example:

If Not ControlCommand($hWnd, "", "Button22", "IsChecked") Then
    ControlCommand($hWnd, "", "Button22", "Check")
    If @error = 1 Then
        If Not ControlCommand($hWnd, "", "Button14", "IsChecked") Then
            ControlCommand($hWnd, "", "Button14", "Check")
        Endif
    Endif
EndIf

 

Link to comment
Share on other sites

I have two checkboxes first's text is 

"&Aktualisierung der Kalkulationsvorgaben übernehmen"

and second's text is 

"&Gewinn bei Verkaufspreisänderung aktualisieren"

 

and I use the following code

 

$hWnd = _WinWaitActivate("Artikel bearbeiten","Serien-/Chargennu&mm")
;#cs
If ControlCommand($hWnd, "&Aktualisierung der Kalkulationsvorgaben übernehmen", "", "IsChecked") Then
    ConsoleWrite(@error & @CRLF)
    ControlCommand($hWnd,"&Aktualisierung der Kalkulationsvorgaben übernehmen","", "Uncheck")
EndIf
ConsoleWrite(@error&@CRLF)

1. If both checkboxes are unchecked, they stay unchecked.

2. If both checkboxes are check, the first stays checked and the seconde becomes unchecked.

 I cannot understad this, even if the second button's text is not mentioned in the script the second button is affected.

3. If the first button is checked and the second button ist unchecked,  both checkboxes stay in their condition.

4. If the first button is unchecked and the second button is checked,  both checkboxes stay in their condition.

 

What could I do  to receive that the first button is not checked and the second button is not affected for all  (1.-4.) conditions?

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