hmsSurprise Posted April 5, 2007 Share Posted April 5, 2007 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 More sharing options...
Helge Posted April 5, 2007 Share Posted April 5, 2007 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 More sharing options...
mattw112 Posted April 5, 2007 Share Posted April 5, 2007 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 More sharing options...
PsaltyDS Posted April 5, 2007 Share Posted April 5, 2007 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 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 More sharing options...
hmsSurprise Posted April 5, 2007 Author Share Posted April 5, 2007 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 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 More sharing options...
PsaltyDS Posted April 5, 2007 Share Posted April 5, 2007 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.jhWatch how you use phrases like "us old farts" on grey-bearded penguins, Kid! 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 More sharing options...
hmsSurprise Posted April 5, 2007 Author Share Posted April 5, 2007 Watch how you use phrases like "us old farts" on grey-bearded penguins, Kid! I didn't know they had beards. Those must be the really old ones.... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now