#include "gh3_songs.au3"
#include <string.au3>

if ($CmdLine[0]<>3) then
   msgbox(0,"","Usage: "&@scriptname&" qbgen.exe_path .chart_path pak_path")
   exit
EndIf

$qbgen = $CmdLine[1]
$chart = $CmdLine[2]
$pak = $CmdLine[3]
$song = $CmdLine[3]
$song = StringTrimRight($song,8)
$i=StringLen($song)
while (StringMid($song,$i,1)<>"\")
	$i=$i-1
WEnd
$song = StringTrimLeft($song,$i)

Run($qbgen)
WinWaitActive($qbgen)
Send($chart)
Send("{ENTER}")
Sleep(100)
$i=0
For $filename in $songs
	if ($filename == $song) then $songnumber=$i
	$i=$i+1
Next
   Send($songnumber)
Send("{ENTER}")
Sleep(50)
   Send($pak)
   Sleep(50)
Send("{ENTER}")
Sleep(50)
   Send("1")
   Sleep(50)
Send("{ENTER}")
Sleep(50)
   Send("0")
   Sleep(50)
Send("{ENTER}")
Sleep(50)
if (Stringmid($pak,stringlen($pak)-10)=="one.pak.ngc" or Stringmid($pak,stringlen($pak)-24)=="thrufireandflames.pak.ngc") Then
	   Send("0")
   Sleep(50)
Send("{ENTER}")
Sleep(50)
EndIf
Send("{ENTER}")
Sleep(50)
  
Sleep(1000)
Sleep(1000)
Exit