Sign in to follow this  
Followers 0
Radsam

ControlID Changing

1 post in this topic

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")

WinActivate($appWindow)

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


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

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  
Followers 0