如何用字符括起选定的字符串?

如何用字符括起选定的字符串?

在没有 Markdown 快捷键的留言板上,用热键括住字符串会特别有用,这样[quote] [/quote]我就不用打字了。在选定的文本周围添加引号 (") 或其他字符也很有用。

答案1

在选定的文本周围添加引号 ("):

F1::
ClipSaved := ClipboardAll   ; save the entire clipboard to the variable ClipSaved
clipboard := ""             ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
Send, ^c                    ; copy the selected text
ClipWait, 1                 ; wait for the clipboard to contain data 
if (!ErrorLevel)            ; if NOT ErrorLevel, clipwait found data on the clipboard
clipboard = "%clipboard%"   ; add the quotation marks
Sleep, 300
    Send, ^v
Sleep, 300
clipboard := ClipSaved      ; restore original clipboard
return

将选定的文本括在 [quote] 和 [/quote] 之间,使用另一个热键和相同的程序。只需将上述代码中的替换clipboard = "%clipboard%"为即可。clipboard = [quote]%clipboard%[/quote]

用于在 [quote] 和 [/quote] 之间输入或粘贴文本用这个:

F2:: SendInput, [quote][/quote]{Left 8}

相关内容