bladem2003 Posted December 3, 2021 Share Posted December 3, 2021 (edited) 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 December 3, 2021 by bladem2003 Link to comment Share on other sites More sharing options...
Subz Posted December 3, 2021 Share Posted December 3, 2021 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 More sharing options...
bladem2003 Posted December 4, 2021 Author Share Posted December 4, 2021 I would like to use _GUIToolTip_Create. is that not possible? Link to comment Share on other sites More sharing options...
Subz Posted December 4, 2021 Share Posted December 4, 2021 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 More sharing options...
bladem2003 Posted December 9, 2021 Author Share Posted December 9, 2021 (edited) 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 December 9, 2021 by bladem2003 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