Migrating from Autohotkey

Hi,

I'm looking to migrate a number of our current scripts in AutoHotkey over to TextBlaze. We've done about 90% of these. We're getting stuck on a couple.

Here is an old legacy script which takes the TEXT in the Clipboard and then does a a series of replaces to make that text a filename compatible name. ie it removes all the special characters etc

eg it transforms somethinng like this

Full SpoilerTV Pilot Watch Spreadsheet!!!--&&& 17

to

full-spoilertv-pilot-watch-spreadsheet-17

here is the Autohothey code

basically takes the clipboard, does the replaces, then lowercases everything, and then pushes it back to the clipboard so I can paste it into my docs/articles.

clipboard=
send ^c
ClipWait
Clipboard := StrReplace(Clipboard,"-")
Clipboard := StrReplace(Clipboard,".")
Clipboard := StrReplace(Clipboard,"!")
Clipboard := StrReplace(Clipboard,",")
Clipboard := StrReplace(Clipboard,":")
Clipboard := StrReplace(Clipboard,"+")
Clipboard := StrReplace(Clipboard,"&")
Clipboard := StrReplace(Clipboard,"£")
Clipboard := StrReplace(Clipboard,"(")
Clipboard := StrReplace(Clipboard,")")
Clipboard := StrReplace(Clipboard,"$")
Clipboard := StrReplace(Clipboard,"%")
Clipboard := StrReplace(Clipboard,"'")
Clipboard := StrReplace(Clipboard,"  ","-")
Clipboard := StrReplace(Clipboard," ","-")
Clipboard := StrReplace(Clipboard,"--","-")
StringLower, Clipboard, Clipboard

Is this something that TextBlaze can do?

1 Like

Hey Andy,

Welcome to Text Blaze, glad to have you!

We have a similar function, replace( -- here's documentation on string functions including that one.

Similar to how you were doing this in your old tool, you'll probably just want to stack a bunch of replace( functions on top of the clipboard, along these lines:

{=lower(replace(replace(replace({clipboard}," ","-"),".","-"),"!","-"))}

The replace function works as:

replace(text-to-be-replaced, "what you want replaced", "what it should be replaced by")

In the example here, text-to-be-replaced is your clipboard contents.

If you want to strip something completely, you could do something like: replace(original, "thing that needs replacement", "")

I don't believe that Text Blaze can push the value back to your clipboard, but you'd simply use your snippet's shortcut to insert that modified version where you need it.

3 Likes

Hi Andew,

Thanks for the warm welcome and the very informative help, very much appreciated.

I'll be sure to play around with that and I think it's exactly what I need.

1 Like