Sign in to follow this  
Followers 0
JayJay

Tooltip coordinates

3 posts in this topic

(I have MouseCoordMode and PixelCoordMode set to relative)

I'm checking something at position $X,$Y and want a tooltip to appear there to show me some info.

The PixelGetColor($X,$Y) is relative to the window I'm checking, but ToolTip("text goes here",$x,$y) is relative to the desktop (absolute coordinates)

I've looked at the other Opt(..) but can't find a setting for ToolTip coordinates.

Here is short script to show what I mean:

(I've added the mousemove to indicate what pixel is being checked, but I want the tooltip to appear there without moving the mouse)

Opt("MouseCoordMode", 0)                        ; 1=absolute, 0=relative, 2=client
Opt("PixelCoordMode", 0)                        ; 1=absolute, 0=relative, 2=client

#include "GUIConstants.au3"

HotKeySet("{ESC}", "Terminate")                 ; ESC to Terminate

GuiCreate("Test",200,200,200,200)
GUISetState()
$x=Random(1,200,1)                              ; random postion
$y=Random(1,200,1)
MouseMove($x,$y)                                ; move mouse, relative to window
Tooltip("This is a tooltip",$x,$y)              ; tooltip is relative to desktop

While 1
        Sleep(500)
WEnd

Func Terminate()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



Opt("MouseCoordMode", 2)                        ; 1=absolute, 0=relative, 2=client
Opt("PixelCoordMode", 2)                        ; 1=absolute, 0=relative, 2=client

#include "GUIConstants.au3"

HotKeySet("{ESC}", "Terminate")     ; ESC to Terminate

GuiCreate("Test",200,200,200,200)
GUISetState()
$x=Random(1,200,1)                ; random postion
$y=Random(1,200,1)
MouseMove($x,$y)                                ; move mouse, relative to window
$OptMCM = Opt('MouseCoordMode', 1)
$Mpos = MouseGetPos()
Tooltip("This is a tooltip",$Mpos[0],$Mpos[1])        ; tooltip is relative to desktop
Opt('MouseCoordMode', $OptMCM)

While 1
    Sleep(500)
WEnd

Func Terminate()
    Exit
EndFunc
Is this what you mean?


[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

Ooops!

I was reviewing my posts, and I noticed you wanted to do this without having use MouseMove(), Here is what I came up with:

#include "GUIConstants.au3"

HotKeySet("{ESC}", "Terminate")     ; ESC to Terminate

$MainGUI = GuiCreate("Test", 200, 200, 800, 200)
GUISetState()
$x = Random(1, 200, 1)                ; random postion
$y = Random(1, 200, 1)
_ToolTipClient($MainGUI, 'This is a tooltip', $x, $y)

While 1
    Sleep(500)
WEnd

Func Terminate()
    Exit
EndFunc

Func _ToolTipClient($hwnd_Client, $s_Text, $iXPos = 0, $iYpos = 0, $i_Title = '', $i_Icon = 0, $i_Options = 0)
    If Not IsHWnd($hwnd_Client) Then $hwnd_Client = WinGetHandle($hwnd_Client)
    Local $iWCSize = WinGetClientSize($hwnd_Client), $iWPos = WinGetPos($hwnd_Client)
    If Not IsArray($iWPos) Or Not IsArray($iWCSize) Then Return 0
    Local $iMoveXPos = (($iWPos[2] - $iWCSize[0]) + ($iWPos[0] + $iXPos)), $iMoveYPos = (($iWPos[3] - $iWCSize[1]) + ($iWPos[1] + $iYpos))
    ToolTip($s_Text, $iMoveXPos, $iMoveYPos, $i_Title, $i_Icon, $i_Options)
    Return 1
EndFunc
Seemed to work.

[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

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