Jump to content

Control ID not constant


 Share

Recommended Posts

Hi

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.

Many thanks

J-F

Link to comment
Share on other sites

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 :D

thanks

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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.

:D

Link to comment
Share on other sites

  • 1 month later...

I've just run into the same problem and I'm a bit confused cause the AutoIt Helpo file says

Control ID

The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls.

But if the number of the Control ID changes everytime a certain window is generated how can this be the best way to identify a control?

And how do I access a control using it's Classname? I planned on using

ControlClick ("Filter", "", 262786)

to open a pulldown menu but like I said before the Control-ID changes everytime. The classname of said control is 'TxcButtonEdit1', so how do I do a left-click on it? Thanks!

Link to comment
Share on other sites

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?

Edited by Moon
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

I hope I have helped you progress.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

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:

Posted Image

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?

Edited by Moon
Link to comment
Share on other sites

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

$pos = ControlGetPos("Untitled - Notepad", "", "Edit1").

So how come this just does not work?

Link to comment
Share on other sites

  • Moderators

TcxCustomInnerTextEdit is a Delphi app control:

Note: AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Well, I've been experimenting for a few days now :P

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.

Link to comment
Share on other sites

  • Moderators

Well, I've been experimenting for a few days now :P

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.

Never mind, I found it quickly...

http://www.autoitscript.com/forum/index.ph...st&p=218527

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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.

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.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

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

Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")

?

Edited by Moon
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...