Sign in to follow this  
Followers 0
slightly_abnormal

are tool tips even possible?

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

ControlGetPos()/MouseGetPos()/ToolTip()

Edit:

Just thought I'd try since I had a few to drink tonight :o

#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 :geek: Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

So they are possible!!! :mellow: I was wondering why hardly anyone used them.. :)

thanks again smoke_n!

Edited by slightly_abnormal

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