Control ID not constant

22 posts in this topic

J-F 0

My question is more for a discussion than trying to get a script done. I have a program that I need to test. We need to make some automatic tests and we are considering our options. The program is written in C#. So the control ID are always changing when you close and reopen the application. The ClassNameNN is constant though. I wonder if there is a way to create something that will use the controlID, even if it changes when reopening the program. Or should I try to use the ClassNameNN to replace the controlID? Or simply AutoIt is not suited for this.

Share this post

Link to post

Share on other sites

J-F 0

Wow, this is really nice. I will try it as soon as I finish the research on the UI program test available.

I think I will use autoIt anyway.

I was wondering, with this script, if you have a window with a Systreeview in it, and there is no controlID visible (using au3 window info) for the Tree and the ClassNameNN is for the window only, will it see the classnameNN or the controlID for the tree?

Because if it does, then my research is done and I will start coding the automated test using this script as a reference

thanks

Share this post

Link to post

Share on other sites

Champak 3

I am just running into this problem now too. And it is wierd, because it is ONLY happening on one of my child guis and not the main at all. So, how exactly do I use classname with "ControlHide" or "GUICtrlSetState"? I've been trying out combos for the last 20min. and can't get it to work.

Share this post

Link to post

Share on other sites

MHz 72

I am just running into this problem now too. And it is wierd, because it is ONLY happening on one of my child guis and not the main at all. So, how exactly do I use classname with "ControlHide" or "GUICtrlSetState"? I've been trying out combos for the last 20min. and can't get it to work.

ControlHide should accept a ClassnameNN OK, but whether a window ignores the action is their choice. So it may seem like ControlHide may not work at certain uses of it.

GUICtrlSetState is an (internal) function for handling AutoIt Gui. You should already have the handle returned from the controls creation to use that handle as the parameter.

Share this post

Link to post

Share on other sites

Moon 0

I've just tried this after verifying in Au3Info that the title used was correct and it did not work.

EDIT: I've read a lot of threads on ClassNameNN already and there seem to be a lot of people dealing with the same problem. How do I controlclick a control that has an ever changing Control ID and which does not respond to it's ClassName? Is there a function to read the Control ID from a control as AU3Info does? Or convert a ClassNameNN to a Control ID or vice versa?

Share this post

Link to post

Share on other sites

Moon 0

Thought about this too but since I don't know which screen resolution/window size people will be using, it'll be hard to find the coordinates of the control adding another layer of complexity. I'm also still wondering why my particular control cannot be manipulated by it's unique ClassNameNN.

Share this post

Link to post

Share on other sites

JSThePatriot 11

Thought about this too but since I don't know which screen resolution/window size people will be using, it'll be hard to find the coordinates of the control adding another layer of complexity. I'm also still wondering why my particular control cannot be manipulated by it's unique ClassNameNN.

It seems that you are wanting to use the ClassNameNN on a menu. It could be clicking anywhere on the menu, as it doesnt have to click at any certain spot. Hence the spot could be empty dead space. That being the case you will want to re-think your methods of accessing GUI menu's.

Share this post

Link to post

Share on other sites

Moon 0

It could be clicking anywhere on the menu, as it doesnt have to click at any certain spot. Hence the spot could be empty dead space.

OK, this is what the control looks like:

The left control with 'off' in it reads:

Control ID: 2163052

ClassNameNN: TcxCustomInnerTextEdit1

Text:

The right control with the down arrow (which is the one I wanna click) reads:

Control ID: 983694

ClassNameNN: TcxButtonEdit1

Text:

Now when I use the Control ID of the 'arrow' (as revealed by Au3Info) like this

ControlClick ("Filter", "", 983694)

the arrow IS clicked and the menu opens up offering checkboxes to select filters from. As the click on this arrow works perfectly fine I think it's safe to assume that there isn't any empty space in this menu.

What drives me crazy is that

ControlClick ("Filter", "", "TcxButtonEdit1")

does NOT open the menu and that there seems to be NO function in AutoIt to convert the ClassNameNN to the current Control ID or read the Control ID from the current window. Since Au3Info does exactly this and I also can get the ClassNameNNs by using WinGetClassList why can't I access this control by that very name from my script?

Share this post

Link to post

Share on other sites

Moon 0

Until someone with more knowledge of this scripting language than me (i.e. everyone around here) can verify that being unable to work with the ClassNameNN is a bug (or I'm just too stupid) I'm trying out some workarounds.

I've positioned the keyboard cursor on the pulldown menu by sending a number of TAB keystrokes. Unfortunately there's no keyboard combo I could use to open the menu like SHIFT-ARROW DOWN. So I used

$name=ControlGetFocus ("Filter")

and even though I completely omitted the Control ID, AutoIt returned 'TcxCustomInnerTextEdit1' which is correct.

Now when I use any combination of

$pos=ControlGetPos ("Filter","","TcxCustomInnerTextEdit1")

I do NOT get the control's coordinates. So I cannot position the mouse cursor 15 pixels to the right to click on the arrow down button.

Again I'm weirded out by the fact that the AutoIt Help does speak of using the Control ID in these functions but illustrates it's examples by using the ClassNameNN instead like

Share this post

Link to post

Share on other sites

Moon 0

Like I said, it weirds me out that I can use the functions with the Control ID or the 0x000123-handle without any problems. And since the Au3Info window DOES determine the Control ID even of such Delphi Controls I don't see any reason why I shouldn't be able to script em. All I need would be a function to read out the current Control ID and then take it from there.

Share this post

Link to post

Share on other sites

SmOke_N 199

Like I said, it weirds me out that I can use the functions with the Control ID or the 0x000123-handle without any problems. And since the Au3Info window DOES determine the Control ID even of such Delphi Controls I don't see any reason why I shouldn't be able to script em. All I need would be a function to read out the current Control ID and then take it from there.

I have a sneaky suspicion that's not all you would need....

But to satisfy your courisity, if you look for a UDF I made "_CtrlGetByPos", then if you know the x and y coords of the controls, then you could always get their ControlID's/ClassNamesNN/ or ControlHandles.

Share this post

Link to post

Share on other sites

Moon 0

does ControlGetHandle() return a handle from TcxCustomInnerTextEdit1 ?

Yes it does, but I'm running into the same problem here: I do have to use it on the Control ID.

$gethandle=ControlGetHandle("Filter" ,"", 132204)

which returns '0x0002046C' so I could use a ControlKlick on it to open the pulldown menu

ControlClick("Filter" ,"", 0x0002046C)

However, I cannot use

$gethandle=ControlGetHandle("Filter" ,"", "TcxCustomInnerTextEdit1")

to get the handle so it doesn't really help.

Did you try using the Send("{SPACE}") to make the menu open up? Once you hit the arrow that should allow you to press space to open it.

The only way to hit the arrow is to click on it with the mouse. I cannot reach it by TAB as I can do with the left part of the menu, the edit field. When I TAB into this and press space it does delete the current setting ('off' in my example) and nothing happens. Curiously enough, manually entering 'on' followed by ENTER in this edit field, does NOT turn on the filter, you gotta click on the arrow and then click on the checkbox in the menu that opens up to activate it.

Anyway, I've used yet another workaround to make it happen. Since the window gets resized to it's default setting every time it is opened (no matter to what size one has dragged it in between), I do a left-click on the coordinates of the arrow and it works. Of course I've run into another problem now.

I'm testing my script in a virtual machine on my computer at home since I do have a newer version of Office installed than is on the computer at work. Even so, my machine runs faster and I had to up the "SendKeyDelay" interval to make the computer at work keep up with the windows generated by the program in the process. So I was wondering, does Send ("{TAB 5}") have the same amount of delay in between presses as