Juno_okyo

Get new random string

Nov 28th, 2014
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.57 KB | None | 0 0
  1. #region
  2. #AutoIt3Wrapper_UseUpx=Y
  3. #AutoIt3Wrapper_Compression=4
  4. #AutoIt3Wrapper_Icon=E:\wamp\www\favicon.ico
  5. #AutoIt3Wrapper_Res_Comment=Coded by Juno_okyo
  6. #AutoIt3Wrapper_Res_Description=Coded by Juno_okyo
  7. #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
  8. #AutoIt3Wrapper_Res_ProductVersion=1.0.0.0
  9. #AutoIt3Wrapper_Res_LegalCopyright=(c) 2014 by Juno_okyo's Blog
  10. #AutoIt3Wrapper_Res_Field=ProductName|Juno_okyo's Production
  11. #AutoIt3Wrapper_Res_Field=ProductVersion|1.0.0.0
  12. #AutoIt3Wrapper_Res_Field=CompanyName|J2TeaM
  13. #endregion
  14.  
  15. ; Includes
  16. #include <Misc.au3>
  17. #include <ButtonConstants.au3>
  18. #include <EditConstants.au3>
  19. #include <GUIConstantsEx.au3>
  20. #include <WindowsConstants.au3>
  21. #include <Array.au3>
  22. #include <String.au3>
  23.  
  24. ; Only One Instance
  25. _Singleton(@ScriptName)
  26.  
  27. ; Options
  28. #NoTrayIcon
  29. Opt('WinTitleMatchMode', 2)
  30. Opt('GUIOnEventMode', 1)
  31. Opt('GUICloseOnESC', 0)
  32.  
  33. ; Script Start - Add your code below here
  34. #Region ### START Koda GUI section ### Form=
  35. Global $MainForm = GUICreate("[Juno_okyo] Get new random string", 505, 437, -1, -1)
  36. GUISetFont(12, 400, 0, "Arial")
  37. GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
  38. Global $Group1 = GUICtrlCreateGroup("Input", 5, 5, 494, 178)
  39. Global $Edit1 = GUICtrlCreateEdit("", 15, 30, 474, 140)
  40. GUICtrlSetState(-1, $GUI_FOCUS)
  41. GUICtrlCreateGroup("", -99, -99, 1, 1)
  42. Global $Group2 = GUICtrlCreateGroup("Output", 5, 190, 494, 178)
  43. Global $Edit2 = GUICtrlCreateEdit("", 15, 215, 474, 140)
  44. GUICtrlCreateGroup("", -99, -99, 1, 1)
  45. Global $Button1 = GUICtrlCreateButton("Convert", 5, 379, 494, 47)
  46. GUICtrlSetFont(-1, 16, 400, 0, "Arial")
  47. GUICtrlSetOnEvent(-1, "Button1Click")
  48. GUICtrlSetCursor(-1, 0)
  49. GUISetState(@SW_SHOW)
  50. #EndRegion ### END Koda GUI section ###
  51.  
  52. While 1
  53.     Sleep(100)
  54. WEnd
  55.  
  56. Func Button1Click()
  57.     Local $input = GUICtrlRead($Edit1)
  58.     If $input = '' Then Return False
  59.  
  60.     $input = StringSplit($input, '.')
  61.     Local $output = ''
  62.  
  63.     For $i = 1 To $input[0]
  64.         $output &= get_new_string($input[$i])
  65.     Next
  66.  
  67.     GUICtrlSetData($Edit2, $output)
  68. EndFunc
  69.  
  70. Func get_new_string($string)
  71.     Local $aString = _StringExplode($string, ' ')
  72.     _ArrayShuffle($aString)
  73.  
  74.     Local $output2 = '', $total = UBound($aString) - 1
  75.     For $i = 0 To $total
  76.         Local $temp = StringStripWS($aString[$i], 8)
  77.         If $temp = '.' Or $temp = '' Then ContinueLoop
  78.  
  79.         $output2 &= $temp
  80.  
  81.         If $i = $total Then
  82.             $output2 &= '. '
  83.         Else
  84.             $output2 &= ' '
  85.         EndIf
  86.     Next
  87.  
  88.     Return string_ucfirst($output2)
  89. EndFunc
  90.  
  91. Func string_ucfirst($str)
  92.     Return StringUpper(StringMid($str, 1, 1)) & StringMid($str, 2)
  93. EndFunc
  94.  
  95. Func MainFormClose()
  96.     Exit
  97. EndFunc
Add Comment
Please, Sign In to add comment