Log in

No account? Create an account

Peter Rogers's Blog
Artist-in-Residence at Chez Firth

Wednesday (7/28/10) 10:41am - ... wherein Peter makes an AHK tool for hashtags.

I finally made a little autohotkey script that turns normal text into hashtags.  So now I can select this text...

I've made a big mistake
... and type ctrl-# to turn it into...
So:  it lower-cases everything, strips out the spaces and punctuation, and adds a "#".

This is handy because it lets me type out separate words instead of one big hashtag.  This means that my autocorrect script can run, and spell-check can flag anything that's still screwed up after autocorrection.

Plus it's just easier to type out a lengthy hashtag when you're not typing one big run-on word.

Anyway, here's the AHK code:
; create hashtag
ClipSaved_CH := ClipboardAll
Send {Ctrl Down}c{Ctrl Up}
Sleep 100
CleanString := Clipboard
StringLower CleanString, CleanString ; set to lowercase
RegExMatch(CleanString, "^(\s*).*[^\s](\s*)$", Matches) ; grab the leading/trailing whitespace
CleanString := RegExReplace(CleanString, "[^\wáéíóúäëïöüàèìòùâêîôûçߢ]") ; strip out spaces, punctuation
SendInput {raw}%Matches1%#%CleanString%%Matches2% ; leading ws, #, hashtag, trailing ws
Clipboard := ClipSaved_CH

Tags: , ,
Mood: [mood icon] accomplished · Music: none
Previous Entry Share Next Entry