slightly_abnormal Posted March 10, 2006 Share Posted March 10, 2006 been wondering for weeks on how to get a tooltip right next to the mouse when hovering over a button/object.. cant seem to get it right #include <GUIConstants.au3> #NoTrayIcon GuiCreate("Tooltip", 140, 60,-1, -1) $Button1 = GuiCtrlCreateButton("Notepad", 10, 10, 50, 40);Hover over this button should display tooltip.. $Button2 = GuiCtrlCreateButton("MSPaint", 80, 10, 50, 40);Hover over this button should display tooltip.. GUISetState(@SW_SHOW) GuiSetState() While 1 $msg = GUIGetMsg() ;Closes window Select Case $msg = $GUI_EVENT_CLOSE exitloop ;==> Case $msg = $button1 run("notepad.exe") ToolTip("This is Notepad", 0, 0);Should display tooltip right next to mouse Sleep(200) ;==> Case $msg = $button2 run("MSPaint.exe") ToolTip("This is a MSPaint", 0, 0);Should display tooltip right next to mouse Sleep(200) If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndSelect Wend Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 10, 2006 Moderators Share Posted March 10, 2006 (edited) ControlGetPos()/MouseGetPos()/ToolTip()Edit:Just thought I'd try since I had a few to drink tonight #include <GUIConstants.au3> #NoTrayIcon Opt('MouseCoordMode', 2) $Main = GUICreate("Tooltip", 140, 60,-1, -1) $Button1 = GUICtrlCreateButton("Notepad", 10, 10, 50, 40);Hover over this button should display tooltip.. $Button2 = GUICtrlCreateButton("MSPaint", 80, 10, 50, 40);Hover over this button should display tooltip.. GUISetState(@SW_SHOW) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;==> Case $msg = $Button1 Run("notepad.exe") Sleep(200) ;==> Case $msg = $Button2 Run("MSPaint.exe") Sleep(200) EndSelect Local $Cpos = ControlGetPos($Main, '', $Button1) Local $Cpos2 = ControlGetPos($Main, '', $Button2) Local $Mpos = MouseGetPos() If $Mpos[0] >= $Cpos[0] And $Mpos[0] <= $Cpos[0] + $Cpos[2] And $Mpos[1] >= $Cpos[1] And $Mpos[1] <= $Cpos[1] + $Cpos[3] Then ToolTip('Hovering over Notepad Button') ElseIf $Mpos[0] >= $Cpos2[0] And $Mpos[0] <= $Cpos2[0] + $Cpos2[2] And $Mpos[1] >= $Cpos2[1] And $Mpos[1] <= $Cpos2[1] + $Cpos2[3] Then ToolTip('Hovering over MSPaint Button') Else ToolTip('') EndIf WEnd Of course this will be 'Your Poor Attempt' when someone else ask the question I'm sure Edited March 10, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 10, 2006 Moderators Share Posted March 10, 2006 I must say that my option works above... but... I decided to "Read" the help file a bit, and since we were dealing with a GUI, the GUI commands specifically... I've never used or had use for what you asked or what I gave, but low and behold... there's actually a command for this:#include <GUIConstants.au3> #NoTrayIcon Opt('MouseCoordMode', 2) $Main = GUICreate("Tooltip", 140, 60,-1, -1) $Button1 = GUICtrlCreateButton("Notepad", 10, 10, 50, 40);Hover over this button should display tooltip.. GUICtrlSetTip($Button1, "Hovering over the NotePad Button") $Button2 = GUICtrlCreateButton("MSPaint", 80, 10, 50, 40);Hover over this button should display tooltip.. GUICtrlSetTip($Button2, "Hovering over the MSPaint Button") GUISetState(@SW_SHOW) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;==> Case $msg = $Button1 Run("notepad.exe") Sleep(200) ;==> Case $msg = $Button2 Run("MSPaint.exe") Sleep(200) EndSelect WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
slightly_abnormal Posted March 10, 2006 Author Share Posted March 10, 2006 (edited) So they are possible!!! I was wondering why hardly anyone used them.. thanks again smoke_n! Edited March 10, 2006 by slightly_abnormal 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