Can the language be change Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
songdg
Posts: 575
Joined: 04 Oct 2017, 20:04

Can the language be change

Post by songdg » 28 Mar 2024, 02:07

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
p33.png (11.86 KiB) Viewed 266 times

User avatar
boiler
Posts: 16983
Joined: 21 Dec 2014, 02:44

Re: Can the language be change

Post by boiler » 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.

User avatar
Seven0528
Posts: 345
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: Can the language be change

Post by Seven0528 » 28 Mar 2024, 02:40

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.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.

lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Can the language be change

Post by lexikos » 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.

User avatar
Seven0528
Posts: 345
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: Can the language be change

Post by Seven0528 » 28 Mar 2024, 19:03

 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/")
}
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.

User avatar
Seven0528
Posts: 345
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: Can the language be change  Topic is solved

Post by Seven0528 » 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
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.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.

lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Can the language be change

Post by lexikos » 28 Mar 2024, 19:54

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.

User avatar
Seven0528
Posts: 345
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: Can the language be change

Post by Seven0528 » 28 Mar 2024, 20:10

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!
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.

songdg
Posts: 575
Joined: 04 Oct 2017, 20:04

Re: Can the language be change

Post by songdg » 28 Mar 2024, 21:05

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:

songdg
Posts: 575
Joined: 04 Oct 2017, 20:04

Re: Can the language be change

Post by songdg » 28 Mar 2024, 21:07

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

songdg
Posts: 575
Joined: 04 Oct 2017, 20:04

Re: Can the language be change

Post by songdg » 28 Mar 2024, 21:12

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.

Post Reply

Return to “Ask for Help (v2)”