AutoHotkey Format function- Change case of text, pad it, set decimals & much more!

AutoHotkey has some great built-in functions for manipulating text.  The Format() function is awesome however I found the documentation a bit confusing so I made a short video to demonstrate the main uses of it.

Here is the AutoHotkey Format function code I demonstrate in the video


#SingleInstance,Force 
;~ Browser_Forward::Reload
;~ Browser_Back::
; A format string composed of literal text and placeholders of the form {Index:Format}.
Name:="joe glines"
MsgBox % Format("{1:Us}",name) ;Uppercase
MsgBox % "Hello there " Format("{1:Ts}",name) " how are you today?" ;Titlecase
MsgBox % Format("{1:Ls}`n{1:Ts}","JOE GLINES") ;LowerCase
Msgbox % Format("|{1:10s}|" ,"Right") ;pad left with up to 10 spaces
Msgbox % Format("|{1:-10s}|","Left") ;pad right with up to 10 spaces
Msgbox % Format("|{:-10}|","Left") ;the 1 and s are defaults so are not needed.
MsgBox % Format("{1:-10}`n{2:10}", "Left", "Right") ;Having two at once as well as new-line
MsgBox % Format("{2} my {1}!", "World", "Hello") ;Put second one in front of first
MsgBox % Format("{1:0.3f}", 423434.233223) ;set 3 decimals
MsgBox % Format("{1:0.3f}`n{1:.7f}", 423434.233223) ;show using 2 references first w/3 decimals, second w/7 return

 

AutoHotkey Format function

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.