#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Misc.au3>
#include <GuiEdit.au3>
Global $Form = GUICreate("Google Guitar", 358, 148, 192, 124)
GUICtrlCreateLabel("Insert Song", 8, 10, 58, 17)
Global $Edit = GUICtrlCreateEdit("", 8, 32, 193, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
Global $Button_ready = GUICtrlCreateButton("Ready : OFF", 224, 8, 99, 25)
Global $Button_save = GUICtrlCreateButton("Save Song", 224, 40, 99, 25)
Global $Button_Load = GUICtrlCreateButton("Load Song", 224, 72, 99, 25)
GUICtrlCreateLabel("Tempo", 208, 104, 37, 17)
Global $Input_tempo = GUICtrlCreateInput(100, 256, 102, 60, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
GUICtrlSetLimit(-1,5,2)
$Input_tempo_temp = GUICtrlCreateInput(10, 313,102, 20, 21,$ES_NUMBER)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1,100,1)
Global $link = GUICtrlCreateLabel("Google Guitar (Les Paul's 96th Birthday)", 8, 128, 195, 17)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Visit Google Guitar")
GUICtrlSetBkColor(-1,-2)
GUICtrlSetFont(-1, -1, -1, 4)
Global $check = GUICtrlCreateCheckbox("Repeat", 209,128,60,17)
GUICtrlCreateLabel("by PlayHD",280,131,60,17)
GUICtrlSetState(-1,$GUI_DISABLE)
GUISetState()
HotKeySet("{HOME}","_play")
HotKeySet("^a","_selectall")
If Not @Compiled Then HotKeySet("{ESC}","_exit")
Global $sleep = 100
Global $ready = 0
$last = 10
While 1
If GUICtrlRead($Input_tempo_temp) <> $last Then
$last = GUICtrlRead($Input_tempo_temp)
GUICtrlSetData($Input_tempo,$last*10)
EndIf
If StringLen(String(GUICtrlRead($Input_tempo))) < 2 Then
GUICtrlSetData($Input_tempo,Int(GUICtrlRead($Input_tempo))*10)
GUICtrlSetData($Input_tempo_temp,GUICtrlRead($Input_tempo)/10)
$last = GUICtrlRead($Input_tempo)/10
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_ready
If $ready = 0 Then
$ready = 1
GUICtrlSetData($Button_ready,"Ready : ON")
Else
$ready = 0
GUICtrlSetData($Button_ready,"Ready : OFF")
EndIf
Case $Button_save
If Not GUICtrlRead($Edit) = "" Then
$file = FileOpen(@TempDir&"\ggsave.txt",2)
FileWrite($file,GUICtrlRead($edit))
FileWrite($file,@LF&"-~tempo~-"&GUICtrlRead($Input_tempo))
FileClose($file)
$path = FileSaveDialog("Google Guitar",@ScriptDir,"Google Guitar Save (*.ggs)",Default,"",$Form)
$array_temp = StringSplit($path,"\")
$array_temp2 = StringSplit($path,".")
If StringRight($path,4) <> ".ggs" Then $path &= ".ggs"
_Crypt_Startup()
_Crypt_EncryptFile(@TempDir&"\ggsave.txt",$path,"google",$CALG_AES_128)
_Crypt_Shutdown()
FileDelete(@TempDir&"\ggsave.txt")
MsgBox (64,"Google Guitar",$array_temp[$array_temp[0]]&" was successfully saved!",10,$Form)
EndIf
Case $Button_Load
$path = FileOpenDialog("Google Guitar",@ScriptDir,"Google Guitar Save (*.ggs)",Default,Default,$Form)
_Crypt_Startup()
_Crypt_DecryptFile($path,@TempDir&"\ggload.txt","google",$CALG_AES_128)
$file = FileOpen(@TempDir&"\ggload.txt")
$text = FileRead($file)
$text2 = StringSplit($text,"-~tempo~-")
GUICtrlSetData($edit,$text2[1])
GUICtrlSetData($Input_tempo,Int($text2[$text2[0]])/10)
GUICtrlSetData($Input_tempo_temp,Int($text2[$text2[0]])/10)
FileClose($file)
FileDelete(@TempDir&"\ggload.txt")
Case $link
ShellExecute("http://www.google.com/logos/2011/lespaul.html")
EndSwitch
WEnd
Func _selectall()
_GUICtrlEdit_SetSel($edit, 0, -1)
EndFunc
Func _play()
If $ready = 1 Then
Local $array = StringSplit(GUICtrlRead($Edit),"")
Do
For $i = 1 To $array[0] Step 1
Send($array[$i])
If _IsPressed(23) Then Return
Sleep(int(GUICtrlRead($Input_tempo)))
Next
Until GUICtrlRead($check) = $GUI_UNCHECKED
EndIf
EndFunc
Func _exit()
Exit
EndFunc
;link http://www.google.com/logos/2011/lespaul.html