Skip to content

Примеры использования

Gleb Golovin edited this page Apr 15, 2015 · 1 revision

Код, который пишет код

var app = new Application(@"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe");
app.Start();

var window = CruciatusFactory.Root.FindElementByUid("VisualStudioMainWindow");
var menuBar = window.FindElementByUid("MenuBar").ToMenu();
menuBar.SelectItem("File$New$Project...");

var newProjectWin = window.FindElementByName("New Project");
newProjectWin.FindElementByUid("Windows Desktop").Click();
newProjectWin.FindElementByName("Console Application").Click();
newProjectWin.FindElementByUid("txt_Name").SetText("SpecialForCodeFest2015-" + Environment.TickCount);
newProjectWin.FindElementByUid("btn_OK").Click();

var textView = window.FindElement(By.Uid("WpfTextView"));
textView.SetText("using System;{ENTER}{ENTER}");
CruciatusFactory.Keyboard.SendText("namespace CodeFest2015{ENTER}");
CruciatusFactory.Keyboard.SendText("{{}{ENTER}");
CruciatusFactory.Keyboard.SendText("class Program{ENTER}");
CruciatusFactory.Keyboard.SendText("{{}{ENTER}");
CruciatusFactory.Keyboard.SendText("static void Main{(}string{[}{]} args{)}{ENTER}");
CruciatusFactory.Keyboard.SendText("{{}{ENTER}");
CruciatusFactory.Keyboard.SendText("Console.WriteLine{(}\"Hello CodeFest2015\"{)};");

CruciatusFactory.Keyboard.SendText("^{F5}");