Cooler Posted May 27, 2019 Share Posted May 27, 2019 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 More sharing options...
FrancescoDiMuro Posted May 27, 2019 Share Posted May 27, 2019 1 minute ago, Cooler said: Tell any suggestions or example scripts regarding this issues friends! Post what you tried so far, then we'll help you with that. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Cooler Posted May 27, 2019 Author Share Posted May 27, 2019 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 More sharing options...
FrancescoDiMuro Posted May 27, 2019 Share Posted May 27, 2019 @Cooler Post the summary of the AutoItWindowInfo Tool Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Cooler Posted May 28, 2019 Author Share Posted May 28, 2019 Summary of AutoItWindowInfo Tool expandcollapse popup>>>> 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 More sharing options...
FrancescoDiMuro Posted May 28, 2019 Share Posted May 28, 2019 @Cooler If there is just one button with the Classname "Button", you could use it to automate you application. You could even use ControlClick() instead of ControlGetPos():. Just an example: ControlClick("XYZ Composer", "", "[CLASS:Button]") Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Cooler Posted May 28, 2019 Author Share Posted May 28, 2019 But here more than one Buttons were there, with different instance. I want to click the second button, which's instance is changing in every new launch. Link to comment Share on other sites More sharing options...
Earthshine Posted May 28, 2019 Share Posted May 28, 2019 Then you will have to get the ID My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Cooler Posted May 28, 2019 Author Share Posted May 28, 2019 Instance ID or what bro..! Link to comment Share on other sites More sharing options...
Earthshine Posted May 28, 2019 Share Posted May 28, 2019 (edited) 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 May 28, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
BrewManNH Posted May 28, 2019 Share Posted May 28, 2019 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 GudeHow 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 More sharing options...
junkew Posted May 28, 2019 Share Posted May 28, 2019 You have the text of the button so should be easy to identify by text. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Danp2 Posted May 28, 2019 Share Posted May 28, 2019 Except that the word "Enable" appears multiple times, so I'm guessing (based on the limited details provided) that there are multiple buttons with this same text. Probably need to use a combination of Class, Text, and Instance. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jdelaney Posted May 28, 2019 Share Posted May 28, 2019 (edited) 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 May 28, 2019 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 More sharing options...
Cooler Posted May 31, 2019 Author Share Posted May 31, 2019 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 More sharing options...
Cooler Posted May 31, 2019 Author Share Posted May 31, 2019 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 More sharing options...
jdelaney Posted May 31, 2019 Share Posted May 31, 2019 (edited) provide the output from my the function in my signature Edited May 31, 2019 by jdelaney Cooler 1 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 More sharing options...
DIMM_V2 Posted November 13, 2023 Share Posted November 13, 2023 How to deal with it , when the instance or class is not supported by Au3Info.exe ? ONLY tools like , UIASpy.au3 , inspect.exe ? .... Link to comment Share on other sites More sharing options...
quickbeam Posted November 14, 2023 Share Posted November 14, 2023 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now