调用tcmatch的简单示例

=""){ Loop, Read, C:\Users\Administrator\Desktop\test.txt { if (tcmatch(A_LoopReadLine,ma)) out.=A_LoopReadLine . "rn" }

tc群友问如何调用tcmatch实现首字母简拼搜索

写了这个示例,自备dll文件

; Generated by Auto-GUI 3.0.1
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
  dllPath:="C:\AHK\Lib\tcmatch\tcmatch.dll"
  out:=""

; FileDelete, C:\Users\Administrator\Desktop\test.txt ; 删除文件内容,如果文件不存在则忽略此步骤
; FileAppend, %test%, C:\Users\Administrator\Desktop\test.txt ; 将变量内容写入文件
FileRead, fileData, C:\Users\Administrator\Desktop\test.txt

Gui Font, s9, Segoe UI
Gui Add, Edit, h40 w300 gmatch vma,
Gui Add, Edit, h300 w300 gsubmit vfileData,%fileData%
Gui Show,,中文模糊搜索
Return
submit: 
    gui,Submit,NoHide
    FileDelete, C:\Users\Administrator\Desktop\test.txt
    FileAppend, %fileData%, C:\Users\Administrator\Desktop\test.txt
return
match:
out:=""
ToolTip
gui,Submit,NoHide
if (ma!=""){
Loop, Read, C:\Users\Administrator\Desktop\test.txt
{
  if (tcmatch(A_LoopReadLine,ma))
    out.=A_LoopReadLine . "`r`n"
}
}else
  ToolTip
ToolTip,%out%
return


GuiEscape:
GuiClose:
    ExitApp

TCMatchOn(dllPath = "") {
    if(g_TCMatchModule)
        return g_TCMatchModule
	g_TCMatchModule := DllCall("LoadLibrary", "Str", dllPath, "Ptr")
    return g_TCMatchModule
}

TCMatchOff() {
    DllCall("FreeLibrary", "Ptr", g_TCMatchModule)
    g_TCMatchModule := ""
}

TCMatch(aHaystack, aNeedle) {
	static MatchFileW, g_TCMatchModule
	MatchFileW := (A_PtrSize == 8 ) ? "TCMatch64\MatchFileW" : "TCMatch\MatchFileW"
	SplitPath A_AhkPath,, OutDir
	dllPath := OutDir "\Lib\tcmatch\" ((A_PtrSize == 8 ) ? "TCMatch64" : "TCMatch") ".dll"
	g_TCMatchModule := TCMatchOn(dllPath)
    Return DllCall(MatchFileW, "WStr", aNeedle, "WStr", aHaystack)
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA捐赠
共{{data.count}}人
人已捐赠
AI 自动化其他

ai命令整理 ----run-系统应用(自带软件)、命令全整理

2025-7-17 19:16:24

AI 自动化教程

AI 改你的 AutoHotkey 大脚本,最烧的不是钱而是「上下文」:jCodeMunch 给 Claude Code / Cursor 装上按符号精确取码,原生支持 AHK v2(省 90%+ token,附可运行的本地索引脚本)

2026-11-8 21:18:12

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
❯
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索