Jump to content

How to find a control if ID duplicates


Recommended Posts

Works fine here when used with Notepad.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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! 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Developers

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

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...