Jump to content
Sign in to follow this  

ControlID Changing

Recommended Posts


I'm trying to use the ANYGUIv2.1 to create a button in an application for work. I can create a button no problem but when I close the app and restart it, the script no longer works because the controlID changed.

Is there a function to get a controlID for a certain ClassNameNN?

Here is my code so far...

#include <ANYGUIv2.1.au3>
#include <guiconstants.au3>
Opt("WinTitleMatchMode", 4); allow ClassName lookup to avoid window confusion
Opt("GUIOnEventMode", 1); Change to OnEvent mode

$appWindow = WinGetHandle("classname=SWT_Window0")


$myVar1 = _GuiTarget($appWindow, "", "", 197238);<===Target is control on main application.
$myVarB1 = _TargetAddButton("Quick Ticket", 390, 0, 75, 22, "", "", $myVar1)
GUICtrlSetOnEvent($myVarB1[0], "button1Clicked")

While WinExists($myVar1)
    If Not WinExists($myVar1) Then
Func button1Clicked()
    MsgBox(0,"Debug", "This is a test.")
;~   ControlFocus($appWindow,"",$mainAppControl);Button click steals focus, restore to app

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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.