Skip to content

Commit 367db85

Browse files
committed
implement custom tray tip text
1 parent 16bb96b commit 367db85

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

ahk/_async/engine.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,18 @@ async def show_tooltip(
13671367
async def hide_tooltip(self, which: int = 1) -> None:
13681368
await self.show_tooltip(which=which)
13691369

1370+
async def menu_tray_tooltip(self, value: str) -> None:
1371+
"""
1372+
Change the menu tray icon tooltip that appears when hovering the mouse over the tray icon.
1373+
Does not affect tray icon for AHK processes started with :py:meth:`run_script` or ``blocking=False``
1374+
1375+
Uses the `Tip subcommand <https://www.autohotkey.com/docs/v1/lib/Menu.htm#Tip>`_
1376+
"""
1377+
1378+
args = [value]
1379+
await self._transport.function_call('AHKMenuTrayTip', args)
1380+
return None
1381+
13701382
# fmt: off
13711383
@overload
13721384
async def sound_beep(self, frequency: int = 523, duration: int = 150) -> None: ...

ahk/_async/transport.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def result(self, timeout: Optional[float] = None) -> T_SyncFuture:
9595
'AHKImageSearch',
9696
'AHKKeyState',
9797
'AHKKeyWait',
98+
'AHKMenuTrayTip',
9899
'AHKMouseClickDrag',
99100
'AHKMouseGetPos',
100101
'AHKMouseMove',
@@ -565,7 +566,8 @@ async def function_call(self, function_name: Literal['AHKRegRead'], args: Option
565566
async def function_call(self, function_name: Literal['AHKRegWrite'], args: Optional[List[str]] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
566567
@overload
567568
async def function_call(self, function_name: Literal['AHKRegDelete'], args: Optional[List[str]] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
568-
569+
@overload
570+
async def function_call(self, function_name: Literal['AHKMenuTrayTip'], args: Optional[List[str]] = None, *, blocking: bool = True) -> Union[None, AsyncFutureResult[None]]: ...
569571
# fmt: on
570572

571573
async def function_call(

ahk/_constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,12 @@
26032603
return FormatNoValueResponse()
26042604
}
26052605
2606+
AHKMenuTrayTip(ByRef command) {
2607+
value := command[2]
2608+
Menu, Tray, Tip, %value%
2609+
return FormatNoValueResponse()
2610+
}
2611+
26062612
b64decode(ByRef pszString) {
26072613
; TODO load DLL globally for performance
26082614
; REF: https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptstringtobinaryw

ahk/_sync/engine.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,18 @@ def show_tooltip(
13561356
def hide_tooltip(self, which: int = 1) -> None:
13571357
self.show_tooltip(which=which)
13581358

1359+
def menu_tray_tooltip(self, value: str) -> None:
1360+
"""
1361+
Change the menu tray icon tooltip that appears when hovering the mouse over the tray icon.
1362+
Does not affect tray icon for AHK processes started with :py:meth:`run_script` or ``blocking=False``
1363+
1364+
Uses the `Tip subcommand <https://www.autohotkey.com/docs/v1/lib/Menu.htm#Tip>`_
1365+
"""
1366+
1367+
args = [value]
1368+
self._transport.function_call('AHKMenuTrayTip', args)
1369+
return None
1370+
13591371
# fmt: off
13601372
@overload
13611373
def sound_beep(self, frequency: int = 523, duration: int = 150) -> None: ...

ahk/_sync/transport.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def result(self, timeout: Optional[float] = None) -> T_SyncFuture:
8787
'AHKImageSearch',
8888
'AHKKeyState',
8989
'AHKKeyWait',
90+
'AHKMenuTrayTip',
9091
'AHKMouseClickDrag',
9192
'AHKMouseGetPos',
9293
'AHKMouseMove',
@@ -546,7 +547,8 @@ def function_call(self, function_name: Literal['AHKRegRead'], args: Optional[Lis
546547
def function_call(self, function_name: Literal['AHKRegWrite'], args: Optional[List[str]] = None, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
547548
@overload
548549
def function_call(self, function_name: Literal['AHKRegDelete'], args: Optional[List[str]] = None, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
549-
550+
@overload
551+
def function_call(self, function_name: Literal['AHKMenuTrayTip'], args: Optional[List[str]] = None, *, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
550552
# fmt: on
551553

552554
def function_call(

ahk/templates/daemon.ahk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,12 @@ AHKBlockInput(ByRef command) {
26002600
return FormatNoValueResponse()
26012601
}
26022602

2603+
AHKMenuTrayTip(ByRef command) {
2604+
value := command[2]
2605+
Menu, Tray, Tip, %value%
2606+
return FormatNoValueResponse()
2607+
}
2608+
26032609
b64decode(ByRef pszString) {
26042610
; TODO load DLL globally for performance
26052611
; REF: https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptstringtobinaryw

0 commit comments

Comments
 (0)