Page 1 of 1

Can the language be change

Posted: 28 Mar 2024, 02:07
by songdg
I want to compile a script for my colleagues use, but some of them know little about English, so can the language be change?

Re: Can the language be change

Posted: 28 Mar 2024, 02:22
by boiler
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

Posted: 28 Mar 2024, 02:40
by Seven0528

Code: Select all

/*
Please refer to the better code below.
*/

Re: Can the language be change

Posted: 28 Mar 2024, 18:59
by lexikos
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

Posted: 28 Mar 2024, 19:03
by Seven0528
 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.)

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/")
}

Re: Can the language be change  Topic is solved

Posted: 28 Mar 2024, 19:46
by Seven0528
 @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

Posted: 28 Mar 2024, 19:54
by lexikos
Seven0528 wrote:
28 Mar 2024, 19:03
I also wanted to be helpful in situations where users may want to replace it with a custom menu, as @boiler mentioned...
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

Posted: 28 Mar 2024, 20:10
by Seven0528

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/")
}
 @lexikos
Oh, honestly, I didn't think about changing A_TrayMenu itself. That's much simpler.
Thank you for the advice!

Re: Can the language be change

Posted: 28 Mar 2024, 21:05
by songdg
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
非常感激您的帮助 :bravo:

Re: Can the language be change

Posted: 28 Mar 2024, 21:07
by songdg
boiler wrote:
28 Mar 2024, 02:22
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.
Thank you very much indeed :D

Re: Can the language be change

Posted: 28 Mar 2024, 21:12
by songdg
lexikos wrote:
28 Mar 2024, 18:59
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.
You're right, a simple rename of the tray menu items would pretty much suit my need.