Radsam Posted July 24, 2005 Posted July 24, 2005 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
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