Reputation: 1592
Can someone explain how to use AutoHotKey to OUTPUT JavaScript when I type a piece of text? For example, I would like type...
iff
... and have AutoHotKey replace that text with...
if (err) { return callback(err); }
I've tried using Send, quotes, slashes... nothing works. I've also tried countless Google searches but everything finds people trying to CONTROL AutoHotKey with JavaScript instead of having it OUTPUT JavaScript.
Upvotes: 2
Views: 361
Reputation: 28516
Adding ::
at beginning and end of some text defines HotString that will do what you need. Also use SendRaw
instead of Send
because curly braces are special characters
::iff::
SendRaw,if (err) { return callback(err); }
Return
Upvotes: 2
Reputation: 437
The ScriptControl Object allows AHk to execute javascript.
jSplode(str,del) {
sc:=ComObjCreate("ScriptControl"),sc.Language:="JScript"
js:="str='" str "';aR=str.split(""" del """);",sc.ExecuteStatement(js)
Return sc.Eval("aR")
}
This is how your code would look:
js =
(
function ROloiw()
{
var map = ";
DL5=document.links;
for (lKi=0; lKi<DL5.length; lKi++)
{
map = map + DL5[lKi] + '|'
}
prompt('map', map );
}
ROloiw();
)
scObj.ExecuteStatement(js)
Upvotes: 0