#Include "gh3_songs.au3"

Func _SongEdit_init( $songedit, $gui, $qbpath )
	Run($songedit)
	WinWaitActive($gui)
	Send("{ENTER}")
	WinWaitActive("[ACTIVE]")
	send($qbpath)
	Send("{ENTER}")
	WinWaitActive($gui)
EndFunc

Func _Replace($file,$song,$gui)
	$i=0
	For $filename in $songs
		if ($filename == $song) then $songnumber=$i
			$i=$i+1
	Next
	Run("notepad.exe")
	WinWaitActive("Untitled - Notepad")
	Send("^o")
	WinWaitActive("Open")
	Sleep(50)
	Send($file)
	_enter()
	Sleep(50)
	Send("+{END}")
	Sleep(50)
	Send("^C")
	$SongTitle = ClipGet()
	_down()
	send("{HOME}")
	sleep(50)
	Send("+{END}")
	Sleep(50)
	Send("^C")
	$Artist = ClipGet()
	_down()
	send("{HOME}")
	Send("+{END}")
	Sleep(50)
	Send("^C")
	$Year = ClipGet()
	Sleep(10)
	Send("!{F4}")
	Sleep(500)
	for $i = 1 to 7
		_tab()
	Next
	for $i = 0 to $songnumber
		_down()
	Next
	_tab()
	_tab()
	_enter()
	Sleep(50)
	Send($SongTitle)
	Sleep(50)
	_tab()
	Send($Artist)
	Send("{RIGHT}")
	Sleep(50)
	_tab()
	Send($Year)
	Sleep(50)
	_enter()
	WinWaitActive($gui)
	Sleep(50)
	_tab()
	_tab()
	_enter()
	WinWaitActive($gui)
EndFunc

Func _Shrink($gui)
	For $i = 1 to 7
		_tab()
	Next
	For $i = 1 to 17
		_down()
	Next
	_clear($gui)
	For $i = 1 to 49
		_down()
	Next
	_clear($gui)
	_down()	
	_clear($gui)
	_down()
	_clear($gui)
	For $i = 1 to 10
		_down()
	Next
	For $i = 1 to 12
		_clear($gui)
		_down()
	Next
	_clear($gui)
	_tab()
	_tab()
	_tab()
	_tab()
	_enter()
	WinWaitActive($gui)
EndFunc

Func _tab()
	Send("{TAB}")
	Sleep(50)
EndFunc

Func _down()
	Send("{DOWN}")
	Sleep(50)
EndFunc	

Func _del()
	Send("{DEL}")
	Sleep(50)
EndFunc	

Func _enter()
	Send("{ENTER}")
	Sleep(50)
EndFunc	

Func _clear($gui)
	_tab()
	_tab()
	_enter()
	WinWaitActive("[ACTIVE]")
	_del()
	_tab()
	_del()
	_tab()
	_del()
	_enter()
	WinWaitActive($gui)
	for $j = 1 to 5
		_tab()
	Next
EndFunc
