-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
➕ Added ToolTip, TrayTip and return types to window functions #92
Conversation
ahk/gui.py
Outdated
def _show_traytip(self, title: str, text: str, second=1.0, type_id=1, slient=False, large_icon=False, blocking=True): | ||
"""Show TrayTip (Windows 10 toast notification) | ||
|
||
https://www.autohotkey.com/docs/commands/TrayTip.htm | ||
|
||
:param title: Title of notification | ||
:type title: str | ||
:param text: Content of notification | ||
:type text: str | ||
:param second: Wait time (s) to be disappeared, defaults to 1.0 | ||
:type second: float, optional | ||
:param type_id: Notification type `TRAYTIP_<type>`, defaults to 1 | ||
:type type_id: int, optional | ||
:param slient: Shows toast without sound, defaults to False | ||
:type slient: bool, optional | ||
:param large_icon: Shows toast with large icon, defaults to False | ||
:type large_icon: bool, optional | ||
""" | ||
|
||
option = type_id + (16 if slient else 0) + (32 if large_icon else 0) | ||
script = self.render_template("gui/traytip.ahk", title=title, text=text, second=second, option=option) | ||
self.run_script(script, blocking=blocking) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can not show "utf-8" text like şğüı
need help @spyoungtech
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a known limitation in several areas and has to do with how encoding is interpreted when sending the script via stdin, which may not be the same across systems. I have some theories on how AHK handles non-ascii input, but I haven't looked into much or confirmed; see #45
Currently, the best-supported method for non-ascii is to send along AHK-unicode sequences like {U+2F72}
. Can you give that a try and see if it works?
For example şğüı
might best be sent as {u+015f}{u+011f}{u+00fc}{u+0131}
If it works with the unicode escapes, I'm happy to merge in as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I didn't work 🤕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found some way to do this. When I send like this, it's work 🎉
- We may decode unicode
u'\U0001f618 \U0001f375'
toChr(0x1f618) Char(0x1f375)
# 😘 🍵 - Maybe this would helpfully
"🚀".encode("unicode_escape")
ref hval = hex(ord("🚀")) # '0x1f680'
we may use it forf"Chr({hval})"
ahk.show_tooltip('% Chr(0x1F680)') # Rocket 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, can you split out the tooltip/traytip changes and the return types for window functions into their own separate changesets and PRs? Thanks! |
This reverts commit d3627ea.
I reverted commit |
This reverts commit c9dea4c.
Could you make "Squash and merge" instead of "Merge" to show users tidy? |
encoded_title = "% " + "".join([f"Chr({hex(ord(char))})" for char in title]) | ||
encoded_text = "% " + "".join([f"Chr({hex(ord(char))})" for char in text]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unicode encoding for AHK
if id and not (1 <= int(id) <= 20): | ||
raise ValueError("ID value must be between [1, 20]") | ||
|
||
encoded_text = "% " + "".join([f"Chr({hex(ord(char))})" for char in text]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unicode encoding for AHK
ahk.show_tooltip("hello") | ||
ahk.show_tooltip("🚀 Hello unicode 🚀", second=2) | ||
ahk.show_tooltip("⽲ hello3", x=10, y=10) | ||
ahk.show_tooltip("hello4", second=2, x=10, y=10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unicode tooltip test
ahk._show_traytip("⽲ Normal 🚀", "It's me") | ||
ahk._show_traytip("🐌 Slow 🐌", "It's you", second=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unicode traytip test
I found some way to do this. When I send like this, it's work 🎉
ahk.show_tooltip('% Chr(0x1F680)') # Rocket 🚀 Finally, I found usable solution: from ahk import AHK
ahk = AHK()
string = 'Rocket 🚀 man'
ahk_string = "% "
for char in string:
hval = hex(ord(char))
ahk_string += f"Chr({hval})"
ahk.show_tooltip(ahk_string)
|
Hey, Could you check the PR 😕 @spyoungtech |
Hi @yedhrab apologies for the long delay. I'm not sure when I will be able to get around to this, but I'm hoping it will be some time in the next couple weeks for both the open PRs. But I haven't forgotten about this :) |
Thank you for the contribution @yedhrab I've squashed and merged to master and these changes will be included in the next release! Cheers, |
Released in v0.10.0 |
Hello, I came back ✋
➕ I added:
GUIMixin
structure alsogui.py
file and templates