Jump to content

What exactly is CLASSNN?


Recommended Posts

Hi!

Here's what the help file has to say:

  • CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"

So can someone explain what exactly does ClassNN hold or give pointers to some developer documentation please?

At a very high level, I understand that If there are 10 buttons on the screen, ClassNN is probably gonna show "Button1", "Button2" and so on. But what is the underlying mapping here?  What field of the Windows Control is used (if at all?).

Where I'm getting at...I would like to somehow tweak my application source code so that I can get custom ClassNN values. It would be great to have "Button<<Name>>" instead of "Button1".

I posted a  variant of this question on the MSDN forums and the answer was that I need to implement UIAutomation COM classes or proxies, but I was just hoping there is something simpler than that. If I can find out how AutoIT works, then it could possibly help.

Any help is much appreciated!

Link to comment
Share on other sites

  • Moderators

tester123,

As far as I know, [CLASSNN:Edit1] is just a shorthand version of [CLASS:Edit;INSTANCE:1] - that is how I have always seen it when displayed in the AutoIt Window tool. No doubt it was kept on for legacy compatibility reasons. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks Melba. Yes, that makes perfect sense. In your example, it is the first instance of Edit.

So that leads to the next question :) How do you retrieve values without using the "nth" instance of something.

Here's a simple example: If i run Scenario 1, i get 10 "Static" results. For Scenario 2, I get only 5. For scenario 3, I get 7, and so on.

Lets say the "Answer" is in..

[CLASS:Static;INSTANCE:7] ,

[CLASS:Static;INSTANCE:4]

[CLASS:Static;INSTANCE:5], etc...

Now my scripts needs to be generic to pick up a particular value which could be the "7th" instance in Scenario 1 and the "4th" instance in Scenario 2. So I cant rely on the instance :(

Surely, i'm not the only one in this situation :D So what would you do in this case?

IF my application source code could somehow identify it as as [CLASS:Static; INSTANCE: <<unique id/name>>], then it'll be easy to retrieve the value.

Edited by tester123
Link to comment
Share on other sites

Thanks John. Sorry, probably I wasnt clear with my question.. it is not about passing a dynamic value..

It is about calling out a field with a unique name..Lets say I have a hundred scenarios and I have this static field which contains my answer and that answer could be any instance since it depends on the scenario being executed... I would like retrieve it with a name instead of a number...

Example: Lets say i want to retrieve the value of the "Operating System" field of a page in wikipedia..

If you go to the AutoIT page in Wiki, OS is the 4th element..

If you go to the Ruby page in Wiki, OS is the 10th element..

In my script, I would like to get the value of the "OS" field.. Now i cant say pick up the 4th element because on the Ruby page, the 4th element is "Developer"..

Ofcourse, one option would be to use "text" instead of the position of the element...but lets say i dont have the text (cases where there are no headers)..

If I had control over the wikipage i could set a "hook" for the OS field..and then use it to retrieve the value..

Btw, this is just to help explain my problem.. I'm using standard windows controls and not websites :)

Edited by tester123
Link to comment
Share on other sites

I'm unsure what you mean by your scenarios, but I think you can use the control text as an Identifier.

A special description can be used as the controlID parameter used in most of the Control...() functions . This description can be used to identify a control by the following properties:

  • ID - The internal 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. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID
  • TEXT - The text on a control, for example "&Next" on a button
  • CLASS - The internal control classname such as "Edit" or "Button"
  • CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"
  • NAME - The internal .NET Framework WinForms name (if available)
  • REGEXPCLASS - Control classname using a regular expression
  • X Y W H - The position and size of a control.
  • INSTANCE - The 1-based instance when all given properties match. 

 

  •  

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Thanks again!  But like i said i'm in a spot where I cant use the text as well.. :(

2 reasons why.. i) Due to overlapping screens, there are buttons with "duplicate" names... so when i output all screen elements, i would have something like this

CLASSNN: Button1, Text: Add, CLASSNN: Button15, Text: Add

ii) Static fields without headers

We dont use Winforms either, so that rules out using the "Name" param

P.S: I know that this question is not on the AutoIT side, but on the application source code side. I'm just wondering if there are folks here who have faced a similar issue :(

Edited by tester123
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...