Jump to content

How to get instance of a specific Button


Recommended Posts

How to get instance of a specific Button, in which the button's instance is keep changing on every time while launching the software.

Its not only changing in the single system on every new launch. It also varies from one computer to another. 

Button name is same, but its instance is changing. How to get instance of a certain button. 

Tell any suggestions or example scripts regarding this issues friends!  

Link to comment
Share on other sites

Currently I'm taking instance from the spy tool manually and updating in the script everytime.

Every new launch of the software, the Button instance is changing. 

Button "4" is changing.

 

Local $pPos = ControlGetHandle("XYZ Composer","","BCGPTabWnd:40000000:8:10003:10:"&"1"); properties class
Local $hWnd = WinWait("XYZ Composer", "", 10)
ControlClick($hWnd, "", "Properties")
Sleep ( 500)
ControlClick($hWnd, "", "Properties")
Local $ePos = ControlGetPos("XYZ Composer","","Button"& "4")
MouseMove( $ePos[0], $ePos[1], 10)
MouseMove( $p, $q, 10)
MouseClick( "LEFT", $p, $q, 2, 10)

 

Link to comment
Share on other sites

Summary of AutoItWindowInfo Tool

>>>> Window <<<<
Title:  A Composer (64-bit) - [V_25125]
Class:  Afx:0000000140000000:8:0000000000010003:0000000000000000:000000002B8C061F
Position:   -8, -8
Size:   1616, 1176
Style:  0x15CF8000
ExStyle:    0x00000110
Handle: 0x0000000000AD03D4

>>>> Control <<<<
Class:  Button
Instance:   4
ClassnameNN:    Button4
Name:   
Advanced (Class):   [CLASS:Button; INSTANCE:4]
ID: 1729
Text:   Enable
Position:   163, 348
Size:   153, 16
ControlClick Coords:    17, 6
Style:  0x50000005
ExStyle:    0x00000000
Handle: 0x00000000003B05C4

>>>> Mouse <<<<
Position:   180, 346
Cursor ID:  0
Color:  0x000000

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Timeline
Properties
Properties
Label Copy 1 o...
255
Enable
10
Enable
None
None
255
Enable
0.50
250
Enable
3DVIAComposer
3DV_GX25125


>>>> Hidden Text <<<<
Workshops
Getting Started
WndDirectUI
Views
Markers
Layers
BOM
Collaboration
Assembly
Collaboration
Styles
_Default Style
Kinematic
Render - Navigate - Transform
Standard

 

Link to comment
Share on other sites

how about you tell me what you are trying to automate and post your source? looks like

ID: 1729

is what you are looking for. If it's changing on you I would need to see it myself to figure out what I would do to solve the issue

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

9 hours ago, Cooler said:

Advanced (Class):   [CLASS:Button; INSTANCE:4]

That tells you what you need for the control ID information.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Did you try the control ID as suggested?  Those are generally unique:

 

Local $ePos = ControlGetPos("XYZ Composer","",1729)

 

Run my signature on your window, and provide the output.  You should see that 1729 is unique.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

On 5/28/2019 at 9:01 PM, junkew said:

You have the text of the button so should be easy to identify by text.

Actually that Button is check list enable button. I'm having 3 Buttons on same name. That's why I'm struggling Bro.

Link to comment
Share on other sites

On 5/29/2019 at 5:12 AM, jdelaney said:

Did you try the control ID as suggested?  Those are generally unique:

 

Local $ePos = ControlGetPos("XYZ Composer","",1729)

 

Run my signature on your window, and provide the output.  You should see that 1729 is unique.

This Im using to handle my class. I can also accessing the button. But its instance is keep on changing. Every time im changing the instance with help of spy tool. i want to make script solid and fixed. Thats what im looking.

Link to comment
Share on other sites

  • 4 years later...

I'm not sure this is the same problem as the original. I faced a similar problem as the OP with an app that dynamically creates tabs. Elements on those tabs get different instance numbers from one run to another. The AutoIt tool can find the instance number, but it changes from one run to another. If it has unique text in the control, you can access the control by that. If the control is in a fixed position, you should be able to do a mouse click with x,y coordinates. 

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