支援Unicode的Autohotkey終於浮上抬面!
因為重新安裝家用舊的HP筆電,在下載Autohotkey時發現Unicode的版本已經出現在官方下載網頁裡了!原來這個Unicode版本是由Lexikos開發的分支,其開發沿革在這篇AutoHotkey_L:支持unicode, 能?送中文的AutoHotkey分支有詳細的介紹,它的說明文件可由此處瀏覽。
以下我寫了幾個簡單的中文輸出測試。不必再用剪貼簿來處理中文,真是簡單很多。
- send_brackets函數能將選取的文字或剪貼簿內容的前後加上不同的中文括號,例如《書名號》、【中括號】等。
- send_html則是輸出常用的HTML標籤,會判斷剪貼簿內容是否為網址而輸出到不同的插入點。
- send指令以sendInput取代,輸出速度提升不少
;; 傳回選取文字的內容 getSelectedText() { clpb_saved = %ClipboardAll% ; save clipboard Clipboard := "" ; clear Send, ^c ; simulate Ctrl+C (=selection in clipboard) selection = %Clipboard% ; save the content of the clipboard Clipboard = %clpb_saved% ; restore old content of the clipboard return selection } ;; 送出一組中文符號,如send_brackets("「」") send_brackets(symbol) { selection := getSelectedText() StringLen, length, selection if (length = 0) { selection = %clipboard% } ;; msgBox %selection% left_str := Substr(symbol,1,1) right_str := Substr(symbol,2,1) sendInput %left_str%%selection%%right_str% StringLen, length, selection length := length + 1 sendInput {left %length%} return } ;; 依剪貼簿開頭是否為"http:"來替換$$或一般文字的@@ ;; "@@" send_html(tag, pos1, pos2) { selection := GetSelectedText() StringLen, length, selection if (length = 0) { selection := clipboard } leading := Substr(selection, 1,5) ;msgbox %leading% newstr = tag if (leading = "http:") { StringReplace, newstr, tag, $$, %selection%, StringLen, length, selection length := pos1 } else { StringReplace, newstr, tag, @@, %selection%, StringLen, length, selection length := length + pos2 } ;msgbox after=%newstr% sendInput %newstr% sendInput {left %length%} return } ;; 按Ctrl+Comma輸出全形逗點,以此類推 ^,::, ^.::。 ^;::; ^[:: send_brackets("「」") ^]:: send_brackets("『』") ^![:: send_brackets("【】") ^!]:: send_brackets("《》") #[:: send_brackets("〔〕") ^':: send_brackets("""""") ;;===== HotString ===== ::,a:: send_html("@@",6,8) return ::,img:: send_html("",4,11) return ::,aimg:: send_html("",8,8) return
腳本下載
- 腳本原始檔:myhotkeys.ahk下載
- 執行檔(不須安裝Autohotkey): myhotkeys.exe
##
您可能也會有興趣的類似文章
- [AHK#54] 用AutoHotkey快速輸出Markdown標題井號(Hashes) (0則留言, 2022/08/06)
- 快速建立個人常用詞庫-AutoHotkey 熱字串小工具:HotString Helper(AHK #3) (0則留言, 2019/05/18)
- [AHK#58] 擷取豆瓣電影網的超簡單AutoHotkey爬蟲腳本程式 (0則留言, 2023/03/04)
- 改寫AutoHotkey輸出中文字串的寫法 (4則留言, 2009/06/20)
- AutoHotkey輸出中文的方法 (19則留言, 2008/03/01)
- [AHK-56] 瀏覽器鏈接快速另存圖片 (0則留言, 2022/09/18)
- [Tools] 常用的AutoHotKey設定 (9則留言, 2005/05/12)
- AutoHotkey的進階剪貼簿功能:WinClip類別 (0則留言, 2019/10/26)
- [AHK#39] 尋找網頁上特定文字並啟動的簡單作法 (0則留言, 2020/12/12)
- 幾個AutoHotkey的實用範例:音量控制、滾輪回上層與語音功能(AHK #7) (3則留言, 2019/06/05)
- [Tools] 操作熱鍵與熱字串的超便利工具:AutoHotKey (13則留言, 2005/04/29)
- 輕鬆學會AutoHotkey的熱鍵:熱鍵用法實例解說(AHK #4) (2則留言, 2019/05/24)
- 輕鬆學會彈指神功-揭露AutoHotkey絕技 (63則留言, 2008/04/10)
- AutoHotkey腳本的4種除錯方法(AHK #5) (0則留言, 2019/05/25)
- [AHK#53] AutoHotkey多行內容輸出時的偏移問題 (0則留言, 2022/07/31)
請問我在 WINDOWS 10 設 #G:: 「自訂字串」,但是 WINDOWS 10還是依 WIN+G快捷鍵優先跳出 XBOX GAME BAR, 而不是 AHK 的「自訂字串」,請問大神,這有解嗎? 謝謝
Windows預設的應該沒辦法覆寫掉。
^,::,
这个代码成立吗?无法下载附件,不清楚是否网站的原因。