public void ButtonClickAsyncTest()
        {
            // Arrenge
            dynamic main = _app.Type<Application>().Current.MainWindow;
            AppVar buttonCore = _app.Type<Button>()();
            main._grid.Children.Add(buttonCore);
            dynamic checker = _app.Type<ButtonEventCheck>()(buttonCore, true);
            WindowControl windowControl = WindowControl.FromZTop(_app);
            WPFButtonBase ButtonBase = new WPFButtonBase(buttonCore);

            // Act
            Async async = new Async();
            ButtonBase.EmulateClick(async);

            // Assert
            WindowControl messageBoxControl = windowControl.WaitForNextModal();
            NativeMessageBox messageBox = new NativeMessageBox(messageBoxControl);
            Assert.AreEqual("TestMessageWindow", messageBox.Message);
            Assert.IsTrue((bool)checker.ButtonClickCalled);

            // Teardown
            messageBox.EmulateButtonClick("OK");
            messageBoxControl.WaitForDestroy();
            async.WaitForCompletion();
        }
示例#2
0
        public void ButtonClickAsyncTest()
        {
            // Arrenge
            dynamic main       = _app.Type <Application>().Current.MainWindow;
            AppVar  buttonCore = _app.Type <Button>()();

            main._grid.Children.Add(buttonCore);
            dynamic       checker       = _app.Type <ButtonEventCheck>()(buttonCore, true);
            WindowControl windowControl = WindowControl.FromZTop(_app);
            WPFButtonBase ButtonBase    = new WPFButtonBase(buttonCore);

            // Act
            Async async = new Async();

            ButtonBase.EmulateClick(async);

            // Assert
            WindowControl    messageBoxControl = windowControl.WaitForNextModal();
            NativeMessageBox messageBox        = new NativeMessageBox(messageBoxControl);

            Assert.AreEqual("TestMessageWindow", messageBox.Message);
            Assert.IsTrue((bool)checker.ButtonClickCalled);

            // Teardown
            messageBox.EmulateButtonClick("OK");
            messageBoxControl.WaitForDestroy();
            async.WaitForCompletion();
        }
示例#3
0
        public void RegisterFemaleSns()
        {
            Thread.Sleep(1000);
            dynamic window      = _app.Type <Application>().Current.MainWindow;
            var     nameTextBox = new WPFTextBox(window.Name);

            nameTextBox.EmulateChangeText("Peach");
            Thread.Sleep(1000);

            var sexRadio = new WPFButtonBase(window.Female);

            sexRadio.EmulateClick();

            Thread.Sleep(1000);

            var reasonComboBox = new WPFComboBox(window.Reason);

            reasonComboBox.EmulateChangeSelectedIndex(2);

            Thread.Sleep(1000);

            var registerBtn = new WPFButtonBase(window.RegisterBtn);

            registerBtn.EmulateClick();

            var outputTxtBlock = new WPFTextBlock(window.Output);

            Assert.AreEqual(outputTxtBlock.Text.Replace("\n", ""), $"登録者名: Peach\n性別: 女性\n登録する経緯: SNSで見た".Replace("\n", ""));

            Thread.Sleep(1000);
        }
示例#4
0
        /// <summary>
        /// https://hgotoh.jp/wiki/doku.php/documents/voiceroid/tips/tips-003 様より
        /// </summary>

        // テキスト転記と再生ボタン押下
        public static void Talk(string talkText)
        {
            if (hWnd == IntPtr.Zero)
            {
                hWnd = GetVoiceroid2HWnd();
            }

            if (hWnd == IntPtr.Zero)
            {
                Console.WriteLine("VOICEROID2を起動してください。");
                return;
            }

            try
            {
                // プロセスに接続する
                var app = new WindowsAppFriend(hWnd);

                // テキスト入力欄と再生ボタンを特定する
                var uiTreeTop    = WindowControl.FromZTop(app);
                var textEditView = uiTreeTop.GetFromTypeFullName("AI.Talk.Editor.TextEditView")[0].LogicalTree();
                var talkTextBox  = new WPFTextBox(textEditView[4]);
                var playButton   = new WPFButtonBase(textEditView[6]);

                // テキストを入力し、再生する
                talkTextBox.EmulateChangeText(talkText);
                playButton.EmulateClick();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                hWnd = IntPtr.Zero;
            }
        }
示例#5
0
        public async Task Play(String msg)
        {
            await Task.Run(async() =>
            {
                talkTextBox.EmulateChangeText(msg);

                if (!saveButton.IsEnabled)
                {
                    while (!saveButton.IsEnabled)
                    {
                        await Task.Delay(100);
                    }
                }

                playButton.EmulateClick();
                await Task.Delay(1000);

                if (!saveButton.IsEnabled)
                {
                    while (!saveButton.IsEnabled)
                    {
                        await Task.Delay(100);
                    }
                }
            });
        }
示例#6
0
        /// <summary>
        /// VOICEROID2 の再生を停止します(停止ボタンを押す)
        /// </summary>
        public void Stop()
        {
            StopSpeech();
            WPFButtonBase stopButton = new WPFButtonBase(_root.IdentifyFromLogicalTreeIndex(0, 4, 3, 5, 3, 0, 3, 1));

            stopButton.EmulateClick();
        }
示例#7
0
        async void consumeMessage()
        {
            await initTask;
            var   lastPlay     = DateTime.Now;
            var   talkCooldown = TimeSpan.FromSeconds(0.3);

            while (!cancelled)
            {
                string message;
                if (!messageQueue.TryTake(out message, 1000))
                {
                    continue;
                }
                // VOICEROID2が発話中の時は「先頭」ボタンが無効になるので、それを利用して発話中かどうかを判定します
                while (!beginButton.IsEnabled)
                {
                    Thread.Sleep(50); // spin wait
                }
                var now = DateTime.Now;
                if ((now - lastPlay) < talkCooldown)
                {
                    Thread.Sleep(talkCooldown - (now - lastPlay));
                }
                lastPlay = DateTime.Now;
                stopButton.EmulateClick();
                talkTextBox.EmulateChangeText(message);
                beginButton.EmulateClick();
                playButton.EmulateClick();
            }
        }
示例#8
0
        public void TestMethod1()
        {
            var main        = new WindowControl(mainCore);
            var CurrentText = new WPFTextBlock(mainCore.CurrentText);

            //各ボタンの初期状態を確認
            Assert.AreEqual(true, _startButton.IsEnabled);
            Assert.AreEqual(false, _stopButton.IsEnabled);
            Assert.AreEqual(false, _resetButton.IsEnabled);
            Assert.AreEqual(false, _lapButton.IsEnabled);

            //ストップウォッチ画面の初期表示
            Assert.AreEqual(CurrentText.Text, "00:00:00:00");

            //ストップウォッチ起動(非同期)~停止まで
            var async = new Async();

            _startButton.EmulateClick(async);

            Thread.Sleep(1000);

            _stopButton.EmulateClick();
            async.WaitForCompletion();

            //ストップウォッチ画面が更新されているか
            Assert.AreNotEqual(CurrentText.Text, "00:00:00:00");
        }
 public void GetCoreElementTest()
 {
     WPFMenuBase menu = new WPFMenuBase(_ctrl._menu);
     var item = menu.GetItem(2);
     var button = new WPFButtonBase(item.GetCoreElement(typeof(Button).FullName));
     button.EmulateClick();
     Assert.IsTrue((bool)_ctrl.menuButtonClicked);
 }
        public void GetCoreElementTest()
        {
            WPFMenuBase menu   = new WPFMenuBase(_ctrl._menu);
            var         item   = menu.GetItem(2);
            var         button = new WPFButtonBase(item.GetCoreElement(typeof(Button).FullName));

            button.EmulateClick();
            Assert.IsTrue((bool)_ctrl.menuButtonClicked);
        }
        public void GetCoreElementTest()
        {
            WPFTreeView tree   = new WPFTreeView(_ctrl._tree);
            var         item   = tree.GetItem(1);
            var         button = new WPFButtonBase(item.GetCoreElement(typeof(Button).FullName));

            button.EmulateClick();
            Assert.IsTrue((bool)_ctrl.treeButtonClicked);
        }
        public void HeaderContentTest()
        {
            WPFTreeView tree   = new WPFTreeView(_ctrl._tree);
            var         item   = tree.GetItem(1);
            var         button = new WPFButtonBase(item.HeaderContent.VisualTree().ByType <Button>().Single());

            button.EmulateClick();
            Assert.IsTrue((bool)_ctrl.treeButtonClicked);
        }
示例#13
0
        /// <summary>
        /// VOICEROID2 に入力された文字列を再生します
        /// </summary>
        public void Play()
        {
            WPFButtonBase playButton = new WPFButtonBase(_root.IdentifyFromLogicalTreeIndex(0, 4, 3, 5, 3, 0, 3, 0));

            playButton.EmulateClick();
            Application.DoEvents();
            _isPlaying = true;
            _isRunning = false;
            _timer.Start();
        }
        public void ButtonClickTest()
        {
            // Arrenge
            dynamic main = _app.Type<Application>().Current.MainWindow;
            AppVar buttonCore = _app.Type<Button>()();
            main._grid.Children.Add(buttonCore);
            dynamic checker = _app.Type<ButtonEventCheck>()(buttonCore, false);
            WPFButtonBase ButtonBase = new WPFButtonBase(buttonCore);

            // Act
            ButtonBase.EmulateClick();
            Assert.IsTrue((bool)checker.ButtonClickCalled);
        }
示例#15
0
        public void ButtonClickTest()
        {
            // Arrenge
            dynamic main       = _app.Type <Application>().Current.MainWindow;
            AppVar  buttonCore = _app.Type <Button>()();

            main._grid.Children.Add(buttonCore);
            dynamic       checker    = _app.Type <ButtonEventCheck>()(buttonCore, false);
            WPFButtonBase ButtonBase = new WPFButtonBase(buttonCore);

            // Act
            ButtonBase.EmulateClick();
            Assert.IsTrue((bool)checker.ButtonClickCalled);
        }
示例#16
0
        public void Clear()
        {
            dynamic window      = _app.Type <Application>().Current.MainWindow;
            var     nameTextBox = new WPFTextBox(window.Name);

            nameTextBox.EmulateChangeText(string.Empty);

            var sexRadio = new WPFButtonBase(window.Male);

            sexRadio.EmulateClick();

            var reasonComboBox = new WPFComboBox(window.Reason);

            reasonComboBox.EmulateChangeSelectedIndex(-1);
        }
        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();
        }
        private void timer_Elapsed(object sender, EventArgs e)
        {
            _timer.Stop(); // 途中の処理が重いため、タイマーをいったん止める
            lock (_lockObject)
            {
                _tickCount += _timer.Interval;

                // ここからプロセス間通信&UI操作(重い)
                //WPFButtonBase playButton = new WPFButtonBase(_root.IdentifyFromLogicalTreeIndex(0, 4, 3, 6, 3, 0, 3, 0));
                WPFButtonBase             playButton = new WPFButtonBase(_root.IdentifyFromLogicalTreeIndex(0, 4, 3, 6, 3, 0, 0, 0, 1, 3, 0));
                var                       d          = playButton.LogicalTree();
                System.Windows.Visibility v          = (System.Windows.Visibility)(d[2])["Visibility"]().Core; // [再生]の画像の表示状態
                                                                                                               // ここまで

                if (v != System.Windows.Visibility.Visible && !_isRunning)
                {
                    _isRunning = true;
                }
                else
                // 再生開始から 500 ミリ秒程度経過しても再生ボタンがうまく確認できなかった場合にも完了とみなす
                if (v == System.Windows.Visibility.Visible && (_isRunning || (!_isRunning && _tickCount > 500)))
                {
                    if (_queue.Count == 0)
                    {
                        StopSpeech();
                        return; // タイマーが止まったまま終了
                    }
                    else
                    {
                        // 喋るべき内容が残っているときは再開
                        string t = _queue.Dequeue();
//                        WPFTextBox textbox = new WPFTextBox(_root.IdentifyFromLogicalTreeIndex(0, 4, 3, 6, 3, 0, 2));
                        WPFTextBox textbox = new WPFTextBox(_root.IdentifyFromLogicalTreeIndex(0, 4, 3, 6, 3, 0, 0, 0, 1, 2));
                        textbox.EmulateChangeText(t);

                        playButton.EmulateClick();
                        _isPlaying = true;
                        _isRunning = false;
                        _tickCount = 0;
                    }
                }

                _timer.Start();
            }
        }
        public void TestInitialize()
        {
            //start process.
            var process = Process.Start(ProcessPath);

            //attach by friendly.
            _app = new WindowsAppFriend(process);

            //show next dialog.
            var mainWindow = _app.WaitForIdentifyFromTypeFullName("SampleApp.MainWindow");
            var button     = new WPFButtonBase(mainWindow.Dynamic()._buttonNextDialog);

            button.EmulateClick(new Async());

            //get next dialog.
            var nextDialog = _app.WaitForIdentifyFromTypeFullName("SampleApp.NextDialog");

            //create driver.
            _driver = new CefSharpDriver(nextDialog.Dynamic()._browser);
        }
示例#20
0
        public void MessageBoxTest()
        {
            var async = new Async();

            _messageBoxButton.EmulateClick(async);

            //メッセージボックスを取得
            var main        = new WindowControl(mainCore);
            var childWindow = main.WaitForNextModal();
            var msg         = new NativeMessageBox(childWindow);

            //メッセージを取得
            Assert.AreEqual("msg", msg.Message);

            //テキストからボタンを検索して押す
            msg.EmulateButtonClick("OK");

            //非同期処理の完了待ち
            async.WaitForCompletion();
        }
示例#21
0
        /// <summary>
        /// 指定パスにあるフレーズ辞書を現在使用されているフレーズ辞書に統合します。
        /// 統合は後勝ちで実行されます。
        /// </summary>
        /// <param name="srcPdicPath"></param>
        public void MergePdicToCurrent(string srcPdicPath)
        {
            Async       async  = new Async();
            Async       async1 = new Async();
            WPFMenuItem mi     = new WPFMenuItem(rootControl.LogicalTree().ByType <MenuItem>().ByBinding("OptionsCommand").Single());

            mi.EmulateClick(async);
            WindowControl settingsWindow       = rootControl.WaitForNextModal();
            WPFButtonBase mergePhraseDicButton = new WPFButtonBase(settingsWindow.LogicalTree().ByType <Button>().ByBinding("MergePhraseDicCommand").Single());

            mergePhraseDicButton.EmulateClick(async1);
            WindowControl selectDialog = rootControl.WaitForNextModal();

            MergeFile(selectDialog, srcPdicPath);

            WindowControl resultDialog = settingsWindow.WaitForNextModal().WaitForNextModal();

            new NativeButton(resultDialog.IdentifyFromWindowText("OK")).EmulateClick();
            new WPFButtonBase(settingsWindow.LogicalTree().ByType <Button>().ByBinding("OkCommand").Single()).EmulateClick();
            async1.WaitForCompletion();
            async.WaitForCompletion();
        }
示例#22
0
        public async Task Save(string msg, string fileName)
        {
            await Task.Run(async() =>
            {
                try
                {
                    //フォーカスしないようにする
                    //ShowWindow(mainWindowHandle.ToInt32(), SW_HIDE);
                    await Task.Delay(100);

                    //再生完了待機
                    while (!saveButton.IsEnabled)
                    {
                        Console.WriteLine("saveBtn is not enabled");
                        await Task.Delay(100);
                    }

                    talkTextBox.EmulateChangeText(msg);

                    var async = new Async();
                    saveButton.EmulateClick(async);
                    //名前を付けて保存ダイアログ
                    var saveFileWindow = uiTreeTop.WaitForNextModal();
                    var saveFileDialog = new NativeMessageBox(saveFileWindow);

                    //ファイル名を入力
                    //右上の検索欄にも入力されてしまうが無視
                    var edits = saveFileDialog.Window.GetFromWindowClass("Edit");
                    foreach (var t in edits)
                    {
                        var edit = new NativeEdit(t);
                        edit.EmulateChangeText(fileName);
                    }

                    saveFileDialog.EmulateButtonClick("保存(&S)");
                    //saveFileWindow.WaitForDestroy();

                    //出力状況を表示するダイアログの表示を待つ
                    Console.WriteLine("waiting for showing progress window");
                    var progressWindow = uiTreeTop.WaitForNextModal();
                    if (progressWindow == null)
                    {
                        progressWindow = uiTreeTop.WaitForNextModal();
                    }
                    Console.WriteLine("showed " + progressWindow.GetWindowText());

                    var tokenSource = new CancellationTokenSource();
                    var task        = new TaskFactory().StartNew(() =>
                    {
                        //完了通知ダイアログの表示を待つ
                        Console.WriteLine("wationg for showing saving complete window");
                        var completeWindow = progressWindow.WaitForNextModal();
                        if (completeWindow != null)
                        {
                            Console.WriteLine("showed " + completeWindow.GetWindowText());
                            Console.WriteLine(DateTime.Now);
                            try
                            {
                                var completeDialog = new NativeMessageBox(completeWindow);
                                completeDialog.EmulateButtonClick("OK");
                                Console.WriteLine("wating for destroying");
                                completeWindow.WaitForDestroy();
                                Console.WriteLine("finish");
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        }
                    }, tokenSource.Token);
                    try
                    {
                        Console.WriteLine(DateTime.Now);
                        if (!task.Wait(5000))
                        {
                            tokenSource.Cancel();
                            Console.WriteLine("timeout");
                            Console.WriteLine(DateTime.Now);
                            var windows = WindowControl.GetTopLevelWindows(uiTreeTop.App);
                            foreach (var window in windows)
                            {
                                Console.WriteLine(window.GetWindowText());
                                var btnList = window.LogicalTree().ByType <Button>();
                                var count   = btnList.Count;
                                for (int i = 0; i < count; i++)
                                {
                                    var btn        = new WPFButtonBase(btnList[i]);
                                    var btnTxtList = btn.LogicalTree(TreeRunDirection.Descendants).ByType <TextBlock>();
                                    if (btnTxtList.Count == 1)
                                    {
                                        var btnTxt = new WPFTextBlock(btnTxtList.Single());
                                        Console.WriteLine(btnTxt.Text);
                                        if (btnTxt.Text.Equals("キャンセル"))
                                        {
                                            btn.EmulateClick();
                                        }
                                    }
                                }
                            }

                            var completeWindow = progressWindow.WaitForNextModal();
                            Console.WriteLine("showed2 " + completeWindow.GetWindowText());
                            Console.WriteLine("2" + DateTime.Now);
                            var completeDialog = new NativeMessageBox(completeWindow);
                            completeDialog.EmulateButtonClick("OK");
                            Console.WriteLine("wating for destroying2");
                            completeWindow.WaitForDestroy();
                            Console.WriteLine("finish2");
                        }
                    }
                    catch (AggregateException)
                    {
                        //タスクがキャンセルされた
                        Console.WriteLine("task was canceled");
                        var completeWindow = WindowControl.FromZTop(uiTreeTop.App);
                        Console.WriteLine("showed3 " + completeWindow.GetWindowText());
                        var completeDialog = new NativeMessageBox(completeWindow);
                        completeDialog.EmulateButtonClick("OK");
                        Console.WriteLine("wating for destroying3");
                        completeWindow.WaitForDestroy();
                        Console.WriteLine("finish3");
                    }

                    if (!async.IsCompleted)
                    {
                        try
                        {
                            Console.WriteLine("wating for async finish");
                            async.WaitForCompletion();
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
                finally
                {
                    //ShowWindow(mainWindowHandle.ToInt32(), SW_MINIMIZE);
                    Console.WriteLine("complete saving");
                }
            });
        }
示例#23
0
        static void Main(string[] args)
        {
            // プロセスの取得
            Process[] ps = Process.GetProcessesByName("VoiceroidEditor");
            if (ps.Length == 0)
            {
                Console.Error.WriteLine("VOICEROID2を起動してください");
                return;
            }

            // WindowsAppFriendをプロセスから作成する
            // 接続できない旨のエラーの場合、別のプロセスでテスト対象のプロセスを操作している場合がある。
            // TestAssistant使いながら動作できないようなので、注意。
            var app = new WindowsAppFriend(ps[0]);

            var mainWindow = WindowControl.FromZTop(app);

            // 茜ちゃんしゃべる
            WPFTextBox txtMessage = new WPFTextBox(mainWindow.IdentifyFromLogicalTreeIndex(0, 4, 3, 5, 3, 0, 2));

            txtMessage.EmulateChangeText("アカネチャンカワイイヤッタ");

            WPFButtonBase btnPlay = new WPFButtonBase(mainWindow.IdentifyFromLogicalTreeIndex(0, 4, 3, 5, 3, 0, 3, 0));

            btnPlay.EmulateClick();

            // ステータスバーを監視してしゃべり終わるまでまつ
            String sts;

            do
            {
                System.Threading.Thread.Sleep(500);
                var txtStatusItem = mainWindow.IdentifyFromVisualTreeIndex(0, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0).Dynamic();;
                sts = txtStatusItem.Text.ToString();
            } while (!sts.Equals("テキストの読み上げは完了しました。"));

            // 保存ボタン押下
            // ダイアログが表示されると引数なしのEmulateClickだと止まるのでAsyncオブジェクトを渡しておく
            var           async   = new Async();
            WPFButtonBase btnSave = new WPFButtonBase(mainWindow.IdentifyFromLogicalTreeIndex(0, 4, 3, 5, 3, 0, 3, 5));

            btnSave.EmulateClick(async);

            // 音声保存ダイアログ操作
            var           dlgSaveWav   = mainWindow.WaitForNextModal();
            var           asyncSaveWin = new Async();
            WPFButtonBase buttonOK     = new WPFButtonBase(dlgSaveWav.IdentifyFromLogicalTreeIndex(0, 1, 0));

            buttonOK.EmulateClick(asyncSaveWin);

            // ファイル名指定後の保存
            var        asyncSaveFile = new Async();
            var        dlgFileSave   = dlgSaveWav.WaitForNextModal();
            NativeEdit editFileName  = new NativeEdit(dlgFileSave.IdentifyFromZIndex(11, 0, 4, 0, 0));

            editFileName.EmulateChangeText(System.DateTime.Now.ToString("yyyymMMddhhmmss") + ".wav");

            NativeButton btnSaveOk = new NativeButton(dlgFileSave.IdentifyFromDialogId(1));

            btnSaveOk.EmulateClick(asyncSaveFile);

            // 情報ダイアログが表示されるまで待機してOKを押下
            var          dlgInfo = WindowControl.WaitForIdentifyFromWindowText(app, "情報");
            NativeButton btn     = new NativeButton(dlgInfo.IdentifyFromWindowText("OK"));

            btn.EmulateClick();


            //非同期で実行した保存ボタン押下の処理が完全に終了するのを待つ
            asyncSaveFile.WaitForCompletion();
            asyncSaveWin.WaitForCompletion();
            async.WaitForCompletion();


            // 葵ちゃんに切り替えてしゃべる
            // UIAutomationだと葵ちゃん切り替えが行えない。
            WPFListView ListView = new WPFListView(mainWindow.IdentifyFromLogicalTreeIndex(0, 4, 3, 3, 0, 1, 0, 2));

            ListView.EmulateChangeSelectedIndex(1);
            txtMessage.EmulateChangeText("オネエチャンカワイイヤッタ");
            btnPlay.EmulateClick();
            ListView.EmulateChangeSelectedIndex(0);
        }
 public void HeaderContentTest()
 {
     WPFTreeView tree = new WPFTreeView(_ctrl._tree);
     var item = tree.GetItem(1);
     var button = new WPFButtonBase(item.HeaderContent.VisualTree().ByType<Button>().Single());
     button.EmulateClick();
     Assert.IsTrue((bool)_ctrl.treeButtonClicked);
 }
 public void GetCoreElementTest()
 {
     WPFTreeView tree = new WPFTreeView(_ctrl._tree);
     var item = tree.GetItem(1);
     var button = new WPFButtonBase(item.GetCoreElement(typeof(Button).FullName));
     button.EmulateClick();
     Assert.IsTrue((bool)_ctrl.treeButtonClicked);
 }
        /// <summary>
        /// VOICEROID2 に入力された文字列を保存します
        /// </summary>
        private void Save(string outputFilePath)
        {
            // 「音声保存」ボタン押下
            WPFButtonBase saveButton = new WPFButtonBase(_root.IdentifyFromLogicalTreeIndex(0, 4, 3, 5, 3, 0, 3, 5));

            saveButton.EmulateClick(new Async());
            Application.DoEvents();

            // 音声保存設定ダイアログの OK ボタン押下
            var           saveWindow   = WindowControl.GetFromWindowText(_app, "音声保存")[0];
            WPFButtonBase saveOkButton = new WPFButtonBase(saveWindow.IdentifyFromLogicalTreeIndex(0, 1, 0));

            saveOkButton.EmulateClick(new Async());
            Application.DoEvents();

            // 「名前を付けて保存」ダイアログで出力ファイル名を入力して OK ボタン押下
            WindowControl saveDialog          = WindowControl.WaitForIdentifyFromWindowText(_app, "名前を付けて保存");
            NativeButton  saveDialogButton    = new NativeButton(saveDialog.IdentifyFromDialogId(1));
            NativeEdit    saveFileNameTextBox = new NativeEdit(saveDialog.IdentifyFromZIndex(11, 0, 4, 0, 0));

            saveFileNameTextBox.EmulateChangeText(outputFilePath);
            Application.DoEvents();
            saveDialogButton.EmulateClick(new Async());
            Application.DoEvents();

            // 上書き確認ダイアログが出てきたら、 OK ボタンを押下
            // 出てくる前提で作っているけど、なぜか出ない場合でも問題なく動いているっぽい。
            while (true)
            {
                try {
                    WindowControl saveConfirmDialog       = WindowControl.IdentifyFromWindowText(_app, "名前を付けて保存");
                    NativeButton  saveConfirmDialogButton = new NativeButton(saveConfirmDialog.IdentifyFromDialogId(6));
                    saveConfirmDialogButton.EmulateClick(new Async());
                    Application.DoEvents();
                }
                catch (WindowIdentifyException e)
                {
                    // do nothing
                }

                // 保存成功通知ダイアログの OK ボタンを押下
                try {
                    WindowControl infoDialog       = WindowControl.IdentifyFromWindowText(_app, "情報");
                    NativeButton  infoDialogButton = new NativeButton(infoDialog.IdentifyFromDialogId(2));
                    infoDialogButton.EmulateClick(new Async());
                    Application.DoEvents();
                    break;
                }
                catch (WindowIdentifyException e)
                {
                    // do nothing
                }

                Thread.Sleep(100);
            }

            // おまじない
            // 再生の時もこれやっているので、何か意味があるのだろう。
            _isPlaying = false;
            _isRunning = false;
            _timer.Start();
        }