阅读:299回复:2
[分享] 使用$GO通道輸出功能調用AutoHotkey v2 Script
測試了$GO()的通道輸出功能,以AutoHotkey v2腳本撰寫,執行前必須安裝AutoHotkey v2環境。
AutoHotkey V2 script (副檔名可自行修改為.ahk) get-date.ahk2: #Requires AutoHotkey v2.0 #SingleInstance Force sDayDiff := A_Args[1] iDayDiff := Integer(sDayDiff) sFormat := A_Args[2] sDateAfterDiff := DateAdd(A_Now, iDayDiff, "days") sDate := "" if (sFormat == "C") { sDate := FormatTime(sDateAfterDiff, "yyyy年MM月dd日") } else if (sFormat == "R") { sYear := FormatTime(sDateAfterDiff, "yyyy") sYear := String(Integer(sYear) - 1911) sDate := sYear . "年" . FormatTime(sDateAfterDiff, "MM月dd日") } else if (sFormat == "E") { sDate := FormatTime(sDateAfterDiff, "yyyy-MM-dd") } ;A_Clipboard := sDate FileAppend sDate , "*"碼表裡的編碼: #get-date.ahk2 日數 格式(C/E/R) zdd $[明天(中式)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_1$_C) zdd $[明天(西式)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_1$_E) zdd $[明天(ROC)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_1$_R) zdd $[今天(中式)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_0$_C) zdd $[今天(西式)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_0$_E) zdd $[今天(ROC)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_0$_R) zdd $[昨天(中式)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_-1$_C) zdd $[昨天(西式)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_-1$_E) zdd $[昨天(ROC)]$GO(|c:\Program$_Files\autohotkey\autohotkey64.exe$_j:\ahk2\get-date.ahk2$_-1$_R)執行結果: |
|
|
板凳#
发布于:2024-10-23 12:27
範例2
將剪貼簿裡的字串內的半形標點符號替換成全形標點符號後直接輸出。 使用OCR工具擷取到的文字標點大半都是半形,透過自訂編碼替換成全形標點。 AutoHotkey V2 script yong-replace.ahk2 (副檔名可自行修改為.ahk) : #Requires AutoHotkey v2.0 #SingleInstance Force /** * @version: 2024-10-23 09:06:37 * @author: Jerry * @Purpose: AutoHotkey v2 script. Called by Yong IME. * @example: * zrpf $[替換成全形標點]$GO(|c:\util\AHK\autohotkey64.exe$_j:\ahk2\yong-replace.ahk2$_$CLIPBOARD$_F)$SPACE * zrph $[替換成半形標點]$GO(|c:\util\AHK\autohotkey64.exe$_j:\ahk2\yong-replace.ahk2$_$CLIPBOARD$_H)$SPACE */ sMsg := A_Args[1] sFormat := A_Args[2] aHalfShapes := [ ",", ".", ":", "?" ] aFullShapes := [ ",", "。", ":", "?" ] if (sFormat == "H") { ; to Half shape aFromShapes := aFullShapes aToShapes := aHalfShapes } else { ; to Full shape aFromShapes := aHalfShapes aToShapes := aFullShapes } for sFromItem in aFromShapes { sToItem := aToShapes[A_Index] sMsg := StrReplace(sMsg, sFromItem, sToItem) } FileAppend sMsg, "*" 碼表裡的編碼: zrpf $[替換成全形標點]$GO(|c:\util\AHK\autohotkey64.exe$_j:\ahk2\yong-replace.ahk2$_$CLIPBOARD$_F)$SPACE zrph $[替換成半形標點]$GO(|c:\util\AHK\autohotkey64.exe$_j:\ahk2\yong-replace.ahk2$_$CLIPBOARD$_H)$SPACE 原文字: 曾子曰:「吾日三省吾身,為人謀而不忠乎?與朋友交而不信乎?傳不習乎?」 調用腳本轉換後: 曾子曰:「吾日三省吾身,為人謀而不忠乎?與朋友交而不信乎?傳不習乎?」 |
|
|