[AHK]按热键Ctrl+Shift+Q,用引号把选中的文本括起来

The example below makes Ctrl+⇧ Shift+Q replace selected text in an editor with a quoted version of that text. It illustrates the use of functions, arguments and default argument values.

^+q::QuoteSelection()  ; Ctrl+Shift+Q

QuoteSelection()
{
	selection:= GetSelection()  ; Get selected text.
	PasteText(Quote(selection))  ; Quote the text and paste it back.
}

GetSelection(timeoutSeconds:= 0.5)
{
	Clipboard:= ""  ; Clear clipboard for ClipWait to function.
	Send ^c  ; Send Ctrl+C to get selection on clipboard.
	ClipWait %timeoutSeconds% ; Wait for the copied text to arrive at the clipboard.
	return Clipboard
}

PasteText(s)
{
	Clipboard:=s  ; Put the text on the clipboard.
	Send ^v  ; Paste the text with Ctrl+V.
}

Quote(s)
{
	return """" . s . """"
}

猜你喜欢

转载自blog.csdn.net/liuyukuan/article/details/82757776