Jump to content

ControlCommand works sometimes and sometimes not


Recommended Posts

Sorry difficult to test, I think your issue is that you need to give ControlCommand a value for example ischecked = 0 or 1, I found that using text had undesired effects, so went back to using Class and Instance, please double check the instances are correct.  I didn't know what the second instance for &Aktualisierung der Kalkulationsvorgaben übernehmen was so just used 21, hope that makes sense

$hWnd = _WinWaitActivate("Artikel bearbeiten","Serien-/Chargennu&mm")
;~ &Gewinn bei Verkaufspreisänderung aktualisieren
If ControlGetText ($hWnd, "", '[CLASS:Button; INSTANCE:14]') = '&Gewinn bei Verkaufspreisänderung aktualisieren' Then
    If ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:14]", "IsChecked") = 0 Then
        ControlCommand($hWnd,"","[CLASS:Button; INSTANCE:14]", "Check")
    EndIf
ElseIf ControlGetText ($hWnd, "", '[CLASS:Button; INSTANCE:22]') = '&Gewinn bei Verkaufspreisänderung aktualisieren' Then
    If ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:22]", "IsChecked") = 0 Then
        ControlCommand($hWnd,"","[CLASS:Button; INSTANCE:22]", "Check")
    EndIf
EndIf

;~ &Aktualisierung der Kalkulationsvorgaben übernehmen
If ControlGetText ($hWnd, "", '[CLASS:Button; INSTANCE:21]') = '&Aktualisierung der Kalkulationsvorgaben übernehmen' Then
    If ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:21]", "IsChecked") = 1 Then
        ControlCommand($hWnd,"","[CLASS:Button; INSTANCE:21]", "UnCheck")
    EndIf
EndIf

 

Edited by Subz
Grammar
Link to comment
Share on other sites

Thank you @Subz

Your modified code worked, so I made it with the following code.

ConsoleWrite(@error & @CRLF)

#include <Au3Recorder_Functions.au3>
;Serien-/Chargennu&mm
;Serien-/Chargennu&mm

$hWnd = _WinWaitActivate("Artikel bearbeiten","Serien-/Chargennu&mm")
;~ &Gewinn bei Verkaufspreisänderung aktualisieren
If ControlGetText ($hWnd, "", '[CLASS:Button; INSTANCE:14]') = '&Gewinn bei Verkaufspreisänderung aktualisieren' Then
    If ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:14]", "IsChecked") = 0 Then
        ControlCommand($hWnd,"","[CLASS:Button; INSTANCE:14]", "Check")
    EndIf
ElseIf ControlGetText ($hWnd, "", '[CLASS:Button; INSTANCE:22]') = '&Gewinn bei Verkaufspreisänderung aktualisieren' Then
    If ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:22]", "IsChecked") = 0 Then
        ControlCommand($hWnd,"","[CLASS:Button; INSTANCE:22]", "Check")
    EndIf
EndIf

;~ &Aktualisierung der Kalkulationsvorgaben übernehmen
If ControlGetText ($hWnd, "", '[CLASS:Button; INSTANCE:13]') = '&Aktualisierung der Kalkulationsvorgaben übernehmen' Then
    If ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:13]", "IsChecked") = 1 Then
        ControlCommand($hWnd,"","[CLASS:Button; INSTANCE:13]", "UnCheck")
     EndIf
ElseIf ControlGetText ($hWnd, "", '[CLASS:Button; INSTANCE:21]') = '&Aktualisierung der Kalkulationsvorgaben übernehmen' Then
    If ControlCommand($hWnd, "", "[CLASS:Button; INSTANCE:21]", "IsChecked") = 1 Then
        ControlCommand($hWnd,"","[CLASS:Button; INSTANCE:21]", "UnCheck")
    EndIf

EndIf

 

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