用tc的应该知道,tc可以设置一套快捷键一键切换到第N个标签,但是在实际使用过程中,看到标签后还要数是第几个,反而降低了效率。所以我用闲暇时间写了一个小脚本,常驻后台,自动给标签添加一个序号,方便切换。效果如图:
特别说明:为节省资源,脚本仅在启动时获取一次tc标签栏的HWND,建议将脚本放到autorun中与tc一起启动,已经添加了 #SingleInstance Force 语句,脚本不会重复启动。。否则每次重启tc后都需要重启一次脚本。
编译版下载地址:https://cdn.autoahk.com/wp-content/uploads/erphpdown/d911d62d25b0341ab8d2db7ffca1a789.exe
; 修改序号与目录名的分隔符号 global splitSymbol := "※" #Persistent #SingleInstance Force ;#NoTrayIcon ControlGet, hwnd1, Hwnd ,, TMyTabControl1, ahk_class TTOTAL_CMD a1 := applyProcessMemory(hwnd1) updateAll(hwnd1, a1) ControlGet, hwnd2, Hwnd ,, TMyTabControl2, ahk_class TTOTAL_CMD a2 := applyProcessMemory(hwnd2) updateAll(hwnd2, a2) ; 希望手动运行的可以注释掉下面这一行,实测内存占用2.4M,影响不大。 ; 手动运行的可以写一个em命令运行脚本,在所有自动切换模式里面加上这条em命令, ; 另外在自动切换模式最后新增一条 *\* SetTimer, Timer, 20 return Timer: if(WinActive("ahk_class TTOTAL_CMD")) { ControlGetFocus, OutputVar , ahk_class TTOTAL_CMD if(OutputVar = "TMyListBox2") { ControlGet, tabN, Tab,,,ahk_id %hwnd1% updateTabName(hwnd1, a1, tabN) } else if(OutputVar = "TMyListBox1") { ControlGet, tabN, Tab,,,ahk_id %hwnd2% updateTabName(hwnd2, a2, tabN) } } return updateAll(hwnd, argv){ SendMessage 0x1304,,,, ahk_id %hwnd% loop %ErrorLevel% { updateTabName(hwnd,argv, A_Index) } } updateTabName(hwnd, argv, tabN){ hproc := argv.hproc remote_item := argv.remote_item remote_text := argv.remote_text MAX_TEXT_SIZE := 260 * (A_IsUnicode ? 2 : 1) TCM_GETITEM := A_IsUnicode ? 0x133C : 0x1305 TCM_SETITEM := TCM_GETITEM + 1 VarSetCapacity(local_text, MAX_TEXT_SIZE) SendMessage TCM_GETITEM, tabN-1, remote_item,, ahk_id %hwnd% if (ErrorLevel = 1) DllCall("ReadProcessMemory", "ptr", hproc, "ptr", remote_text , "Str", local_text, "uptr", MAX_TEXT_SIZE, "ptr", 0) if (local_text ~= "\d+" . splitSymbol) return local_text := TabN . splitSymbol . local_text DllCall("WriteProcessMemory", "ptr", hproc, "ptr", remote_text , "Str", local_text, "uptr", MAX_TEXT_SIZE, "ptr", 0) SendMessage TCM_SETITEM, tabN-1, remote_item,, ahk_id %hwnd% } applyProcessMemory(hwnd){ static PROCESS_VM_OPERATION := 0x8 , PROCESS_VM_READ := 0x10 , PROCESS_VM_WRITE := 0x20 , READ_WRITE_ACCESS := PROCESS_VM_READ |PROCESS_VM_WRITE |PROCESS_VM_OPERATION , PROCESS_QUERY_INFORMATION := 0x400 , MAX_TEXT_LENGTH := 260 , MAX_TEXT_SIZE := MAX_TEXT_LENGTH * (A_IsUnicode ? 2 : 1) , MEM_COMMIT := 0x1000 , MEM_RELEASE := 0x8000 , PAGE_READWRITE := 4 , TCIF_TEXT := 1 , TCM_GETITEM := A_IsUnicode ? 0x133C : 0x1305 WinGet pid, PID, ahk_id %hwnd% hproc := DllCall("OpenProcess", "uint", READ_WRITE_ACCESS |PROCESS_QUERY_INFORMATION , "int", false, "uint", pid, "ptr") if A_Is64bitOS try DllCall("IsWow64Process", "ptr", hproc, "int*", is32bit := true) else is32bit := true RPtrSize := is32bit ? 4 : 8 TCITEM_SIZE := 16 + RPtrSize*3 remote_item := DllCall("VirtualAllocEx", "ptr", hproc, "ptr", 0 , "uptr", TCITEM_SIZE + MAX_TEXT_SIZE , "uint", MEM_COMMIT, "uint", PAGE_READWRITE, "ptr") remote_text := remote_item + TCITEM_SIZE VarSetCapacity(local_item, TCITEM_SIZE, 0) NumPut(TCIF_TEXT, local_item, 0, "uint") NumPut(remote_text, local_item, 8 + RPtrSize) NumPut(MAX_TEXT_LENGTH, local_item, 8 + RPtrSize*2, "int") VarSetCapacity(local_text, MAX_TEXT_SIZE) DllCall("WriteProcessMemory", "ptr", hproc, "ptr", remote_item , "ptr", &local_item, "uptr", TCITEM_SIZE, "ptr", 0) return {"hproc":hproc,"remote_item":remote_item, "remote_text":remote_text} }
好就没来了,想了想还是不弄收费模式了,有钱的大佬打赏一个呗。
搞得不错