AmicusLinguae

ControlCommand works sometimes and sometimes not

22 posts in this topic

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)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Phrase: 

 

Using CheckboxTool.au3 also ran without @error equal to zero.

 

Must be:

Using CheckboxTool.au3 also ran without @error not equal to zero.

Share this post


Link to post
Share on other sites

What is the name of the Window you are trying to read the checkboxes with?  Is it a third party application, browser or something else?

Share this post


Link to post
Share on other sites

AmicusLinguae,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

@Subz

The name of the window is "Artikel bearbeiten" . It is a "lexware premium" software.

What could I do to solve this problem?

AL

Share this post


Link to post
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)

 

Share this post


Link to post
Share on other sites

I tried this, what you sent me. But the command "WinWaitActive" doesnot activate the window "Artikel bearbeiten" also if click on the  window and it in an endless loop.

What could I do?

Share this post


Link to post
Share on other sites

Replace WinWaitActive with _WinWaitActivate (I believe this is a custom function you have).  I'm not sure what you mean by an endless loop as the function isn't in a loop.

Share this post


Link to post
Share on other sites

#10 ·  Posted

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

Share this post


Link to post
Share on other sites

#12 ·  Posted

Sorry, too early in joy. After trying the above solution in the stand alone programm, I tryed it in my grater programm, there it did work two times correctly. After that it also did not work in the stand alone program any more.

 

What can I do?

Share this post


Link to post
Share on other sites

#13 ·  Posted

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)

Share this post


Link to post
Share on other sites

#14 ·  Posted

I found out that the ClassnameNN and other Properties changed. Therefore I cannot check the correct checkbox. 

 

Does anybody know which Property does not change when a new window of "Artikel bearbeiten" is opened?

 

tia

 

AL

 

Share this post


Link to post
Share on other sites

#15 ·  Posted

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

Share this post


Link to post
Share on other sites

#16 ·  Posted

Can you use the Au3Info tool to hover the Checkbox and send through a screenshot?

Share this post


Link to post
Share on other sites

#17 ·  Posted

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

Share this post


Link to post
Share on other sites

#18 ·  Posted

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

 

Share this post


Link to post
Share on other sites

#19 ·  Posted

Thank you @Subz, I will try you first solution.

Share this post


Link to post
Share on other sites

#20 ·  Posted

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?

Share this post


Link to post
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