Jump to content

Reading a check button.


Recommended Posts

Tried to read a check button using the following but the GUICtrlRead always returns a zero. Is this the wrong approach?

jh

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Func autoLogon()

Run("c:\WINDOWS\system32\cmd.exe /c control userpasswords2")

WinWait("User Accounts","")

$hWnd = WinGetHandle ("User Accounts")

Sleep(800)

$hCont = ControlGetHandle($hWnd, "", "Button1")

MsgBox(0, "User Accts should be open, handle = ", $hCont)

$result = GUICtrlRead($hCont)

MsgBox(0, "checkboxValue", $result)

EndFunc

Link to comment
Share on other sites

Functions starting with GUI is for GUICreate and its family and not for windows created by other applications.

controlID - The control identifier (controlID) as returned by a GUICtrlCreate... function.

Have you tried to use ControlGetText instead ?

Helpfile : AutoIt --> Function Reference --> Window Management --> Controls -> ...

Link to comment
Share on other sites

Tried to read a check button using the following but the GUICtrlRead always returns a zero. Is this the wrong approach?

jh

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Func autoLogon()

Run("c:\WINDOWS\system32\cmd.exe /c control userpasswords2")

WinWait("User Accounts","")

$hWnd = WinGetHandle ("User Accounts")

Sleep(800)

$hCont = ControlGetHandle($hWnd, "", "Button1")

MsgBox(0, "User Accts should be open, handle = ", $hCont)

$result = GUICtrlRead($hCont)

MsgBox(0, "checkboxValue", $result)

EndFunc

What I do to read a checkbox then check it if it is not already is:

If ControlCommand("Security for ROOT\CIMV2", "Allow Enable Account", "Button11", "IsChecked", "") = 0 Then
    ControlCommand("Security for ROOT\CIMV2", "Allow Enable Account", "Button11", "Check", "")
EndIf
Link to comment
Share on other sites

Tried to read a check button using the following but the GUICtrlRead always returns a zero. Is this the wrong approach?

Since your control is named "Button1", I'm assuming it's a radio button or checkbox, so this should work:

Func autoLogon()
    Run("c:\WINDOWS\system32\cmd.exe /c control userpasswords2")
    WinWait("User Accounts","")
    $result = ControlCommand("User Accounts", "", "Button1", "IsChecked")
    MsgBox(0, "checkboxValue", $result)
EndFunc

:shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Since your control is named "Button1", I'm assuming it's a radio button or checkbox, so this should work:

Func autoLogon()
    Run("c:\WINDOWS\system32\cmd.exe /c control userpasswords2")
    WinWait("User Accounts","")
    $result = ControlCommand("User Accounts", "", "Button1", "IsChecked")
    MsgBox(0, "checkboxValue", $result)
EndFunc

:shocked:

Sorry to bother folks, was just proceeding based on a reply to an earlier post. I just tried ControlCommand and was going to say Never Mind but you guys are too smart and too quick for us old farts.

jh

Link to comment
Share on other sites

Sorry to bother folks, was just proceeding based on a reply to an earlier post. I just tried ControlCommand and was going to say Never Mind but you guys are too smart and too quick for us old farts.

jh

Watch how you use phrases like "us old farts" on grey-bearded penguins, Kid!

:shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...