Guest User

Google Guitar Autoit3

a guest
May 7th, 2012
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.98 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <StaticConstants.au3>
  5. #include <WindowsConstants.au3>
  6. #include <Crypt.au3>
  7. #include <Misc.au3>
  8. #include <GuiEdit.au3>
  9. Global $Form = GUICreate("Google Guitar", 358, 148, 192, 124)
  10. GUICtrlCreateLabel("Insert Song", 8, 10, 58, 17)
  11. Global $Edit = GUICtrlCreateEdit("", 8, 32, 193, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
  12. Global $Button_ready = GUICtrlCreateButton("Ready : OFF", 224, 8, 99, 25)
  13. Global $Button_save = GUICtrlCreateButton("Save Song", 224, 40, 99, 25)
  14. Global $Button_Load = GUICtrlCreateButton("Load Song", 224, 72, 99, 25)
  15. GUICtrlCreateLabel("Tempo", 208, 104, 37, 17)
  16. Global $Input_tempo = GUICtrlCreateInput(100, 256, 102, 60, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
  17. GUICtrlSetLimit(-1,5,2)
  18. $Input_tempo_temp = GUICtrlCreateInput(10, 313,102, 20, 21,$ES_NUMBER)
  19. GUICtrlCreateUpdown(-1)
  20. GUICtrlSetLimit(-1,100,1)
  21. Global $link = GUICtrlCreateLabel("Google Guitar (Les Paul's 96th Birthday)", 8, 128, 195, 17)
  22. GUICtrlSetColor(-1, 0x0000FF)
  23. GUICtrlSetCursor(-1, 0)
  24. GUICtrlSetTip(-1, "Visit Google Guitar")
  25. GUICtrlSetBkColor(-1,-2)
  26. GUICtrlSetFont(-1, -1, -1, 4)
  27. Global $check = GUICtrlCreateCheckbox("Repeat", 209,128,60,17)
  28. GUICtrlCreateLabel("by PlayHD",280,131,60,17)
  29. GUICtrlSetState(-1,$GUI_DISABLE)
  30. GUISetState()
  31. HotKeySet("{HOME}","_play")
  32. HotKeySet("^a","_selectall")
  33. If Not @Compiled Then HotKeySet("{ESC}","_exit")
  34. Global $sleep = 100
  35. Global $ready = 0
  36. $last = 10
  37. While 1
  38.     If GUICtrlRead($Input_tempo_temp) <> $last Then
  39.         $last = GUICtrlRead($Input_tempo_temp)
  40.         GUICtrlSetData($Input_tempo,$last*10)
  41.     EndIf
  42.     If StringLen(String(GUICtrlRead($Input_tempo))) < 2 Then
  43.         GUICtrlSetData($Input_tempo,Int(GUICtrlRead($Input_tempo))*10)
  44.         GUICtrlSetData($Input_tempo_temp,GUICtrlRead($Input_tempo)/10)
  45.         $last = GUICtrlRead($Input_tempo)/10
  46.     EndIf
  47.     $nMsg = GUIGetMsg()
  48.     Switch $nMsg
  49.         Case $GUI_EVENT_CLOSE
  50.             Exit
  51.         Case $Button_ready
  52.             If $ready = 0 Then
  53.                 $ready = 1
  54.                 GUICtrlSetData($Button_ready,"Ready : ON")
  55.             Else
  56.                 $ready = 0
  57.                 GUICtrlSetData($Button_ready,"Ready : OFF")
  58.             EndIf
  59.         Case $Button_save
  60.             If Not GUICtrlRead($Edit) = "" Then
  61.                 $file = FileOpen(@TempDir&"\ggsave.txt",2)
  62.                 FileWrite($file,GUICtrlRead($edit))
  63.                 FileWrite($file,@LF&"-~tempo~-"&GUICtrlRead($Input_tempo))
  64.                 FileClose($file)
  65.                 $path = FileSaveDialog("Google Guitar",@ScriptDir,"Google Guitar Save (*.ggs)",Default,"",$Form)
  66.                 $array_temp = StringSplit($path,"\")
  67.                 $array_temp2 = StringSplit($path,".")
  68.                 If StringRight($path,4) <> ".ggs" Then $path &= ".ggs"
  69.                 _Crypt_Startup()
  70.                 _Crypt_EncryptFile(@TempDir&"\ggsave.txt",$path,"google",$CALG_AES_128)
  71.                 _Crypt_Shutdown()
  72.                 FileDelete(@TempDir&"\ggsave.txt")
  73.                 MsgBox (64,"Google Guitar",$array_temp[$array_temp[0]]&" was successfully saved!",10,$Form)
  74.             EndIf
  75.         Case $Button_Load
  76.             $path = FileOpenDialog("Google Guitar",@ScriptDir,"Google Guitar Save (*.ggs)",Default,Default,$Form)
  77.             _Crypt_Startup()
  78.             _Crypt_DecryptFile($path,@TempDir&"\ggload.txt","google",$CALG_AES_128)
  79.             $file = FileOpen(@TempDir&"\ggload.txt")
  80.             $text = FileRead($file)
  81.             $text2 = StringSplit($text,"-~tempo~-")
  82.             GUICtrlSetData($edit,$text2[1])
  83.             GUICtrlSetData($Input_tempo,Int($text2[$text2[0]])/10)
  84.             GUICtrlSetData($Input_tempo_temp,Int($text2[$text2[0]])/10)
  85.             FileClose($file)
  86.             FileDelete(@TempDir&"\ggload.txt")
  87.         Case $link
  88.             ShellExecute("http://www.google.com/logos/2011/lespaul.html")
  89.     EndSwitch
  90. WEnd
  91.  
  92. Func _selectall()
  93.     _GUICtrlEdit_SetSel($edit, 0, -1)
  94. EndFunc
  95. Func _play()
  96.     If $ready = 1 Then
  97.         Local $array = StringSplit(GUICtrlRead($Edit),"")
  98.         Do
  99.             For $i = 1 To $array[0] Step 1
  100.                 Send($array[$i])
  101.                 If _IsPressed(23) Then Return
  102.                 Sleep(int(GUICtrlRead($Input_tempo)))
  103.             Next
  104.         Until GUICtrlRead($check) = $GUI_UNCHECKED
  105.     EndIf
  106. EndFunc
  107.  
  108. Func _exit()
  109.     Exit
  110. EndFunc
  111.  
  112.  
  113. ;link http://www.google.com/logos/2011/lespaul.html
Add Comment
Please, Sign In to add comment