Jump to content

Give each letter of string a random case (Broken For Loop)


Recommended Posts

hello, im a new person from autohotkey and my code isnt working, what it does now is it takes only the last letter and upper/lower cases it a bunch of times but i want it to do the whole word.

I'm trying to have it take in e.g. "cookies"

and output "CoOKIeS"

AUTOIT CODE: (I need help with this thanks :D )

$STRING_LENGTH = StringLen($USERNAME)
For $i = $STRING_LENGTH to 0 Step -1
;Loop,$STRING_LENGTH
$CHAR = StringLeft($USERNAME,1)
$RANDOM = Random(1,2,1)
If $RANDOM = 1 Then
$CHAR = StringLower($CHAR)
Else
$CHAR = StringUpper($CHAR)
EndIf
StringTrimLeft($CHAR,1)
;$char = StringTrimLeft($char,1)
;string=%string%%char%
$USERNAME = $USERNAME&$char
Next

The code from an autohotkey example i was trying to duplicate is this:

RANDOM:
Gosub,CUT
StringLen,length,string
Loop,%length%
{
  StringLeft,char,string,1
  Random,random,1,2
  If random=1
    StringLower,char,char
  Else
    StringUpper,char,char
  StringTrimLeft,string,string,1
  string=%string%%char%
}
If showstatus=1
  ToolTip,Selection converted to RaNDoM CaSE
SetTimer,TOOLTIPOFF,On
Gosub,PASTE
Return
Edited by ashley123
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...