问题
I want to create a hotkey Ctrl + ( that adds brackets to a phrase. I.e select x-1
to get (x-1)
. How to program this function?
I write a lot of phrases such as: x+1/(x-1)^2
so it would be helpful to have a hotkey to add brackets.
回答1:
^(::
SendInput, ^c
Sleep 10
Clipboard = (%Clipboard%)
SendInput, ^v
return
This implies that you are actually pressing CTRL+SHIFT+9 (since you don't have a (
key).
I did a quick test and it will add round brackets to anything you highlight. I would recommend tweaking the trigger key since CTRL+SHIFT+9 isn't that easy to hit, but otherwise seems to work without issues.
If you want to save the clipboard, then you'll have to do this:
^(::
SavedClipboard := ClipboardAll
SendInput, ^c
Sleep 10
Clipboard = (%Clipboard%)
SendInput, ^v
Clipboard := SavedClipboard
SavedClipboard =
return
来源:https://stackoverflow.com/questions/24148230/how-to-add-brackets-using-autohotkey