saywell Posted February 7, 2011 Share Posted February 7, 2011 (edited) I've just wasted hours trying to sort out a problem with my script. I have a function that opens our patient admin system (PAS) if it's not already running (Winexists ("PAS") [using titlematch mode 2]. It worked fine when called from various places in the GUI, except for one. After much faffle, I discovered that the tooltip was giving a false positive to the Winexists command! Strangely, it was the 'PAS' in the tip TEXT that did this' not in the tip title! Solved by changing 'PAS' in tooltip text to 'P.A.S.' I thought this might be helpful to others, so posting here as it's not mentioned in the helpfile. Here's an example - different tooltip message on each button: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Opt ('WinTitleMatchMode', 2) Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) GUICtrlSetTip ($Button_1, "Opens Notepad if not already running", "Opens Notepad") $Button_2 = GUICtrlCreateButton("Run Notepad", 0, -1) GUICtrlSetTip ($Button_2, "Opens Bill's text editor if not already running", "Opens Notepad") GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 If Not WinExists ("Notepad") Then Run('Notepad.exe') ; Will Run/Open Notepad EndIf Case $msg = $Button_2 If Not WinExists ("Notepad") Then Run('Notepad.exe') ; Will Run/Open Notepad EndIf EndSelect WEnd EndFunc ;==>Example William Edited February 7, 2011 by saywell Link to comment Share on other sites More sharing options...
Tankbuster Posted February 8, 2011 Share Posted February 8, 2011 Nice investigation.Btw. is this in the end now a "feature" or "bug" of Autoit? I guess referring to Winexists I expected tooltips not as a window, but on the other hand it may be nice to use this "feature" to trigger something when a certain tooltip pops up.So is it worth to add a line to the documentation about this, either on Winexists or GUICtrlSetTip? Something like:"Remark: matching tooltips text returns true"(I checked the docu and the bugtracker but did not find a trace of an issue related to this find.) 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