Jump to content
birbird

How to find a control if ID duplicates

Recommended Posts

birbird

This is the code of mine

$aList = WinList("[CLASS:#32770; W:491; H:369]")

It does not work. Could anyone please tell what is the right way to use size to find window?

Share this post


Link to post
Share on other sites
water

Works fine here when used with Notepad.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

When you say "does not work", how do you know that it does not work?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
birbird

Thanks for your help, I will check my code.

Share this post


Link to post
Share on other sites
birbird

I don't know why, maybe the application is not well written.

On a window, there are 2 controls with the same ID. The one is a Edit, the other is a Static (Class).

ControlSetText($hWnd, "", "[ID:1032]", "")

can not find the control I want.

ControlSetText($hWnd, "", "[CLASSNN:Edit7]", "")

can not work either, because the number after Edit vary in different run.

ControlSetText($hWnd, "", "[CLASS:Edit; ID:1032]", "")

is right logically, but it seems other parameter is ignored if ID presents. This does not work either.

How could I get the Edit with ID 1032 while there is another control's ID is 1032 too?

Any help will highly appreciated! 

Share this post


Link to post
Share on other sites
birbird

I find a workaround is that click an other control first (it has an unique ID), then the Edit will get focus as designed, then Send will do the job.

But I still want to know if I can ControlSetText it under this situation?

Edited by birbird

Share this post


Link to post
Share on other sites
MikahS

Can you post the Info you get from the Window info tool? It could have differences in instance numbers that you can use to specify which control you want.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
birbird

Can you post the Info you get from the Window info tool? It could have differences in instance numbers that you can use to specify which control you want.

Thank you for your idea.

I guess you mean 

ControlSetText($hWnd, "", "[CLASS:Edit; INSTANCE:1]", "")

I have tried it, I fail because the instance num vary in different run.

The Window Info is like this

control2.thumb.png.f53b0c86d9198ea0f662a

Edited by birbird

Share this post


Link to post
Share on other sites
birbird

Sorry new to autoit, after frustrated much, I think finding control by position and size is a reliable method.

But I can't make it work, this is my test code to caculator.

$hWnd = WinWait("[W:423; H:323]")
ConsoleWrite($hWnd & @CRLF)

Local $sText = ControlGetText($hWnd, "", "[ID:323]")
ConsoleWrite($sText & @CRLF)

Local $sText2 = ControlGetText($hWnd, "", "[X:150; Y:70; W:50; H:16]")
ConsoleWrite($sText2 & @CRLF)

It can find the control by ID, but fail by position and size. Please help :lol:

The Window Info is 

control3.thumb.png.c3f613eddae8ccb1d9c9e

Share this post


Link to post
Share on other sites
birbird

This code work well to windows caculator

$hWnd = WinWait("[W:423; H:323]")
ConsoleWrite($hWnd & @CRLF)

So it shoud be something else wrong with my code, nothing to do with W / H

Share this post


Link to post
Share on other sites
water

Can you please explain why you need to find controls by position and not by ID or Classname?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
birbird

Can you please explain why you need to find controls by position and not by ID or Classname?

Please see this post #1255468

 

Share this post


Link to post
Share on other sites
water

Why did you start a second thread for the same problem? I'm sure searching a control by its coordinates isnt't the best way.
I've never heard of two controls having the same ID.

Can you please post the screenshot of the AutoIt Window Info Tool for BOTH controls?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
birbird

Why did you start a second thread for the same problem? I'm sure searching a control by its coordinates isnt't the best way.
I've never heard of two controls having the same ID.

Can you please post the screenshot of the AutoIt Window Info Tool for BOTH controls?

Here they are

control4.thumb.png.8d5b7bd8a0c08534031be

control5.thumb.png.6c52d46a39d53b6828db9

 

 

Edited by birbird

Share this post


Link to post
Share on other sites
water

Have you tried to access the control by specifying the Value from "Advanced Mode"?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
birbird

3 threads merged, please stick to one thread from here on.

Jos

Sorry for too many threads.

I started a thread about how to find control by position and size just because it is a stand alone problem.

I just red https://www.autoitscript.com/autoit3/docs/intro/controls.htm, it says position and size can be used to identify a control, but no example. 

Then I write an example, but not work and don't know what is wrong.

So I started a thread ask for identify a control by position and size.

No matter how I solve the other problem finally, I want know the right way to find a control by position and size.

Please help me. :)

 

And, at least the identify window by size problem should not be merged, it has nothing to do with other problems.

Anyway, I am clear about the window problem, that's all right.

Edited by birbird

Share this post


Link to post
Share on other sites
birbird

Have you tried to access the control by specifying the Value from "Advanced Mode"?

Yes, I tried. This is my preceding post

Thank you for your idea.

I guess you mean 

ControlSetText($hWnd, "", "[CLASS:Edit; INSTANCE:1]", "")

I have tried it, I fail because the instance num vary in different run.

Share this post


Link to post
Share on other sites
water

Can you please tell us which application you try to automate?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

×