How to add brackets using AutoHotKey

早过忘川 提交于 2019-12-25 02:52:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!