Jump to content

ControlCommand + IsChecked PROBLEM


Recommended Posts

Hi all,

I'm new here and I have a few problems. Today I started playing with this program and it seems to me just amazing.

But I have a problem. I've done some tests, everything is super, it works. Maybe not perfectly but substantial time to debug function. Example:

run("c:\windows\system32\SystemPropertiesRemote.exe")
; cakat na okno
While not WinActive("System Properties", "Remote" )
    WinActivate("System Properties", "Remote")
WEnd
ControlClick("System Properties", "", "[CLASS:Button; INSTANCE:2]"); Allow Remote Assistance connection to this computer
ProcessWait("System Properties", "1")
ControlClick("System Properties", "", "[CLASS:Button; INSTANCE:9]")

run("c:\windows\system32\SystemPropertiesAdvanced.exe")
; cakat na okno
While not WinActive("System Properties", "Advanced" )
    WinActivate("System Properties", "Advanced")
WEnd
ControlClick("System Properties", "", "[CLASS:Button; INSTANCE:6]")
; cakat na okno
While not WinActive("Startup and Recovery", "System startup" )
    WinActivate("Startup and Recovery", "System startup")
WEnd
ControlClick("Startup and Recovery", "", "[CLASS:Button; INSTANCE:6]"); Automatically restart
ProcessWait("Startup and Recovery", "1")
ControlClick("Startup and Recovery", "", "[CLASS:Button; INSTANCE:9]")
ProcessWait("System Properties", "1")
ControlClick("System Properties", "", "[CLASS:Button; INSTANCE:8]")
MsgBox(0, @Scriptname, "Skript ukončený, okno sa zavrie samé o 5 sekúnd", 5)

But, I need to do to me if it's checked box is checked or not, if yes to tick off, if not, continue.

run("c:\windows\system32\SystemPropertiesRemote.exe")
; cakat na okno
While not WinActive("System Properties", "Remote" )
    WinActivate("System Properties", "Remote")
WEnd
If ControlCommand("System Properties", "Button2", "IsChecked","") Then
    MsgBox(0, "", "not checked")
Else
    MsgBox(0, "", "checked")
EndIf

And this would seem to me the result.

run("c:\windows\system32\SystemPropertiesRemote.exe")
; cakat na okno
While not WinActive("System Properties", "Remote" )
    WinActivate("System Properties", "Remote")
WEnd
If ControlCommand("System Properties", "Button2", "IsChecked","")=1 Then
    ProcessWait("System Properties", "1")
    ControlClick("System Properties", "", "[CLASS:Button; INSTANCE:9]")
Else
    ControlCommand("System Properties", "Button2", "Check","")
    ProcessWait("System Properties", "1")
    ControlClick("System Properties", "", "[CLASS:Button; INSTANCE:9]")
EndIf

Please, help me.

Thank you all for answers

Link to comment
Share on other sites

This code works fine for me. The If statement was logically incorrect, so I changed it. That wouldn't have made it not work, just display the message wrong.

run("c:\windows\system32\SystemPropertiesRemote.exe")
; cakat na okno
While not WinActive("System Properties", "Remote" )
    WinActivate("System Properties", "Remote")
WEnd
If ControlCommand("System Properties", "", "Button2", "IsChecked") Then
    MsgBox(0, "", "checked")
Else
    MsgBox(0, "", "not checked")
EndIf

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

  • 8 months later...

I am having the same problem with "IsChecked" ControlCommand()

What I am trying to do is check the status of a check box if it is checked then uncheck it and move on. But my code below is not working. Any input or suggestion are very much appreciated. Thx

if(ControlCommand("Open File", "", "WindowsForms10.BUTTON.app.0.2b89eaa3", "IsChecked"))

{

ControlClick("Open File", "", "WindowsForms10.BUTTON.app.0.2b89eaa3", "left");

}else {print("Check box func is not workingn");}

Link to comment
Share on other sites

Try using AutoIt to do it? That code isn't AutoIt3 syntax.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Yes you're right, the code above is Perl syntax since I need to use perl as an intermediate medium. For that purpose I have defined an autoIt3 object in Perl as Au3 below. With this I was able to interact with many Autoit3 controls, except the ControlCommand with "IsChecked" & "UnCheck" cmds.

my $Au3 = Win32::OLE->new("AutoItX3.Control");

the actual code is as below:

if($Au3->ControlCommand("Open File", "", "WindowsForms10.BUTTON.app.0.2b89eaa3", "IsChecked"))

{

$Au3->ControlClick("Open File", "", "WindowsForms10.BUTTON.app.0.2b89eaa3", "left");

}else {print("Check box func is not workingn");}

I got the "Checked" cmd working OK with the exact syntax above thus I am sure the syntax is not an issue here. The problem is I need the "UnCheck" or "IsChecked" cmd and I can't get them to work. Any other suggestion? thx

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