Jump to content
Sign in to follow this  
vish2503

Dynamic IDs, Handles and Instances - Urgent

Recommended Posts

vish2503

post-44743-1231455516_thumb.jpg

Hi I just started Automating one of my apps with Autoit. Snapshot attached.

1. For all the controls, IDs, Handles and sometimes instances are also generated dynamically.

2. Pls refer screen shot: For Ex: In the upper editor window, if I have only one New Document tab, the Instance value is 3. However, if I have more than 1 New Document tabs, the Instance number changes. Pls see below for the AutoInfo Text for the Control.

3. My main issue is that I am unable to read anything from both upper and lower editor windows. I have tried using both, ControlGetText and _GUICtrlEdit_GetText by passing the right parameters. All I get is "tern1" as shown in the AutoInfo text window. No matter what I am unable to read the text typed in Text Editors. I can only use ControlSend to send my text to the Editors.

Few scenarios that I plan to automate are: Creation of mutiple New Documents tabs, Read Text from the Editor, Manipulate text in the editor. How to handle the dynamic IDs.

NOTE: THe application is developed using MS Techologies, C# and .NET. This main window of the application is Document Manager window.

Pls Help. Thanks a bunch in advance.

When Multiple New Documents TAB

Class: WindowsForms10.window.8.app.0.129c866

Instance: 19

ClassnameNN: WindowsForms10.window.8.app.0.129c86619

Advanced (Class): [CLASS:WindowsForms10.window.8.app.0.129c866; INSTANCE:19]

ID: 12453402

Text: tern1

Position: 169, 157

Size: 595, 230

ControlClick Coords: 171, 63

Style: 0x56010000

ExStyle: 0x00000000

Handle: 0x00BE061A

When Single New Document TAB

Class: WindowsForms10.window.8.app.0.129c866

Instance: 9

ClassnameNN: WindowsForms10.window.8.app.0.129c8669

Advanced (Class): [CLASS:WindowsForms10.window.8.app.0.129c866; INSTANCE:9]

ID: 12453402

Text: tern1

Position: 169, 157

Size: 595, 230

ControlClick Coords: 247, 82

Style: 0x56010000

ExStyle: 0x00000000

Handle: 0x00BE061A

Share this post


Link to post
Share on other sites
Pain

Can you show the "correct" parameters you tried with?

If ControlSend works ControlGetText should work to.

If this work

ControlSend("NewsPlex", "", "WindowsForms10.window.8.app.0.129c8669", "Hello world")

this should also work

ControlGetText ( "NewsPlex", "", "WindowsForms10.window.8.app.0.129c8669")

Share this post


Link to post
Share on other sites
vish2503

Can you show the "correct" parameters you tried with?

If ControlSend works ControlGetText should work to.

If this work

ControlSend("NewsPlex", "", "WindowsForms10.window.8.app.0.129c8669", "Hello world")

this should also work

ControlGetText ( "NewsPlex", "", "WindowsForms10.window.8.app.0.129c8669")

This is the Code that I tried:

ControlSend("NewsPlex", "", "[CLASSNN:WindowsForms10.window.8.app.0.129c8669; Instance:9]", "Sample Text")

$textA = ControlGetText("NewsPlex", "", "[CLASSNN:WindowsForms10.window.8.app.0.129c8669; Instance:9]")

I also tried.

$ctrlHandle = ControlGetHandle("NewsPlex", "", "[CLASSNN:WindowsForms10.window.8.app.0.129c8669; Instance:9]")

_GUICtrlEdit_SetText($ctrlHandle, "This is my First Test")

$textA = _GUICtrlEdit_GetText($ctrlHandle)

Thanks.

Share this post


Link to post
Share on other sites
vish2503

This is the Code that I tried:

ControlSend("NewsPlex", "", "[CLASSNN:WindowsForms10.window.8.app.0.129c8669; Instance:9]", "Sample Text")

$textA = ControlGetText("NewsPlex", "", "[CLASSNN:WindowsForms10.window.8.app.0.129c8669; Instance:9]")

I also tried.

$ctrlHandle = ControlGetHandle("NewsPlex", "", "[CLASSNN:WindowsForms10.window.8.app.0.129c8669; Instance:9]")

_GUICtrlEdit_SetText($ctrlHandle, "This is my First Test")

$textA = _GUICtrlEdit_GetText($ctrlHandle)

Thanks.

I tried your code. The Text retrieved is still "tern1". Any help in this regard would be really helpful. THanks.

Share this post


Link to post
Share on other sites
bo8ster

Your having the same issue as mehttp://www.autoitscript.com/forum/index.php?showtopic=87381.

All I can suggest is

_CtrlGetByPos() : http://www.autoitscript.com/forum/index.ph...c=30717&hl=

Or Maybe:

_WinGetCtrlInfo() : http://www.autoitscript.com/forum/index.ph...c=32781&hl=

as was suggested to me.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
vish2503

Hi, My Aplologies for the delayed response. Was stuck with other high priority work. I checked both the blogs.

Using WinGetCtrlInfo I can get the IDs and ClassNameNNs. Really Helps a Lot.

Using CtrlGetByPos, is also good enough. I can get the position of the Ctrl. Neat Code.

Here are my other main issues:

1. My main area / issue where I am stuck is, I am unable to read from anything off the Editor window that I have using any functions. Pls Help.

2. Pls refer screen shot psoted earlier: In the upper editor window, if I have only one New Document tab, the Instance value is 3. However, if I have more than 1 New Document tabs, the Instance number changes. Also the ClassNameNN changes.

How to read data from the Editor. Is there a function to read DATA on / from a Editor Control? How can I handle or deal with second issue. PLEASE HELP!!!!!!!

Share this post


Link to post
Share on other sites
vish2503

Hi, Is there a way or method to find out what type of a control, a control is? Whether it is Listbox or menu or edit box etc?

Share this post


Link to post
Share on other sites
vish2503

Here is the Info from the Auto Info Tool: This info doesnt quite clearly tell me whether the Control is an Edit type or list box. etc.

We have a TE editor instance embedded in our application, I am able to write to the editor using ControlSend, However no matter what I am unable to retrieve or get or read text from the Editor. I have explained this issue in detail in another post (http://www.autoitscript.com/forum/index.php?showtopic=87371&hl=Urgent)

>>>> Window <<<<

Title: NewsPlex

Class: WindowsForms10.window.8.app.0.129c866

Position: -4, -4

Size: 1288, 968

Style: 0x17CF0000

ExStyle: 0x00050100

Handle: 0x003D0750

>>>> Control <<<<

Class: WindowsForms10.window.8.app.0.129c866

Instance: 9

ClassnameNN: WindowsForms10.window.8.app.0.129c8669

Advanced (Class): [CLASS:WindowsForms10.window.8.app.0.129c866; INSTANCE:9]

ID: 2885490

Text: tern1

Position: 169, 157

Size: 903, 344

ControlClick Coords: 464, 161

Style: 0x56010000

ExStyle: 0x00000000

Handle: 0x002C0772

>>>> Mouse <<<<

Position: 633, 344

Cursor ID: 0

Color: 0xFFFFFF

>>>> StatusBar <<<<

>>>> Visible Text <<<<

New Document

Modified Text

00:00

tern1

New Document

Modified Text

00:00

tern1

/

ultraGrid1

StatusStrip

>>>> Hidden Text <<<<

Share this post


Link to post
Share on other sites
SmOke_N

Here is the Info from the Auto Info Tool: This info doesnt quite clearly tell me whether the Control is an Edit type or list box. etc.

We have a TE editor instance embedded in our application, I am able to write to the editor using ControlSend, However no matter what I am unable to retrieve or get or read text from the Editor. I have explained this issue in detail in another post (http://www.autoitscript.com/forum/index.php?showtopic=87371&hl=Urgent)

Then why would you start another topic if you're already running a topic on the same issue? Why not just ask in that topic?

Edit:

BTW, I'd be willing to bet that control is not an edit control. The edit feature is more than likely activated when you click on it. That's when you'd need to get the control handle (and you'll want to work with handles as much as possible with .NET apps).

Basically, .NET is quite difficult to code for in AutoIt if you don't have any idea what is actually happening in the .NET code itself... so take some time and work with your developers that created the app and see if you guys can come up with a nice solution.

Edited by SmOke_N

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.

Share this post


Link to post
Share on other sites
lamezcua

When clicking on my control it works one time using ControlClick

CODE
ControlClick($title,"","[CLASS:WindowsForms10.window.8.app.0.3ce0bb8; INSTANCE:151]")

but the next time the application starts, the CLASSNN attribute is different and it does not work anymore. I need to be able to run the tests automatically, so I need to:

a) Get the CLASSNN every time (is it possible using a script?)

:) Use instance (I think that one is constant)

c) Another solution I am not aware of

I also tried ID but it change as well

Share this post


Link to post
Share on other sites
TerarinK

a) Get the CLASSNN every time (is it possible using a script?)

Use instance (I think that one is constant)

c) Another solution I am not aware of

Can't you just use CLASS as the window title parameter. This way you can always perform WinGetClassList ( "title" [, "text"] ). Then with that you can decide rather if it is a single or multiple based application by a 'regular expression' designed for this task.

CODE

Const $csPattern = "(?i)WindowsForms10.window.8.app.0.(.*?)(\n|\r\n|$)"

...

$sClassList = WinGetClassList("NewsPlex")

Dim $Matches = StringRegExp($sClassList, $csPattern, 3)

For $i = 0 to UBound($array) - 1

If $array[$i] <> @CRLF Then msgbox(0, "RegExp", $array[$i])

Next

This will get you the number of controls you have 1 being single and anything else would be multiple. That way you can always know what is out there even if it is unknown.

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

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  

×