Can the language be change Topic is solved
Can the language be change
I want to compile a script for my colleagues use, but some of them know little about English, so can the language be change?
- Attachments
-
- p33.png (11.86 KiB) Viewed 407 times
Re: Can the language be change
You can remove the existing tray menu items using A_TrayMenu.Delete and add your own menu items using any language. If you want it to do those same things, then you would just need to add your own functions that do those same things that those menu items would invoke.
Re: Can the language be change
Code: Select all
/*
Please refer to the better code below.
*/
Last edited by Seven0528 on 28 Mar 2024, 20:19, edited 3 times in total.
- English is not my native language. Please forgive any awkward expressions.
- 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
Re: Can the language be change
There is no need to hook the tray icon message. You can just rename the tray menu items with A_TrayMenu.Rename() when the script starts.
Re: Can the language be change
In this case, while that may be true,
I also wanted to be helpful in situations where users may want to replace it with a custom menu, as @boiler mentioned...
(However, placing the A_TrayMenu.Rename() method at the top would have improved readability, it's my fault.)
I also wanted to be helpful in situations where users may want to replace it with a custom menu, as @boiler mentioned...
(However, placing the A_TrayMenu.Rename() method at the top would have improved readability, it's my fault.)
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance
persistent
onMessage(0x0404,AHK_NOTIFYICON)
customMenu:=menu()
customMenu.add("&AutoHotkey 论坛链接",runAutoHotkeyForumLink)
customMenu.add("程序关闭(&X)",(*)=>ExitApp())
AHK_NOTIFYICON(wParam, lParam, Msg, hWnd) {
switch (lParam)
{
case 0x0205: ; RButton Up
setTimer notifyIconRbuttonUp, -1
return true
}
}
notifyIconRbuttonUp() {
customMenu.show()
}
runAutoHotkeyForumLink(itemName, itemPos, myMenu) {
try run("https://www.autohotkey.com/boards/")
}
- English is not my native language. Please forgive any awkward expressions.
- 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
Re: Can the language be change Topic is solved
@songdg
The image you provided shows the WeChat icon in the system tray.
It seems you might be Chinese, so I've rewritten it in Chinese. Hope that helps.
看您提供的图片,托盘图标中有微信。
看起来您可能是中国人,我尝试重新用中文写了一遍。希望有所帮助。
The image you provided shows the WeChat icon in the system tray.
It seems you might be Chinese, so I've rewritten it in Chinese. Hope that helps.
看您提供的图片,托盘图标中有微信。
看起来您可能是中国人,我尝试重新用中文写了一遍。希望有所帮助。
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance
persistent
onMessage(0x0404,AHK_NOTIFYICON)
if (!A_IsCompiled) {
A_TrayMenu.rename("&Help", "帮助(&H)")
A_TrayMenu.rename("&Window Spy", "应用程序窗口监视器(&W)")
A_TrayMenu.rename("&Reload Script", "重新加载程序(&R)")
A_TrayMenu.rename("&Edit Script", "编辑程序(&E)")
}
A_TrayMenu.rename("&Suspend Hotkeys", "暂停热键(&S)")
A_TrayMenu.rename("&Pause Script", "暂停程序(&P)")
A_TrayMenu.rename("E&xit", "退出(&X)")
AHK_NOTIFYICON(wParam, lParam, Msg, hWnd) {
switch (lParam)
{
case 0x0205: ; RButton Up
setTimer notifyIconRbuttonUp, -1
return true
}
}
notifyIconRbuttonUp() {
try A_TrayMenu.rename("&Open", "打开(&O)")
A_TrayMenu.show()
}
; F5::A_AllowMainWindow:=!A_AllowMainWindow
Last edited by Seven0528 on 28 Mar 2024, 20:17, edited 3 times in total.
- English is not my native language. Please forgive any awkward expressions.
- 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
Re: Can the language be change
It might be helpful to someone, but I think it just distracts from the actual answer to the original question (which you did include in your example, so don't take my criticism harshly). boiler did not mention replacing the tray menu, but modifying it; replacing the items within A_TrayMenu. You can just remove all of the standard items and add your own, without ever needing to use OnMessage.
Re: Can the language be change
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance
persistent
A_TrayMenu.delete()
A_TrayMenu.add("&AutoHotkey 论坛链接",runAutoHotkeyForumLink)
A_TrayMenu.add("程序关闭(&X)",(*)=>ExitApp())
runAutoHotkeyForumLink(itemName, itemPos, myMenu) {
try run("https://www.autohotkey.com/boards/")
}
Oh, honestly, I didn't think about changing A_TrayMenu itself. That's much simpler.
Thank you for the advice!
- English is not my native language. Please forgive any awkward expressions.
- 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
Re: Can the language be change
非常感激您的帮助Seven0528 wrote: ↑28 Mar 2024, 19:46@songdg
The image you provided shows the WeChat icon in the system tray.
It seems you might be Chinese, so I've rewritten it in Chinese. Hope that helps.
看您提供的图片,托盘图标中有微信。
看起来您可能是中国人,我尝试重新用中文写了一遍。希望有所帮助。Code: Select all
#Requires AutoHotkey v2.0 #SingleInstance persistent onMessage(0x0404,AHK_NOTIFYICON) if (!A_IsCompiled) { A_TrayMenu.rename("&Help", "帮助(&H)") A_TrayMenu.rename("&Window Spy", "应用程序窗口监视器(&W)") A_TrayMenu.rename("&Reload Script", "重新加载程序(&R)") A_TrayMenu.rename("&Edit Script", "编辑程序(&E)") } A_TrayMenu.rename("&Suspend Hotkeys", "暂停热键(&S)") A_TrayMenu.rename("&Pause Script", "暂停程序(&P)") A_TrayMenu.rename("E&xit", "退出(&X)") AHK_NOTIFYICON(wParam, lParam, Msg, hWnd) { switch (lParam) { case 0x0205: ; RButton Up setTimer notifyIconRbuttonUp, -1 return true } } notifyIconRbuttonUp() { try A_TrayMenu.rename("&Open", "打开(&O)") A_TrayMenu.show() } ; F5::A_AllowMainWindow:=!A_AllowMainWindow
Re: Can the language be change
Thank you very much indeedboiler wrote: ↑28 Mar 2024, 02:22You can remove the existing tray menu items using A_TrayMenu.Delete and add your own menu items using any language. If you want it to do those same things, then you would just need to add your own functions that do those same things that those menu items would invoke.
Who is online
Users browsing this forum: Daniel_San and 41 guests