Skip to content

Commit

Permalink
Tray menu and v2.4.0-hotfix (#14)
Browse files Browse the repository at this point in the history
* 增加任务栏托盘菜单

* add the winspy tool to the tray menu

* 命令输入终止符超时处理办法
  • Loading branch information
zedeeee authored Jun 6, 2024
1 parent e2466d0 commit f8cf833
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Lib/CAT_Automatic.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ cat_command_execution(input_string, command_ini, power_input_hwnd)
}

ControlSetText("c:" . command_id_and_cb_array[1], power_input_hwnd)
SendMessage(0x0100, 0xD, 0, power_input_hwnd)

; timeout handling
try
SendMessage(0x0100, 0xD, 0, power_input_hwnd, , , , , 60000)
catch Error as e
{
k_ToolTip("错误:" . e.What e.Message, 2000)
}

if command_id_and_cb_array.Length == 2
{
Expand Down
158 changes: 158 additions & 0 deletions Lib/tray_menu.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#Requires AutoHotkey v2.0

#Include stdio.ahk


global ESC_CLEAN_FUNC_ENABLE_FLAG := 0

showProjectHomepage_cb(*) {
Run "https://github.com/zedeeee/UCLC"
}

help_Homepage_cb(*) {
Run "https://github.com/zedeeee/UCLC-config"
}

modify_alias_cb(*)
{
Run "notepad " alias_ini_path
}

modify_shortcut_cb(*)
{
Run "notepad " hotkey_ini_path
}

about_cb(*)
{
arr := StrSplit(menu_items[1][1], "v")
version := arr[arr.Length]
MsgBox Format("一个CATIA快捷键脚本`n使CATIA的操作体验更接近AutoCAD`n版本:{1}", version), "UCLC", 0x40

}

update_check_cb(*)
{
}

esc_enhanced_cb(ItemName, ItemPos, MyMenu)
{
global ESC_CLEAN_FUNC_ENABLE_FLAG := Mod(ESC_CLEAN_FUNC_ENABLE_FLAG + 1, 2)
MyMenu.ToggleCheck(ItemName)
if ESC_CLEAN_FUNC_ENABLE_FLAG
{
MsgBox("已开启 ESC 清除命令输入框功能`n开发阶段功能请酌情使用", "UCLC - ESC增强", 0x40)
}
}

reload_cb(*) {
Reload
}

disable_script_cb(ItemName, ItemPos, MyMenu)
{
menu_toggleCheck_cb(ItemName, ItemPos, MyMenu)
Suspend(-1)
}

exit_cb(*) {
ExitApp
}

menu_toggleCheck_cb(ItemName, ItemPos, MyMenu)
{
MyMenu.ToggleCheck(ItemName)
}


NoAction_cb(*) {
; Do Nothing
k_ToolTip("功能未开放", 2000)
}

run_spy_cb(*)
{
win_spy_path := RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoHotkey", "InstallDir") . "\UX\WindowSpy.ahk"
Run(win_spy_path)
}

disable_botton_cb(ItemName, ItemPos, MyMenu) {
MyMenu.Disable(ItemName)
}

add_sub_menu(ItemName, ItemPos, MyMenu) {

}

about_and_updates_menu := [
["关于", about_cb, ""],
["项目主页", showProjectHomepage_cb, ""],
["自定义帮助", help_Homepage_cb, ""],
; ["检查更新", NoAction_cb, ""]
]

dev_sub_menu := [
["ESC增强", esc_enhanced_cb, ""],
]

/**
* ["按钮名称", 回调函数, 子菜单数组]
*/
menu_items := [
["UCLC v2.4.0", NoAction_cb, about_and_updates_menu],
["", NoAction_cb, ""],
["自定义别名", modify_alias_cb, ""],
["自定义快捷键", modify_shortcut_cb, ""],
["开发功能", NoAction_cb, dev_sub_menu],
["", NoAction_cb, ""],
; ["配置", disable_botton_cb, ""],
["Windows Spy", run_spy_cb, ""],
["重新载入", reload_cb, ""],
["禁用脚本", disable_script_cb, ""],
["退出", exit_cb, ""]
]


add_coustom_tray_menu()
{
TraySetIcon("./icon/color-icon64.png")

A_IconTip := "UCLC: 像AutoCAD一样使用CATIA"

cus_tray_menu := Menu()

A_TrayMenu.Delete()

for menu_item in menu_items
{
button_name := menu_item[1]
callback_function := menu_item[2]
sub_menu_items := menu_item[3]

if button_name == ""
{
A_TrayMenu.Add()
continue
}

; 如果子菜单不为空, 开始注册子菜单
if sub_menu_items != ""
{
parent_button_name := button_name
sub_menu_name := [button_name . "_sub_menu"]
sub_menu_name[1] := Menu()

for sub_menu_item in sub_menu_items
{
sub_button_name := sub_menu_item[1]
sub_callback_function := sub_menu_item[2]
sub_menu_name[1].Add(sub_button_name, sub_callback_function)
}
A_TrayMenu.Add(parent_button_name, sub_menu_name[1])
continue
}
A_TrayMenu.Add(button_name, callback_function)

}
A_TrayMenu.Rename(menu_items[1][1], "UCLC")
}
7 changes: 4 additions & 3 deletions UCLC.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ SetTitleMatchMode 2
#Include ./Lib/string.ahk
#Include ./Lib/AHK_LOG.ahk
#Include ./Lib/CAT_Automatic.ahk
#Include ./Lib/tray_menu.ahk

TraySetIcon("./icon/color-icon64.png")
add_coustom_tray_menu()

global config_ini_path := ".\config.ini"
global alias_ini_path := GET_USER_CONFIG_INI_PATH("用户别名")
global hotkey_ini_path := GET_USER_CONFIG_INI_PATH("快捷键")
global DEBUG_I := IniRead(config_ini_path, "通用", "DEBUG")
global workbench_list := Map()
global current_workbench := ""
global ESC_CLEAN_FUNC_ENABLE_FLAG := ""
; global ESC_CLEAN_FUNC_ENABLE_FLAG := ""

; 检查 USER-CONFIG文件
user_config_exist_remind(alias_ini_path)

ESC_CLEAN_FUNC_ENABLE_FLAG := init_dev_func_prompt(config_ini_path, "ESC_CLEAN", "ESC 键清除 POWER-INPUT (CATIA 有崩溃风险)")
; ESC_CLEAN_FUNC_ENABLE_FLAG := init_dev_func_prompt(config_ini_path, "ESC_CLEAN", "ESC 键清除 POWER-INPUT (CATIA 有崩溃风险)")

; 创建 计算器 组
GroupAdd "group_calc", "计算器"
Expand Down

0 comments on commit f8cf833

Please sign in to comment.