AutoHotkey Community

It is currently May 26th, 2012, 4:59 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: February 21st, 2009, 2:00 am 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
I wrote this while on a break from studying.
It basically jumbles the letters of each word but leaving the first and last letters untouched.
I'm sure you guys received emails with this (it's quite old):
Quote:
The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it wouthit a porbelm.

Well, all my script does is that it transforms any text currently selected into a jumbled version and places it on the clipboard. Default hotkey is Win+z.

Code:
#z::
   
   ;Clear clipboard
   Clipboard =
   
   ;Copy selection and wait for it to get to the clipboard
   SendInput ^c
   ClipWait
   
   s := Clipboard
   
   ;Jumble words
   i := 1
   Loop {
      i := RegExMatch(s,"P)[a-zA-Z]{4,}",l,i)
      If Not i
         Break
      Else Jumble(s,i,l)
      i += l
   }
   
   ;Put back in clipboard
   ClipBoard := s
   
Return

Jumble(ByRef s, pos, len) {
   
   ;Extract the middle letters
   l := len - 2
   t := SubStr(s, pos + 1, l)
   
   ;Jumble the letters
   Loop {
      
      ;Get random number
      Loop {
         Random, r, 1, l
         i := NumGet(t, r - 1, "UChar")
         If i
            Break
      }
      
      ;Put the chosen letter in the next pos
      NumPut(i, s, pos + A_Index - 1, "UChar")
      NumPut(0, t, r - 1, "UChar")
      
      If (A_Index = l)
         Break
   }
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group