trunc.ate Posted January 23, 2004 Share Posted January 23, 2004 Can someone advise me how to use ControlCommand? I am trying to test wether a checkbox in an application is enabled. I'm not quite sure how to use ControlCommand and it's parameters correctly and if it's really intended for my purpose. AutoItSetOption ( "WinTitleMatchMode", 2 ) WinActivate ( "HTTPort 3.SNFM" ) WinWaitActive("HTTPort 3.SNFM") ControlCommand("HTTPort 3.SNFM", "Proxy requires authentication", "", "Check", "" ) The intended Control gets the focus but that's it, no toggling. Link to comment Share on other sites More sharing options...
trids Posted January 23, 2004 Share Posted January 23, 2004 Call this function .. (use 0 for Black, or use your AutoitSpy for custom colo(u)rs) Func CheckBox($pX1, $pX2, $pY1, $pY2, $pOnColor, $pState) ;This function scans the pixels in the given range, ;and if the $pColor value is found then does nothing (since it is ALREADY "on") ;otherwise it sends a mouseclick event to the middle of the range ;Set coordinates relative to active window AutoItSetOption("MouseCoordMode", 0) ;0 = relative coords to the active window AutoItSetOption("PixelCoordMode", 0) ;0 = relative coords to the active window ;Ignore mouse wanderings BlockInput(1) ;See if the On-Color can be found $aXY = PixelSearch($pX1, $pY1, $pX2, $pY2, $pOnColor) If @error = 1 then ;pOnColor WAS NOT found $ynChecked = 0 Else ;pOnColor WAS found $ynChecked = 1 EndIf If $ynChecked = $pState then ;Do nothing, since the required state matches the current status Else ;Send the mouse to click the topleft coords MouseClick( "left" ,$pX1 ,$pY1 ,1 ,0) Endif ;Back to normal BlockInput(0) Return EndFunc Link to comment Share on other sites More sharing options...
trids Posted January 23, 2004 Share Posted January 23, 2004 Btw: I had to use the function above for an install that used non-standard checkboxes, cos the regular method didn't work on it .. $sTitle = "Regional Settings Properties" WinWaitActive($sTitle) ControlCommand($sTitle, "", "Button1", "Check", "") Sleep(1500) ControlCommand($sTitle, "", "Button1", "UnCheck", "") Sleep(1500) Link to comment Share on other sites More sharing options...
trunc.ate Posted January 24, 2004 Author Share Posted January 24, 2004 Thanks for the workaround using the pixel color. But let's return for a moment to ControlCommand: I finally worked out how to make it function but have to admit that I'm still not sure how to set the parameters, expecially the need of the "text"-part. The help file tells us to use it like this:ControlCommand ( "title", "text", "classnameNN", "command" ,"option") Take Winamp for example. I want to open the File-Info Box and uncheck the ID3v2 Tag option. After the Send ("!fv") I get a box with the title "MPEG file info box + ID3 tag editor". I now search AU3_Spy for the text which is displayed beneath the checkbox. In this case I find "ID3v&2 Tag" in the section <Visible Window Text>. Additionally I would search AU3_spy for the Checkbox name and find "Button5". My ConctrolCommand would then be ControlCommand("MPEG file info box + ID3 tag editor", "ID3v&2 Tag", "Button5", "UnCheck", "") This works, but it also works when I leave out the "text" parameter, and it doesn't work when I leave it in and take out the "classnameNN"-parameter instead. Why is that? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 24, 2004 Developers Share Posted January 24, 2004 This is how I understand it works up till now..... The Title and Text fields are used to Identify the correct window. So text should contain a text that makes this particular window unique. If the window title is unique it will work without a value in the Text field to identify the correct window. The classnameNN parameter is the name of the control on the selected window which you want to Check/UnCheck. so thats always needed. By the way you can also use these commands to Check / uncheck checkboxes: ; to check ControlSend("MPEG file info box + ID3 tag editor", "ID3v&2 Tag", "Button5","{NUMPADADD}") ; to UnCheck ControlSend("MPEG file info box + ID3 tag editor", "ID3v&2 Tag", "Button5","{NUMPADSUB}") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
trunc.ate Posted January 24, 2004 Author Share Posted January 24, 2004 Ah, I see. So leaving out the Window Title works likewise if the text identifies the window sufficiently and so ControlCommand("", "ID3v&2 Tag", "Button5", "UnCheck", "") works, too. Thanks for clearing this up 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