I would like to mimic the tooltip functionality found in AutoHotKey.
AutoHotKey code:
infoTooltip() {
MouseGetPos, xPos, yPos, winId
PixelGetColor, color, %xPos%, %yPos%, RGB
WinGetTitle, winTitle, ahk_id %winId%
ToolTip "%winTitle%"`n%xPos% %yPos% %color%
}
Looks like this when called inside a loop and will follow mouse around:
References found from googling:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms632680(v=vs.85).aspx
How to use Windows ToolTip Control without bounding to a tool
My Python code attempt so far:
import win32con, win32gui
from win32api import GetModuleHandle
from commctrl import (TOOLTIPS_CLASS, TTS_ALWAYSTIP, TTS_NOPREFIX, TTM_ADDTOOL, TTM_SETMAXTIPWIDTH)
class TooltipWindow:
def __init__(self):
win32gui.InitCommonControls() # Loads COMCTL32.DLL (Shell Common Controls Library)
self.hwnd = win32gui.CreateWindowEx(
win32con.WS_EX_CLIENTEDGE | win32con.WS_EX_TOPMOST,
TOOLTIPS_CLASS,
"MyTooltipWindow",
win32con.WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX | win32con.WS_BORDER,
win32con.CW_USEDEFAULT,
win32con.CW_USEDEFAULT,
win32con.CW_USEDEFAULT,
win32con.CW_USEDEFAULT,
None,
None,
GetModuleHandle(None),
None
)
win32gui.SendMessage(self.hwnd, TTM_ADDTOOL, None, ???)
tooltip = TooltipWindow()
I have no idea how to translate the TOOLINFO struct to the lparam argument. Also, going in blind trying to get most of this code working as this is my first real win32gui project.
Any help is appreciated, thank you!
Have you considered instead doing a Dll import? It's definitely worth lugging around the .dll it if you are planning on using more authotkey functionality.