Developer Toolbox: AutoHotKey – Super Snippets
March 4, 2009 by Jim · 8 Comments
So I’ve been working with a bunch of REALLY old code lately and one thing I run into over and over again is queries with no queryparam.
While I do have a snippet setup in CFEclipse to insert a queryparam:
<cfqueryparam value="##" cfsqltype="cf_sql_$${CF SQL Type:varchar|bit|date|integer|numeric|timestamp}">
</cfqueryparam>
But I still have to cut-n-paste the variable, etc. Kind of a pain when doing it over and over again. So I started tinkering with AutoHotKey (my favorite lazy tool) and came up with this:
;-- Wrap selected text in QueryParam (will first strip ' or ") ---
!q::
clipboard =
send ^c
clipwait, 1
If ErrorLevel = 0
StringReplace, clipboard, clipboard, ', , All
{
clipboard = <cfqueryparam value="%clipboard%" cfsqltype="cf_sql_varchar">
send ^v
}
return
</cfqueryparam>
So now I simply highlight my variable – hit my key combo (in this case [ALT]+[Q] and my text is copied to the clipboard – stripped of quote marks, wrapped in the queryparam and sent back to the editor!
Possibly Related:

The Developer Toolbox: AutoHotKey – Super Snippets by Jim, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.



Nifty tip, Jim.
This reminds me that I need to setup more things like this in Eclipse.
Thanks.
Jim,
I’ve created a stack of CFQueryparam snippets in CFEclipse that wrap variables in old code queries. I’m not sure how I can share them, but I basically have the first part ” in the following box. Saves me tons of time. I love TextExpander on my Mac, but I’ve been looking for a something like this on Linux. Thanks.
And of course my code snippet doesn’t show up. I think this should work…
Start text: <cfqueryparam value="
End text: " cfsqltype="cf_sql_char" />
Also, I sync them between machines with Dropbox. Super helpful that they are stored in xml files.
I was just Twittering about this :)
Snippets are nice – you can zip them up and easily share them. The nice thing about a text expander is you can use it anywhere. If I have code open in Notepad I can still dump in my ’snippets’. So far I haven’t found anything similar on Linux :(
Excellent idea about sharing them with Dropbox!!
Nice tips – thanks guys.
Just in case anyone has been living under a rock (B->), don’t forget to investigate Snipex (http://www.markdrew.co.uk/blog.....s-released) – a snippet server solution built into CFE by the delectable Mark Drew.
I’ve written a couple of AutoHotKey scripts that I use to clean up the clipboard, optimize CSS and repurpose content for lists.
http://www.ssmedia.com/utilities/autohotkey/
I use C++ for the string processing. AutoHotKey puts the text on the clipboard, runs the helper exe, and pastes the result back into the original.