Exemplo n.º 1
0
        /// <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 SetUp()
 {
     //テスト用の画面起動
     app     = new WindowsAppFriend(Process.Start(Settings.TestApplicationPath));
     testDlg = WindowControl.FromZTop(app);
     WindowsAppExpander.LoadAssemblyFromFile(app, GetType().Assembly.Location);
 }
Exemplo n.º 3
0
        /// <summary>
        /// アセンブリをフルネームからロード
        /// </summary>
        //    [Test]
        public void TestExpandAssemblyFullName()
        {
            //NUnitのランタイムが4.0になったので一旦このテストは保留
            WindowControl targetForm = WindowControl.FromZTop(app);

            WindowsAppExpander.LoadAssemblyFromFullName(app, typeof(Microsoft.VisualBasic.Interaction).Assembly.FullName);
            app[typeof(Microsoft.VisualBasic.Interaction), "AppActivate"](app.ProcessId);
        }
Exemplo n.º 4
0
        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>());
        }
Exemplo n.º 5
0
        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 <WPFMenuItemTest>().Init(main._grid);
        }
Exemplo n.º 7
0
        public void TestExpandAssemblyFile()
        {
            WindowControl targetForm = WindowControl.FromZTop(app);

            WindowsAppExpander.LoadAssemblyFromFile(app, typeof(ExpandMethods).Assembly.Location);
            app[typeof(ExpandMethods), "SetText"]("xxx", targetForm.AppVar);
            Assert.AreEqual(targetForm["Text"]().ToString(), "xxx");
            Assert.AreEqual((int)app[typeof(ExpandMethods), "GetDataValue"](new Data(3)).Core, 3);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        /// <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);
            }
        }
Exemplo n.º 13
0
        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());
            }
        }
Exemplo n.º 14
0
        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);
        }
        /// <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);
            }
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        /// <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);
            }
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        /// <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 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);
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        public void TestLoadLibrary()
        {
            if (IntPtr.Size != 4)
            {
                return;
            }

            Assert.IsTrue(WindowsAppExpander.LoadLibrary(app, TargetPath.PathExpandNative));
            WindowsAppExpander.LoadAssemblyFromFile(app, typeof(ExpandMethods).Assembly.Location);

            //ロードしたDLLからMFCのメッセージボックスを呼び出し、それを閉じる
            WindowControl current = WindowControl.FromZTop(app);

            app[typeof(ExpandMethods), "Func", new Async()]("xxx");
            WindowControl next    = current.WaitForNextModal();
            WindowControl button2 = next.IdentifyFromZIndex(2);

            button2.SetFocus();
            button2.SequentialMessage(
                new MessageInfo(0x0201, 0x0001, 0),
                new MessageInfo(0x0202, 0x0000, 0));
        }
Exemplo n.º 25
0
        private void OnSelectApp(object sender, RoutedEventArgs e)
        {
            var dlg = new SelectAppWindow();
            var ret = dlg.ShowDialog() ?? false;

            if (ret == true)
            {
                var pid     = dlg.SelectedProcess.Process.Id;
                var process = Process.GetProcessById(pid);
                var app     = new WindowsAppFriend(process);

                dynamic win = app.Type <Application>().Current.MainWindow;
                WindowsAppExpander.LoadAssemblyFromFile(app, GetType().Assembly.Location);
                var sb = (ControlInfo[])GetInvoker(app).Dump(win, _temporaryImageStoreFolder);
                Map = new Dictionary <ControlInfo, WirePolyline>();
                ViewPort.Children.Clear();
                var root = sb.First();
                foreach (var c in sb)
                {
                    var frame = CreateControlFrameView(c, root);
                    Map.Add(c, frame);
                    if (c.TexturePath != null)
                    {
                        if (c.Children.Count == 0)
                        {
                            var body  = CreateControlBodyView(c, root);
                            var body2 = CreateControlBodyView2(c, root);
                            ViewPort.Children.Add(body);
                            ViewPort.Children.Add(body2);
                        }
                    }
                    ViewPort.Children.Add(frame);
                }
                Tree.ItemsSource = root.Children;
            }
        }
Exemplo n.º 26
0
 public void TestInitialize()
 {
     _app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(_app, GetType().Assembly);
 }
Exemplo n.º 27
0
 public string[] ListBoxEmployee_GetSearchResult()
 {
     WindowsAppExpander.LoadAssembly(Window.App, GetType().Assembly);
     return(Window.App.Type(GetType()).GetListItems(ListBoxEmployee));
 }
Exemplo n.º 28
0
        /// <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);
        }