Sign in to follow this  
Followers 0
Lococobra

Annoying controls

11 posts in this topic

I'm hoping someone else has come across this and might have some ideas for me, but I've done a lot of searching and so far no dice.

I have a program that I write a pretty big automation utility for. New updates are released on a weekly/bi-weekly basis to that program. Every time there's an update, all of the control IDs and ClassNNs change at random. Does anyone have a better way of getting those new IDs than to manually go through the program every update with the window info tool?

I've been trying some stuff with WinList, but it doesn't really seem to be that helpful. Any ideas?

Share this post


Link to post
Share on other sites



Look at the other options you have in the help file for advanced specification of controls. Think about how do you recognize the control manually (X/Y position, text, etc.)? Then search for those attributes.

;)


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

Share this post


Link to post
Share on other sites

Mostly that stuff won't work because not all of the controls have text and the positions may change from version to version. It may be better than the way I'm doing it now though.

How do I get a control by position though? I've tried for example...

$text = ControlGetText($hWnd, '', '[X:564; Y:208]')

But it always throws an error "no window matches the criteria". I'm sure those are the right coordinates and it works if I use something else (ClassNN, ID, Text, etc...) to find the control..

Share this post


Link to post
Share on other sites

I have no idea if this'll work, but try this: $text = ControlGetText($hWnd, '', '564, 208')


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

Share this post


Link to post
Share on other sites

No that wouldn't work. I tried it just to be sure though and it didn't.

Share this post


Link to post
Share on other sites

Mostly that stuff won't work because not all of the controls have text and the positions may change from version to version. It may be better than the way I'm doing it now though.

How do I get a control by position though? I've tried for example...

$text = ControlGetText($hWnd, '', '[X:564; Y:208]')

But it always throws an error "no window matches the criteria". I'm sure those are the right coordinates and it works if I use something else (ClassNN, ID, Text, etc...) to find the control..

You got the right syntax, how did you set $hWnd?

And what are the coordinates relative to? Should be Window Client Area, not screen coords.

;)


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

Share this post


Link to post
Share on other sites

Yeah, as I said if I try to access the controls by any other means (other than coordinates) then it works.

Here's some sample code to show what I mean...

CODE:
$text1 = ControlGetText($hWnd, '', '[ID:84]')
$pos = ControlGetPos($hWnd, '', '[ID:84]')
$text2 = ControlGetText($hWnd, '', '[X:'&$pos[0]&'; Y:'&$pos[1]&']')
MsgBox(0,'',$text1&' : ('&$pos[0]&', '&$pos[1]&') : '&$text2)

OUTPUT:
Start : (564, 208) :

$text2 never gets filled because of the error.

Share this post


Link to post
Share on other sites

I don't understand the error. Are you running the current version of AutoIt? This demo works for me:

#include <GuiConstantsEx.au3>

Global $hGUI, $ctrlButton, $aPos, $sText1, $sText2

$hGUI = GUICreate("Test", 300, 200)
$ctrlButton = GUICtrlCreateButton("Start", 100, 150, 100, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ctrlButton
            $sText1 = ControlGetText($hGUI, "", $ctrlButton)
            $aPos = ControlGetPos($hGUI, "", $ctrlButton)
            $sText2 = ControlGetText($hGUI, "", "[X:" & $aPos[0] & "; Y:" & $aPos[1] & "]")
            ConsoleWrite("$sText1  = " & $sText1 & @LF & _
                "$aPos = " & $aPos[0] & "," & $aPos[1] & @LF & _
                "$sText2 = " & $sText2 & @LF & @LF)
    EndSwitch
WEnd

;)


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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Very strange. Your code works fine and seems to do exactly what I'm doing. Even weirder is that I just tried it with specifying the width/height of the same control and that actually worked fine. I can't think of any reason my code isn't working except that maybe the position isn't being polled correctly. I don't have any other tool other than the window info tool or ControlGetPos, but I'm pretty sure those both work the same way.

I'm all out of ideas :[

EDIT:

I tried my exact code with a different control (from a different program) and it worked. I guess I'm just SOL.

Edited by Lococobra

Share this post


Link to post
Share on other sites

There are other, less common issues that might arise. Like some GUIs having multiple controls layered in a z-order, with some transparent or disabled\hidden as required. I ran into one installer where all the controls used for all the GUI presentations were created at once, and then just hidden\shown as required during the course of the install.

BTW, you didn't say what version of AutoIt you were using. If it's not 3.3.2.0, then you need to try it with the current production version.

;)


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

Share this post


Link to post
Share on other sites

Yeah, I wasn't using the updated version but I updated and tried it and there was no difference. I've had trouble with these controls before, they have classes like "ThunderRT6CommandButton" and I think I read on other threads that other people had trouble with them too. You have to do some crazy stuff to click on them for example. The only way I've been able to simulate a click on one of those buttons is to first focus the control then send it an enter key.

About the possibility that the controls are layered, it's possible but then shouldn't it still pick up at least one of them?

I've resigned to just using the text where possible and manually grab the rest of them.

Share this post


Link to post
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
Sign in to follow this  
Followers 0