Quantcast
Channel: AutoHotkey Community
Viewing all articles
Browse latest Browse all 579

Ask for Help (v2) • console.log last word

$
0
0
I am trying to create an ahk that does the following
if I type Report.log it replaces it with console.log("Report" , Report);

I thought it would be straightforward, but I ended up with a complicated code, that works but with issues,
For example if I am writing a long Variable name like InitialReport VS Code completes the variable name, then I write .log at the end of it, in this case my ahk does not work,

this is my code

CODE:

MakeLog() {
; Define a nested function
NestedFunction(match) {
theWord := ''
try {
theWord := match[1]
}
catch Error as err {
Send ("{Left}")
Send ("^+{Left}") ; Control+Shift+Left Arrow to select the word to the left
Send ("^c") ; Control+C to copy
Sleep (50)
theWord := A_Clipboard
}

A_Clipboard := 'console.log("' . theWord . '" , ' . theWord . ");"
Send("^v")

}
; Call the nested function
return NestedFunction
}
RegExHotstring("(?:\b\w*)?\.log\b", MakeLog(),"*?")


Thank you for any help

Statistics: Posted by AladdinMhemed — 59 minutes ago



Viewing all articles
Browse latest Browse all 579

Trending Articles