/// <summary> /// 認証コードを取得する。 /// VOICEROID2エディタが実行中である必要がある。 /// </summary> /// <returns>認証コードのシード値</returns> public static string GetKey(string process_name) { // VOICEROIDエディタのプロセスを検索する Process[] voiceroid_processes = Process.GetProcessesByName(process_name); if (voiceroid_processes.Length == 0) { return(null); } Process process = voiceroid_processes[0]; // プロセスに接続する WindowsAppFriend app = new WindowsAppFriend(process); WindowsAppExpander.LoadAssembly(app, typeof(Injecter).Assembly); dynamic injected_program = app.Type(typeof(Injecter)); try { // 認証コードを読み取って返す return(injected_program.InjectedGetKey()); } catch (Exception) { return(null); } }
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 <WPFMenuItemTest>().Init(main._grid); }
static DTE2 GetDTE2(WindowsAppFriend app) { WindowsAppExpander.LoadAssembly(app, typeof(ByVisualStudio).Assembly); var dteType = app.Type(typeof(ByVisualStudio)).DTEType; AppVar obj = app.Type().Microsoft.VisualStudio.Shell.Package.GetGlobalService(dteType); return(obj.Pin <DTE2>()); }
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)); }
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 <ActiveItemTestControl>()(); main._grid.Children.Add(_ctrl); }
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); }
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); }
static void Init(AppVar appVar) { var app = (WindowsAppFriend)appVar.App; object dmy; string key = typeof(TreeExtensions).Assembly.FullName; if (!app.TryGetAppControlInfo(key, out dmy)) { WindowsAppExpander.LoadAssembly(app, typeof(TreeExtensions).Assembly); app.AddAppControlInfo(key, new object()); } }
/// <summary> /// Install RM.Friendly.WPFStandardControls.3.5.dll to target process. /// </summary> /// <param name="app">Application manipulation object.</param> #else /// <summary> /// 対象プロセスにRM.Friendly.WPFStandardControls.3.5.dllをインジェクションします。 /// </summary> /// <param name="app">アプリケーション操作クラス。</param> #endif public static void Injection(WindowsAppFriend app) { WPFStandardControls_3.Injection(app); string key = typeof(WPFStandardControls_3_5).FullName; object isInit; if (!app.TryGetAppControlInfo(key, out isInit)) { WindowsAppExpander.LoadAssembly(app, typeof(WPFStandardControls_3_5).Assembly); app.AddAppControlInfo(key, true); } }
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); }
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); }
public AppDriver(string args, int timeoutMs) { _proc = Process.Start(ExePath, args); _app = new WindowsAppFriend(_proc); _mainWindowDriver = new MainWindowDriver(_app.Type <System.Windows.Application>().Current.MainWindow); WPFStandardControls_3.Injection(_app); WPFStandardControls_3_5.Injection(_app); WPFStandardControls_4.Injection(_app); WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); _killer = new Killer(timeoutMs, _proc); }
/// <summary> /// Install RM.Friendly.WPFStandardControls.4.dll to target process. /// </summary> /// <param name="app">Application manipulation object.</param> #else /// <summary> /// 対象プロセスにRM.Friendly.WPFStandardControls.4.dllをインジェクションします。 /// </summary> /// <param name="app">アプリケーション操作クラス。</param> #endif public static void Injection(WindowsAppFriend app) { WPFStandardControls_3_5.Injection(app); string key = typeof(WPFStandardControls_4).ToString(); object isInit; if (!app.TryGetAppControlInfo(key, out isInit)) { WindowsAppExpander.LoadAssembly(app, typeof(WPFStandardControls_4).Assembly); ResourcesLocal4.Initialize(app); app.AddAppControlInfo(key, true); } }
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 <T>()(); grid.Children.Add(_target); WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); }
/// <summary> /// Install RM.Friendly.WPFStandardControls.3.dll to target process. /// </summary> /// <param name="app">Application manipulation object.</param> #else /// <summary> /// 対象プロセスにRM.Friendly.WPFStandardControls.3.dllをインジェクションします。 /// </summary> /// <param name="app">アプリケーション操作クラス。</param> #endif public static void Injection(WindowsAppFriend app) { string key = typeof(WPFStandardControls_3).FullName; object isInit; if (!app.TryGetAppControlInfo(key, out isInit)) { WindowsAppExpander.LoadAssembly(app, typeof(ControlDriverAttribute).Assembly); WindowsAppExpander.LoadAssembly(app, typeof(WindowControl).Assembly); WindowsAppExpander.LoadAssembly(app, typeof(WPFStandardControls_3).Assembly); ResourcesLocal3.Initialize(app); app.AddAppControlInfo(key, true); } }
public void DllInjectionTest() { dynamic window = _app.Type <Application>().Current.MainWindow; dynamic textBox = window._textBox; //The code let target process load current assembly. WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); //You can use class defined in current assembly dynamic observer = _app.Type <Observer>()(textBox); //Check change text textBox.Text = "abc"; Assert.IsTrue((bool)observer.TextChanged); }
public AppDriver() { if (Process != null) { return; } var dir = Path.GetFullPath("../../../WpfApplication/bin/Release"); var pathExe = dir + "/WpfApplication.exe"; var info = new ProcessStartInfo(pathExe) { WorkingDirectory = dir }; Process = Process.Start(pathExe); _app = new WindowsAppFriend(Process); WPFStandardControls_4.Injection(_app); WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); }
/// <summary> /// 初期化です。対象のアプリケーションにアセンブリを読み込ませます。 /// </summary> /// <param name="app">アプリケーション操作クラス。</param> internal static void Initialize(WindowsAppFriend app) { Type myType = typeof(Initializer); //初期化は一度だけです。 //何度呼び出しても問題はないが、パフォーマンスに効いてくるのでWindowsAppFriendのキャッシュを利用します。 string key = myType.Module.Name + "[Initialize]"; object isInit; if (!app.TryGetAppControlInfo(key, out isInit)) { //身初期化の場合はアセンブリを読み込ませます。 WindowsAppExpander.LoadAssembly(app, typeof(ControlDriverAttribute).Assembly); WindowsAppExpander.LoadAssembly(app, myType.Assembly); ResourcesLocal.Initialize(app); app.AddAppControlInfo(key, true); } }
public void Friendlyの基本機能() { var main = _app.Type <Application>().Current.MainWindow; main.Title = "xxx"; main.Background = _app.Type <Brushes>().Black; main.GlowBrush = _app.Type <Brushes>().Black; string result = main.Func(5); Assert.AreEqual("5", result); //データ書き換えたり var infos = main.DataContext._infos; infos.Clear(); infos.AddRange( new[] { new EntryInfo() { Name = "石川", Mail = "*****@*****.**", Language = "C#", IsMan = true, BirthDay = new DateTime(1977, 1, 7) } }); //DLLインジェクション WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); //メソッド呼び出し _app.Type(GetType()).ChangeTabColor(main); //モックも利用できます。 var mock = _app.Type <MockCommunicator>()(); main.DataContext._communicator = mock; //一旦手動で通信処理を実行 string data = mock.Data; Assert.AreEqual("石川", data); }
public void コントロール特定3() { WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); WPFStandardControls_3_5.Injection(_app); AppVar main = _app.Type <Application>().Current.MainWindow; var userControl = main.LogicalTree().ByType("WpfApplication.DemoSimpleControl").Single(); var elements = _app.Type(GetType()).GetDemoSimpleControlElements(userControl); var textBlokX = new WPFTextBlock(elements.TextBlockXName); var textBlokMail = new WPFTextBlock(elements.TextBlockMail); var textBlokxLanguage = new WPFTextBlock(elements.TextBlockLanguage); var textBoxX = new WPFTextBox(elements.TextBoxXName); var textBoxMail = new WPFTextBox(elements.TextBoxMail); var comboBoxxLanguage = new WPFComboBox(elements.ComboBoxLanguage); var buttonOpen = new WPFButtonBase(elements.ButtonOpen); var button1 = new WPFButtonBase(elements.Button1); var buttonA = new WPFButtonBase(elements.ButtonA); var buttonCancel = new WPFButtonBase(elements.ButtonCancel); }
public string[] ListBoxEmployee_GetSearchResult() { WindowsAppExpander.LoadAssembly(Window.App, GetType().Assembly); return(Window.App.Type(GetType()).GetListItems(ListBoxEmployee)); }
/// <summary> /// Constructor. /// </summary> /// <param name="appVar">Application variable object for the control.</param> #else /// <summary> /// コンストラクタです。 /// </summary> /// <param name="appVar">アプリケーション内変数。</param> #endif public C1FlexGridDriver(AppVar appVar) : base(appVar) { WindowsAppExpander.LoadAssembly((WindowsAppFriend)AppVar.App, typeof(C1FlexGridDriver).Assembly); }
/// <summary> /// Constructor. /// </summary> /// <param name="appVar">Application variable object for the control.</param> #else /// <summary> /// コンストラクタです。 /// </summary> /// <param name="appVar">アプリケーション内変数。</param> #endif public FpSpreadDriver(AppVar appVar) : base(appVar) { WindowsAppExpander.LoadAssembly((WindowsAppFriend)AppVar.App, typeof(FpSpreadDriver).Assembly); }
public void TestInitialize() { _app = new WindowsAppFriend(Process.Start("Target.exe")); WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); }