Jump to content

Recommended Posts

Posted

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)

Posted

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

  • Moderators
Posted

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:

  Reveal hidden contents

 

Posted

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)

 

Posted

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?

Posted

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.

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

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?

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)

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

 

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

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

 

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?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...