Jump to content

_GUIToolTip_TrackPosition set tooltip 20pixel over the mouse pointer


Recommended Posts

Is there a way to add the tooltip 20 pixel over the mouse pointer?

 

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>


Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

Local $hToolTip = _GUIToolTip_Create(0, $TTS_BALLOON)
; Add tool to the ToolTip control, not using a control or the GUI to link it to
_GUIToolTip_AddTool($hToolTip, 0, " ", 0, 0, 0, 0, 0, $TTF_SUBCLASS)

_GUIToolTip_SetTitle($hToolTip, 'Mouse position', $TTI_INFO)
GUISetState(@SW_SHOW)

_GUIToolTip_TrackActivate($hToolTip, True, 0, 0)
Local $aPos, $iOldaPos0, $iOldaPos1
While 1
    Sleep(10)
    $aPos = MouseGetPos()
    If $aPos[0] <> $iOldaPos0 Or $aPos[1] <> $iOldaPos1 Then
        _GUIToolTip_TrackPosition($hToolTip, $aPos[0] + 10, $aPos[1] - 20)
        _GUIToolTip_UpdateTipText($hToolTip, 0, 0, "X: " & $aPos[0] & " Y: " & $aPos[1])
        $iOldaPos0 = $aPos[0]
        $iOldaPos1 = $aPos[1]
    EndIf
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
; Destroy the tooltip control
_GUIToolTip_Destroy($hToolTip)
GUIDelete($hGUI)

 

 

 

 

Edited by bladem2003
Link to comment
Share on other sites

Using ToolTIp maybe?

#include <GUIConstantsEx.au3>

Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

GUISetState(@SW_SHOW)

Local $aPos, $iOldaPos0, $iOldaPos1
While 1
    Sleep(10)
    $aPos = MouseGetPos()
    If $aPos[0] <> $iOldaPos0 Or $aPos[1] <> $iOldaPos1 Then
        ToolTip("X: " & $aPos[0] + 10 & @CRLF & "Y: " & $aPos[1] - 20, $aPos[0], $aPos[1] - 60, "")
        $iOldaPos0 = $aPos[0]
        $iOldaPos1 = $aPos[1]
    EndIf
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete($hGUI)

 

Link to comment
Share on other sites

You could use $TTF_TRACK although the balloon will be below the mouse pointer or you could remove balloon style and have it above.

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>


Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

Local $hToolTip = _GUIToolTip_Create(0, $TTS_BALLOON)
; Add tool to the ToolTip control, not using a control or the GUI to link it to
_GUIToolTip_AddTool($hToolTip, 0, " ", 0, 0, 0, 0, 0, $TTF_TRACK)

_GUIToolTip_SetTitle($hToolTip, 'Mouse position', $TTI_INFO)
GUISetState(@SW_SHOW)

_GUIToolTip_TrackActivate($hToolTip, True, 0, 0)
Local $aPos, $iOldaPos0, $iOldaPos1
While 1
    Sleep(10)
    $aPos = MouseGetPos()
    If $aPos[0] <> $iOldaPos0 Or $aPos[1] <> $iOldaPos1 Then
        _GUIToolTip_TrackPosition($hToolTip, $aPos[0] + 20, $aPos[1] + 20)
        _GUIToolTip_UpdateTipText($hToolTip, 0, 0, "X: " & $aPos[0] & " Y: " & $aPos[1])
        $iOldaPos0 = $aPos[0]
        $iOldaPos1 = $aPos[1]
    EndIf
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
; Destroy the tooltip control
_GUIToolTip_Destroy($hToolTip)
GUIDelete($hGUI)

 

Link to comment
Share on other sites

you can move the tooltip with winmove but _GUIToolTip_UpdateTipText sets the coordinates back to the mouse pointer

is there another way to update the text?

 

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <WinAPISysWin.au3>
#include <array.au3>


Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)


$hToolTip = _GUIToolTip_Create(0, BitOR($TTS_NOPREFIX, $TTS_NOANIMATE, $TTS_NOFADE, $TTS_BALLOON)) ;$TTS_CLOSE )
_GUIToolTip_SetMaxTipWidth($hToolTip, 400)         ; this allows multiline tooltips to be used with $hToolTip2
_GUIToolTip_AddTool($hToolTip, 0, " ", 0, 0, 0, 0, 0, BitOR($TTF_SUBCLASS, $TTF_TRANSPARENT))

GUISetState(@SW_SHOW)
_GUIToolTip_Activate($hToolTip)
_GUIToolTip_TrackActivate($hToolTip, True, 0, 0)

Local $aPos, $iOldaPos0, $iOldaPos1
While 1
    Sleep(10)
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    $aPos = MouseGetPos()
    $aPos2 = GUIGetCursorInfo()
    If ($aPos[0] <> $iOldaPos0 Or $aPos[1] <> $iOldaPos1) Then
        _GUIToolTip_UpdateTipText($hToolTip, 0, 0, "X: " & $aPos[0] & " Y: " & $aPos[1])
        WinMove($hToolTip, "",$aPos[0], $aPos[1] - _GUIToolTip_GetBubbleHeight($hToolTip, 0, 0) - 20)
        $iOldaPos0 = $aPos[0]
        $iOldaPos1 = $aPos[1]
    EndIf
WEnd

 

Edited by bladem2003
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...