I'll just leave it here, hardcoded some strings to make it clear. Also I switch realms editing config file.
PHP Code:
foreach (AccInfo acc in infos)
{
string[] config=File.ReadAllLines(@"C:\Games\WoW\WTF\Config.wtf", Encoding.UTF8);
for(int i=0;i<config.Length;i++)
if (config[i].StartsWith("SET realmName"))
{
config[i]="SET realmName \""+acc.realm+"\"";
}
File.WriteAllLines(@"C:\Games\WoW\WTF\Config.wtf", config);
AI myAI;
Process wowProcess = Process.Start(@"C:\Games\WoW\Wow.exe");
Thread.Sleep(5000);
myAI = new AI(wowProcess.Id);
string s = @"if (WoWAccountSelectDialog and WoWAccountSelectDialog:IsShown()) then
for i = 0, GetNumGameAccounts() do
if GetGameAccountInfo(i) == '" + acc.accountName + @"' then
WoWAccountSelect_SelectAccount(i)
end
end
elseif (AccountLoginUI and AccountLoginUI:IsVisible()) then
DefaultServerLogin('" + acc.battleName + @"', '" + acc.password + @"')
AccountLoginUI:Hide()
elseif (RealmList and RealmList:IsVisible()) then
for i = 1, select('#',GetRealmCategories()) do
for j = 1, GetNumRealms(i) do
if GetRealmInfo(i, j) == '" + acc.realm + @"' then
RealmList:Hide()
ChangeRealm(i, j)
end
end
end
elseif (CharacterSelectUI and CharacterSelectUI:IsVisible()) then
if GetServerName() ~= '" + acc.realm + @"' and (not RealmList or not RealmList:IsVisible()) then
RequestRealmList(1)
else
for i = 0,GetNumCharacters() do
if (GetCharacterInfo(i) == '" + acc.charName + @"') then
CharacterSelect_SelectCharacter(i)
EnterWorld()
end
end
end
end ";
while (!myAI.IsIngame())
{
Thread.Sleep(2000);
myAI.LuaDoString(s);
}
}