Sign in to follow this  
Followers 0
ashley123

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

2 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



oops FIXED IT!! silly me. Plz delete topic. I accidentaly used a wrong variable name.

Thanks for the help guys.

Share this post


Link to post
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
Sign in to follow this  
Followers 0