naaloh Posted November 10, 2011 Posted November 10, 2011 Hello, everyone. I'm a new AutoIt user (switched recently from AutoHotkey becase it has more limitations and its syntax is very bad compared to AutoIt). Right now I'm trying to write a script which includes automating an application unfortunately written in Delphi. Even more unfortunately in the course of automation I need to have a radio button depressed. The problem here is to find out its current state - ControlCommand "IsChecked" always returns 1, so as far as I undertand, the only way I could determine the state is by detecting its appearance (the button changes color when depressed). How can I do that with AutoIt? Here is the piece of code for the the button from the Delphi form, just in case it might be helpful. object connbutton: TMyToolButton Left = 0 Top = 0 Width = 55 Height = 50 Hint = 'Connect/Disconnect to server' Caption = 'Connect' ImageIndex = 0 Images = ImageList2 Theme = Office2003Blue Transparent = True ShowHint = True TabOrder = 7 OnClick = connbuttonClick Layout = blGlyphTop Style = bsCheck end
rodent1 Posted November 10, 2011 Posted November 10, 2011 You only mentioned your attempt using ControlCommand. Did you try the function GuiCtrlSetData? Then if that fails, you can always bring up your app, find out how many tabs it takes to select your control, and then send it a space. Or maybe you can change the radiobutton caption from "Connect" to "&Connect" and send an alt-c?
naaloh Posted November 11, 2011 Author Posted November 11, 2011 (edited) You only mentioned your attempt using ControlCommand. Did you try the function GuiCtrlSetData?Have you even tried to read the description of GuiCtrlSetData? This function is for working with controls created by AutoIt scripts and has nothing to do with controls of other applications.Then if that fails, you can always bring up your app, find out how many tabs it takes to select your control, and then send it a space. Or maybe you can change the radiobutton caption from "Connect" to "&Connect" and send an alt-c?Would you mind telling me what on earth it has to do with my question? I don't need tabs, spaces, alts or cs to change the state of the control, ControlClick works just fine. The problem is, because it's a radio button, I need to know if it isn't already checked before I send the click (because it it is, it'll obviously become unchecked afterwards). BTW, this button cannot be reached by pressing tabs, they don't really work in that application. Edited November 11, 2011 by naaloh
Moderators Melba23 Posted November 11, 2011 Moderators Posted November 11, 2011 rodent1,GUICtrl* functions only work on AutoIt created controls. They need the ControlID returned from the appropriate GUICtrlCreate* function as the ID parameter. So they will be of absolutely no use with a third party app. naaloh,Delphi controls are notoriously hard to deal with as they seem not to be created by the standard API. In the past I have needed to use PixelGetColor to check the colour of the interior of the radio button. A bit clumsy but it has worked adequately. Is the app GUI of a fixed size with the radio always in the same position within it? If so, then the problem is trivial - if not, then it becomes a bit more difficult. Let me know and we can try and get you a solution. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
naaloh Posted November 11, 2011 Author Posted November 11, 2011 (edited) then you should try GUICtrlReadAnd you really should try reading the description of the functions you're suggesting to use Delphi controls are notoriously hard to deal with as they seem not to be created by the standard API. In the past I have needed to use PixelGetColor to check the colour of the interior of the radio button. A bit clumsy but it has worked adequately. Is the app GUI of a fixed size with the radio always in the same position within it? If so, then the problem is trivial - if not, then it becomes a bit more difficult. Let me know and we can try and get you a solution. M23I think PixelChecksum that I discovered today will be most suitable for my needs, as it can check the whole button area rather than just one pixel. As far as I can tell, the position of the button inside the window doesn't change, but even if it did, I could always retrieve the coordinates via ControlGetPos. The problem, however, is that PixelChecksum seems to include the mouse pointer in the image it calculates checksum for. Can I temporarily hide the mouse pointer with AutoIt? Edited November 11, 2011 by naaloh
Moderators Melba23 Posted November 11, 2011 Moderators Posted November 11, 2011 naaloh,PixelCheckSum will work just as well as PixelGetColor - I very nearly mentioned it earlier. Just make sure that nothing else within the area you are using changes colour at any time. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
naaloh Posted November 11, 2011 Author Posted November 11, 2011 Just make sure that nothing else within the area you are using changes colour at any time. Like what might it be? BTW, it turned out there were no need to worry about mouse pointer, it looks like it's ignored when the hwnd parameter is specified. Here's the sample script which displays decimal CRC of the control AutoItSetOption ("PixelCoordMode", 0) $hwnd = WinGetHandle ("Alt.Binz") $ConPos = ControlGetPos($hwnd, "", "TMyToolButton13") $CRC = PixelChecksum($ConPos[0], $ConPos[1], $ConPos[0]+$ConPos[2]-1, $ConPos[1]+$ConPos[3]-1, 1, $hwnd, 1) MsgBox(0, "CRC", "CRC is "&$CRC)
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