I am automating a VB6 application using AutoIT and have hit some issues.
The application has a 'Toolboxes' window which contains an SSTab
control with 18 tabs in 6 rows. There are over 100 instances of the ThunderRT6CommandButton
class. My AutoIT script is supposed to interact with specific buttons, and so far I've been using ControlClick
:
ControlClick($sToolboxes, '', '[CLASS:ThunderRT6CommandButton; INSTANCE:81]')
The issue is that when I change to a different tab and close the toolboxes window the application remembers which tab was open. This means that the next time I open the toolboxes window the tabs are initiated in a different order and all of the instance numbers of the buttons have changed.
I can't even call ControlClick
and specify the text of the button to be clicked because that isn't unique; about 20 of the buttons are simply labelled 'Apply'.
Using Inspect.exe I noticed that each button has a unique AutomationID
which is constant even when closing and reopening the toolboxes window after shuffling the tabs around.
Is there any way that I can click buttons using their AutomationID in AutoIT?
The only other fix for this that I can think of is making the AutoIT script launch the application itself so that the toolboxes are in the same order each time the script runs
The AutoIT Window Info tool shows the AutomationID
, but calls it "ID":
I changed my script to include ID:##
instead of an instance number and it works:
ControlClick($sToolboxes, '', '[CLASS:ThunderRT6CommandButton; ID:245]')