Skip to content

Instantly share code, notes, and snippets.

@nimdahk
Created April 11, 2012 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nimdahk/2356479 to your computer and use it in GitHub Desktop.
Save nimdahk/2356479 to your computer and use it in GitHub Desktop.
Change AutoIT Selects into AutoHotkey if/else if
changeSelect(var){
Select := 0
Loop Parse, var, `n, `r
{
if Trim(A_LoopField) = "Select"
Select++
else if RegExMatch(A_LoopField, "i)(\s*)Case\s*else(.*)", $) ;and Select > 0
{
Case%Select%++
out .= $1 (Case%Select% > 1 ? "}" : "") . "else{" . $2
}
else if RegExMatch(A_LoopField, "i)(\s*)Case\s*(.*)", $) ;and Select > 0
{
Case%Select%++
out .= $1 . (Case%Select% > 1 ? "}else " : "") "if (" $2 "){"
}
else if RegExMatch(A_LoopField, "i)^(\s*)EndSelect(.*)$", $)
{
out .=$1 . "}" . $2
Select--
}
else
out .= A_LoopField
out .= "`r`n"
}
StringTrimRight, out, out, 2
return out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment