spyoungtech / ahk

Python wrapper for AutoHotkey with full type support. Harness the automation power of AutoHotkey with the beauty of Python.
MIT License
887 stars 66 forks source link

Executor tray tip #299

Closed filantus closed 6 months ago

filantus commented 6 months ago

Hello! Sorry if i got something wrong and for long post. But i stumbled on issue (for me at least).

My goal was just run script and change AHK tray icon tip (from executor.ahk to anything else). I read about menu_tray_tooltip method and used it. But instead of just changing tip i got two tray icons! one of these was with text stated by me and another one was initial icon with tip executor.ahk.

Then i tried menu_tray_icon_hide method, and it's hide icon with my text and leave only one with text executor.ahk. So it's seems what use both menu_tray_tooltip and menu_tray_icon_hide makes no sense.

Ok. Moving on. After that i tried menu_tray_tooltip with NoTrayIcon(apply_to_hotkeys_process=True) directive. So i got one icon with my text. Almost win. But there is one problem. That icon hasn't menu like initial icon with tip executor.ahk has. But i want to keep that menu.

And looks like to achieve that it must be changed tip of exactly that icon with executor.ahk text.

So i wrote new directive for that. And create this pull request to share it with all.

Example of usage:

from ahk.directives import TrayTip, ExecutorTrayTip

ahk = AHK(directives=[TrayTip('hello!', apply_to_hotkeys_process=True)], version='v2')

# or even simpler
ahk = AHK(directives=[ExecutorTrayTip('hello!')], version='v2')

# also as side effect it's possible to remove tip at all if state an empty string
ahk = AHK(directives=[ExecutorTrayTip('')], version='v2')
coveralls commented 6 months ago

Coverage Status

coverage: 77.359% (-0.05%) from 77.41% when pulling 2d9d64ebb14e0f1559711dcd065e1585b6901f23 on filantus:executor-tray-tip into 168c7536b4f1b26e2535d583286bfacb4365af6f on spyoungtech:main.

spyoungtech commented 6 months ago

Thanks for this. Though, I have some other thoughts on how this problem can be solved, and in a way that works when using both AutoHotkey v1 and v2, and perhaps also support other tray icon functionality. I've opened #303 to track this effort.