本文整理汇总了C#中WindowsAppFriend.Type方法的典型用法代码示例。如果您正苦于以下问题:C# WindowsAppFriend.Type方法的具体用法?C# WindowsAppFriend.Type怎么用?C# WindowsAppFriend.Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowsAppFriend
的用法示例。
在下文中一共展示了WindowsAppFriend.Type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInitialize
public void TestInitialize()
{
app = new WindowsAppFriend(Process.Start("Target.exe"));
WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
dynamic main = app.Type<Application>().Current.MainWindow;
dataGrid = new WPFDataGrid(app.Type<WPFDataGridTest>().InitDataGrid(main._grid));
}
示例2: WinForms
public void WinForms()
{
var app = new WindowsAppFriend(Process.Start("WinForms.exe"));
var mainForm = app.Type().System.Windows.Forms.Application.OpenForms[0];
//WinFormsの場合は変数名で取りましょう。
var _buttonX = new FormsButton(mainForm._buttonX);
_buttonX.EmulateClick();
//ポップアップメニューも変数からとる
var _toolStripMenuItemA = new FormsToolStripItem(mainForm._toolStripMenuItemA);
_toolStripMenuItemA.EmulateClick();
//とは言え、取れないときも
//そんなときは工夫する
WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
var button名無し = new FormsButton(app.Type().Tips.ChildControl.Get名無し(mainForm));
button名無し.EmulateClick();
//メニューアイテムも上位ライブラリ使えばインデックスとかテキストから取れたり
var menu = new FormsToolStrip(mainForm._contextMenuStrip);
var b = menu.FindItem("B");
b.EmulateClick();
Process.GetProcessById(app.ProcessId).Kill();
}
示例3: TestInitialize
public void TestInitialize()
{
_app = new WindowsAppFriend(Process.Start("Target.exe"));
WindowsAppExpander.LoadAssembly(_app, GetType().Assembly);
dynamic main = _app.Type<Application>().Current.MainWindow;
_ctrl = _app.Type<WPFListViewTest>().Init(main._grid);
}
示例4: ResetConnection
void ResetConnection()
{
int id = _app.ProcessId;
_app.Dispose();
_app = new WindowsAppFriend(Process.GetProcessById(id));
dynamic main = _app.Type<Application>().Current.MainWindow;
_ctrl = _app.Type<WPFListViewTest>().Init(main._grid);
}
示例5: TestInitialize
public void TestInitialize() {
app = new WindowsAppFriend(Process.Start("Target.exe"));
WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
win = app.Type(typeof(Application)).Current.MainWindow;
dynamic grid = win._grid;
control = app.Type<WPFContextMenuTestControl>()();
grid.Children.Add(control);
}
示例6: TestInitialize
public void TestInitialize()
{
app = new WindowsAppFriend(Process.Start("Target.exe"));
dynamic win = app.Type<Application>().Current.MainWindow;
dynamic grid = win._grid;
target = app.Type<ListBox>()();
grid.Children.Add(target);
}
示例7: TestInitialize
public void TestInitialize()
{
_app = new WindowsAppFriend(Process.Start("Target.exe"));
WindowsAppExpander.LoadAssembly(_app, GetType().Assembly);
dynamic main = _app.Type<Application>().Current.MainWindow;
dynamic checkBox = _app.Type<CheckBox>()();
main._grid.Children.Add(checkBox);
_toggle = new WPFToggleButton(checkBox);
}
示例8: Test
public void Test()
{
//アタッチ
WindowsAppFriend app = new WindowsAppFriend(vsProcess);
//DLLインジェクション
WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
//Microsoft.VisualStudio.Shell.Package.GetGlobalServiceの呼び出し
var dteType = app.Type(GetType()).DTEType;
AppVar obj = app.Type().Microsoft.VisualStudio.Shell.Package.GetGlobalService(dteType);
//注目!
//インターフェイスでプロキシが作成できる!
var dte = obj.Pin<DTE2>();
var solution = dte.Solution;
//ソリューション作成
solution.Create(SolutionDir, "Test.sln");
string solutionPath = Path.Combine(SolutionDir, "Test.sln");
solution.SaveAs(solutionPath);
//プロジェクト追加
solution.AddFromTemplate(
@"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1041\WPFApplication\csWPFApplication.vstemplate",
Path.Combine(SolutionDir, "WPF"), "WPF", true);
//保存
solution.SaveAs(solutionPath);
//閉じる
solution.Close();
//再度開く
solution.Open(solutionPath);
//クリーン→ビルド
solution.SolutionBuild.Clean(true);
solution.SolutionBuild.Build(true);
//デバッグ
solution.SolutionBuild.Debug();
//デバッグ対象プロセスを操作
var debProcess = System.Diagnostics.Process.GetProcessById(dte.Debugger.DebuggedProcesses.Item(1).ProcessID);
using (var debApp = new WindowsAppFriend(debProcess))
{
debApp.Type().System.Windows.Application.Current.MainWindow.Close(new Async());
}
//編集モードに戻るまで待つ
while (dte.Debugger.CurrentMode != dbgDebugMode.dbgDesignMode)
{
System.Threading.Thread.Sleep(10);
}
}
示例9: TestInitialize
public void TestInitialize() {
app = new WindowsAppFriend(Process.Start("Target.exe"));
WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
dynamic win = app.Type(typeof(Application)).Current.MainWindow;
dynamic grid = win._grid;
dynamic target = app.Type<ListBox>()();
grid.Children.Add(target);
target.ItemsSource = Enumerable.Range(0, 100).Select(i => "value " + i).ToArray();
listBox = new WPFListBox(target);
}
示例10: TestInitialize
public void TestInitialize()
{
app = new WindowsAppFriend(Process.Start("Target.exe"));
WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
dynamic win = app.Type(typeof(Application)).Current.MainWindow;
dynamic grid = win._grid;
dynamic target = app.Type<Expander>()();
grid.Children.Add(target);
expander = new WPFExpander(target);
window = new WindowControl(win);
}
示例11: SetUp
public void SetUp()
{
_app = new WindowsAppFriend(Process.Start("Target.exe"));
_mainWindow = WindowControl.FromZTop(_app);
dynamic win = _app.Type<Application>().Current.MainWindow;
dynamic grid = win._grid;
_target = _app.Type<ProgressBar>()();
grid.Children.Add(_target);
WindowsAppExpander.LoadAssemblyFromFile(_app, GetType().Assembly.Location);
}
示例12: WinForms
public void WinForms()
{
var app = new WindowsAppFriend(Process.Start("WinForms.exe"));
//System.Windows.Forms.Application.OpenForms
var form = app.Type().System.Windows.Forms.Application.OpenForms[0];
form.Text = "取れたよ";
//複数個開いている場合
{
var form2 = app.Type().System.Windows.Forms.Form();
form2.Text = "2";
form2.Show();
}
//実はforeachできます。
//Linqは無理ですけどね。
foreach (var f in app.Type().System.Windows.Forms.Application.OpenForms)
{
string title = f.Text;
if (title == "2")
{
f.Text = "これも取れた";
break;
}
}
//WindowControlの検索関数を使ってみる
var main = WindowControl.IdentifyFromTypeFullName(app, "WinForms.MainForm");
main.Dynamic().Text = "ほらね。";
var second = WindowControl.IdentifyFromWindowText(app, "これも取れた");
second.Dynamic().Text = "バッチリ。";
//WaitFor
//取れるまで待つ
Task.Factory.StartNew(() =>
{
Thread.Sleep(10000);
var form3 = app.Type().System.Windows.Forms.Form();
form3.Text = "3";
form3.Show();
});
var third = WindowControl.WaitForIdentifyFromWindowText(app, "3");
//Get
//複数あった場合、複数とれる
var many = WindowControl.GetFromTypeFullName(app, "System.Windows.Forms.Form");
Assert.AreEqual(2, many.Length);
Process.GetProcessById(app.ProcessId).Kill();
}
示例13: WinForms
public void WinForms()
{
var app = new WindowsAppFriend(Process.Start("WinForms.exe"));
var form = app.Type().System.Windows.Forms.Application.OpenForms[0];
WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
var _grid = form._grid;
_grid.CurrentCell = _grid[0, 0];
app.Type(GetType()).Edit(_grid, "abc");
var wrap = new FormsDataGridView(_grid);
wrap.EmulateChangeCellText(0, 1, "xyz");
Process.GetProcessById(app.ProcessId).Kill();
}
示例14: Wpf
public void Wpf()
{
var app = new WindowsAppFriend(Process.Start("Wpf.exe"));
AppVar window = app.Type().System.Windows.Application.Current.MainWindow;
var logicalTree = window.LogicalTree();
var buttonModal = new WPFButtonBase(logicalTree.ByBinding("CommandModal").Single());
var buttonModeless = new WPFButtonBase(logicalTree.ByBinding("CommandModeless").Single());
//モーダレスは通常はそのままでOK
buttonModeless.EmulateClick();
var next = app.Type().System.Windows.Application.Current.Windows[1];
next.Title = "aaa";
//でもたまに変なことしているやつがいれば注意
//まあ、こっち使った方が無難
var nextW = WindowControl.WaitForIdentifyFromWindowText(app, "aaa");
nextW.Dynamic().Close();
//モーダルは要注意
var current = new WindowControl(window);
{
var a = new Async();
buttonModal.EmulateClick(a);
var modal = current.WaitForNextModal();
modal.Dynamic().Close();
a.WaitForCompletion();
}
//連続で出るやつはもっと注意
var buttonModalSequential = new WPFButtonBase(logicalTree.ByBinding("CommandModalSequential").Single());
{
var a = new Async();
buttonModalSequential.EmulateClick(a);
var modal1 = current.WaitForNextModal();
modal1.Dynamic().Close();
modal1.WaitForDestroy();
var modal2 = current.WaitForNextModal();
modal2.Dynamic().Close();
modal2.WaitForDestroy();
a.WaitForCompletion();
}
Process.GetProcessById(app.ProcessId).Kill();
}
示例15: WPF
public void WPF()
{
var app = new WindowsAppFriend(Process.Start("Wpf.exe"));
var window = app.Type().System.Windows.Application.Current.MainWindow;
//ガタガタ言わずにx:Name使えばいいじゃん。
var _textBox = new WPFTextBox(window._textBox);
_textBox.EmulateChangeText("x:Name最高!");
//嫌って言う人いるから頑張ったよ。
AppVar windowAppVar = window;
var logicalTree = windowAppVar.LogicalTree();
var textBox = new WPFTextBox(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBox>().Single());
var textBlock = new WPFTextBlock(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBlock>().Single());
var buttonModal = new WPFButtonBase(logicalTree.ByBinding("CommandModal").Single());
var buttonModalSequential = new WPFButtonBase(logicalTree.ByBinding("CommandModalSequential").Single());
var buttonModeless = new WPFButtonBase(logicalTree.ByBinding("CommandModeless").Single());
var listBox = new WPFListBox(logicalTree.ByBinding("Persons").Single());
//VisualTreeにしか現れない要素は気を付けて
var item = listBox.GetItem(20);
var itemText = new WPFTextBlock(item.VisualTree().ByBinding("Name").Single());
//これでもダメな場合は工夫してね!
Process.GetProcessById(app.ProcessId).Kill();
}