Is there a content awareness feature of AutoHotKey? I need to replace some selected text in my application. Imagine the following CSHTML:
@
{
ViewBag.Title = "Welcome";
}
<p>Welcome to this page</p>
I have created a very simple script, that (once text has been selected):
- Clears clipboard
- Send CTRL+C
- Send
@normalize("
- Send CTRL+V
- Send
")
That means, that if I select Welcome to this page
, it will be replaced with @normalize("Welcome to this page")
. That part works perfectly fine.
However, if I want to replace "Welcome"
with the same, I would have to select the quotation marks, which speeds down this automation script quite a lot, because I can't simply double click on the word and select it. Now I would have to press and hold, then drag the mouse across the screen until it reaches the last ending quotation mark.
Instead, I need my AutoHotKey script to do something like:
Send CTRL + C;
var caret = currentCaretTextPosition; //made up
IF caret+1 IS "
Send Delete
IF caret-1 IS "
Send Backspace
Send @normalize("
Send CTRL+V
Send ")
If that makes sense. Basically transforms "Welcome"
into:
- ""
- "
- @normalize("
- @normalize("Welcome
- @normalize("Welcome")
This is very basic content awareness stuff, because it checks the surrounding characters of the caret, then acts upon that.
AutoHotKey script (triggered by CTRL+ALT+SHIFT+X):
^!+x::
clipboard:=""
While clipboard
Sleep 10
While !clipboard
{
Send ^c
Sleep 100
}
Sleep 20
Send @normalize("
Sleep 20
Send ^v
Sleep 20
Send ")
return