DaZuo OCR Setup Guide
按鍵精靈 + 大漠 Plugin + 打坐 OCR Script 安裝教程
適用於 Windows XP VM / VirtualBox、X-MudClient、按鍵精靈 2014。照步驟完成即可運行 DaZuo OCR script,OCR 自動讀取內力與氣,全程自動打坐衝內力。
0. 下載檔案
| 項目 | 來源 | 安裝位置 / 檔名 |
|---|---|---|
| 按鍵精靈 / 按精 | download.myanjian.com | 安裝到預設位置 |
| 大漠 Plugin(含註冊插件) | 下載 dm-regdll-plugin.zip | 解壓後:dm.dll 放入 C:\dm\;RegDll.dll 放入按鍵精靈 Plugin 資料夾 |
| OCR 字庫 | 下載 mud_num.txt | 放入 C:\dm\mud_num.txt |
| DaZuo OCR Script | 下載 dazuo-ocr-script.txt | 貼到按鍵精靈新腳本 |
1. Windows XP 顯示設定
- 在桌面按右鍵,選擇 內容。
- 進入 主題 分頁。
- 主題選擇 Windows 傳統配色。
- 進入 設定值 分頁。
- 螢幕解析度設定為 1280 × 960。
- 色彩品質設定為 最高(32 位元)。
- 按 套用,再按 確定。
2. 安裝按鍵精靈
- 開啟 download.myanjian.com。
- 下載並安裝 PC 版按鍵精靈。
- 安裝完成後,先關閉按鍵精靈。
- 之後每次運行按鍵精靈,使用 以系統管理員身份執行。
3. 安裝大漠 Plugin
- 建立資料夾:
C:\dm - 把
dm.dll放入C:\dm。 - 確認有:
C:\dm\dm.dll - 把
RegDll.dll複製到按鍵精靈的Plugin資料夾。 - 常見路徑如下,選擇你電腦實際存在的資料夾:
C:\Program Files\按键精灵2014\Plugin C:\Program Files (x86)\按键精灵2014\Plugin C:\按键精灵2014\Plugin\
- 把 OCR 字庫放到:
C:\dm\mud_num.txt
4. 測試大漠 Plugin
- 用系統管理員身份打開按鍵精靈。
- 新建一個測試腳本。
- 貼上以下測試碼。
- 按 調試 / F10。
Call Plugin.RegDll.Reg("C:\dm\dm.dll")
Set dm = CreateObject("dm.dmsoft")
dm.SetPath "C:\dm"
TracePrint "大漠版本: " & dm.Ver()成功時,調試訊息會顯示:
大漠版本: 3.1233 或其他大漠版本號。5. 放置 OCR 字庫
- 下載 mud_num.txt。
- 放入:
C:\dm\mud_num.txt - 確認檔名與路徑完全正確(小寫
mud_num.txt)。
6. 測試 OCR 讀數
- 打開 X-MudClient。
- 確保左側狀態欄可見。
- 確保 內力 和 氣 數字可見。
- 新建一個 OCR 測試腳本。
- 貼上以下測試碼。
- 執行後,按提示把滑鼠移到 X-MudClient 視窗內,再按確定。
Call Plugin.RegDll.Reg("C:\dm\dm.dll")
Set dm = CreateObject("dm.dmsoft")
dm.SetPath "C:\dm"
TracePrint "大漠版本: " & dm.Ver()
retDict = dm.SetDict(0, "mud_num.txt")
dm.UseDict 0
TracePrint "SetDict ret: " & retDict
If retDict <> 1 Then
TracePrint "字庫載入失敗,請確認 C:\dm\mud_num.txt 是否存在。"
EndScript
End If
Function OnlyDigits(s)
result = ""
For i = 1 To Len(s)
ch = Mid(s, i, 1)
If ch >= "0" And ch <= "9" Then
result = result & ch
End If
Next
OnlyDigits = result
End Function
Function OCRToNumber(s)
cleanText = OnlyDigits(s)
If cleanText = "" Then
OCRToNumber = -1
ElseIf IsNumeric(cleanText) Then
OCRToNumber = CLng(cleanText)
Else
OCRToNumber = -1
End If
End Function
Function OcrWithFallback(x1, y1, x2, y2, normalColor, redColor, simValue)
normalText = dm.Ocr(x1, y1, x2, y2, normalColor, simValue)
normalNum = OCRToNumber(normalText)
If normalNum >= 0 Then
OcrWithFallback = normalText
Exit Function
End If
TracePrint "正常色 OCR 失敗,嘗試紅色 OCR。"
redText = dm.Ocr(x1, y1, x2, y2, redColor, simValue)
OcrWithFallback = redText
End Function
MsgBox "請將滑鼠移到 X-MudClient 遊戲視窗入面,然後按確定。"
hwnd = dm.GetMousePointWindow()
If hwnd = 0 Then
TracePrint "無法取得 X-MudClient 視窗。"
EndScript
End If
ret = dm.GetWindowRect(hwnd, winX1, winY1, winX2, winY2)
normalNeiLiColor = "5ac7ff-303030|45c7ff-303030|40cfff-303030"
normalQiColor = "00ff00-303030|63ef63-303030|40ff40-303030|00cc00-303030"
redNumColor = "ff0000-303030|ff3333-303030|ff5555-303030|cc0000-303030"
ocrSimilarity = 0.90
rawNeiLiCurrent = OcrWithFallback(winX1 + 28, winY1 + 111, winX1 + 66, winY1 + 132, normalNeiLiColor, redNumColor, ocrSimilarity)
rawNeiLiMax = OcrWithFallback(winX1 + 68, winY1 + 111, winX1 + 120, winY1 + 132, normalNeiLiColor, redNumColor, ocrSimilarity)
rawQiCurrent = OcrWithFallback(winX1 + 25, winY1 + 146, winX1 + 66, winY1 + 168, normalQiColor, redNumColor, ocrSimilarity)
rawQiMax = OcrWithFallback(winX1 + 68, winY1 + 146, winX1 + 126, winY1 + 168, normalQiColor, redNumColor, ocrSimilarity)
TracePrint "OCR raw 目前內力: " & rawNeiLiCurrent
TracePrint "OCR raw Max 內力: " & rawNeiLiMax
TracePrint "OCR raw 目前氣: " & rawQiCurrent
TracePrint "OCR raw Max 氣: " & rawQiMax
TracePrint "OCR parsed 目前內力: " & OCRToNumber(rawNeiLiCurrent)
TracePrint "OCR parsed Max 內力: " & OCRToNumber(rawNeiLiMax)
TracePrint "OCR parsed 目前氣: " & OCRToNumber(rawQiCurrent)
TracePrint "OCR parsed Max 氣: " & OCRToNumber(rawQiMax)成功時會讀到:目前內力、Max 內力、目前氣、Max 氣。
7. 安裝正式 DaZuo Script
- 在按鍵精靈新建腳本。
- 下載 dazuo-ocr-script.txt,並把全部內容貼入。
- 保存腳本。
- 確認 script 內以下設定存在:
cmdYaoJiu = "USE 藥酒" afterDazuoYaoJiuCount = 5 cmdGuanDongZhu = "USE 關東煮" guanDongZhuCooldownSec = 60 recoverTickSec = 15 dazuoRecoverTickSafetyLoss = 1 ocrSimilarity = 0.9 targetMaxNeiLi = 9999
- 確認 Max 內力 OCR 座標使用:
rawNeiLiMax = OcrWithFallback(winX1 + 68, winY1 + 111, winX1 + 120, winY1 + 132, normalNeiLiColor, redNumColor, ocrSimilarity)
- 確認 Max 氣 OCR 座標使用:
rawQiMax = OcrWithFallback(winX1 + 68, winY1 + 146, winX1 + 126, winY1 + 168, normalQiColor, redNumColor, ocrSimilarity)
8. 正式運行
- 打開 X-MudClient。
- 登入角色。
- 打開左側狀態欄。
- 確認內力和氣數字可見。
- 打開按鍵精靈。
- 選擇 DaZuo OCR script。
- 按 啟動 / F10。
- 輸入是否轉生:
1或0。 - 輸入內功等級。
- 彈窗出現時,把滑鼠移到 X-MudClient 視窗內。
- 按確定。
- 觀察調試訊息。
9. 正常運行時的調試訊息
畫面數值更新成功。 內力: xxxx / xxxx 氣: xxxx / xxxx 單次 DaZuo 可用上限: xxxx 發送指令: DaZuo xxxx DaZuo 完成後固定飲藥酒。 OCR 確認突破成功。
10. 常見處理
| 情況 | 直接處理 |
|---|---|
SetDict ret: 0 | 確認 C:\dm\mud_num.txt 存在。 |
| 讀不到大漠版本 | 用系統管理員身份開按鍵精靈,確認 C:\dm\dm.dll 存在。 |
| 找不到 X-MudClient 視窗 | 彈窗時把滑鼠移到 X-MudClient 視窗內。 |
| Max 內力讀錯 | 確認使用 winX1 + 68 至 winX1 + 120。 |
| Max 氣讀錯 | 確認使用 winX1 + 68 至 winX1 + 126。 |
| 紅色數字讀不到 | 使用提供的新版 mud_num.txt。 |
| OCR 讀到亂碼 | 確認 Windows XP 解析度是 1280 × 960,色彩是 最高 32 位元。 |
11. 備份
設定完成後,備份以下檔案:
C:\dm\dm.dll C:\dm\mud_num.txt DaZuo OCR script 按鍵精靈腳本檔