Exemple #1
0
            // 音声効果のタブをクリックしておく、押さないと音声効果の各エディットボックスが生成されてないので
            private void SetupVocieEffectTab(bool is_top = true)
            {
                var wcm = GetWCM();

                // 再生ボタンの位置から、相対的に「音声効果」のボタンの場所を推定してクリックさせている
                // クリックの座標を知るために、アプリウィンドウの矩形と再生ボタンの矩形について取得
                // 座標がわかれば、あとは強制的にアプリをアクティブにしてクリック命令をする。
                var play_button = wcm.GetChiledByText(play_button_text);

                play_button.ClickL();
                var wc_top = wcm.GetTop();

                var wc_top_rc      = wc_top.GetRectange();
                var play_button_rc = play_button.GetRectange();

                var x         = play_button_rc.X - wc_top_rc.X + voice_effect_tab_offset_x;
                var y         = play_button_rc.Y - wc_top_rc.Y + voice_effect_tab_offset_y;
                var mouse_pos = new Point(x, y);

                wc_top.Active();
                WaitSleep.Do(100);
                wc_top.ClickLActive(mouse_pos.X, mouse_pos.Y);

                // タブを戻しておく
                if (is_top)
                {
                    WaitSleep.Do(100);
                    x         = play_button_rc.X - wc_top_rc.X + 20;                        // このあたりのオフセットはいい加減...
                    y         = play_button_rc.Y - wc_top_rc.Y + voice_effect_tab_offset_y; //
                    mouse_pos = new Point(x, y);
                    wc_top.ClickLActive(mouse_pos.X, mouse_pos.Y);
                }
            }
Exemple #2
0
            // 音声を保存する際に、別スレッドで保存ダイアログを処理するため
            private void SaveVoice_Dialog()
            {
                while (true)
                {
                    Thread.Sleep(10);
                    var wcm = new WindowControllerManager("音声ファイルの保存");
                    var dlg = wcm.GetTop();
                    if (dlg == null)
                    {
                        continue;
                    }
                    if (wcm.GetChiledByClassName("Edit") == null)
                    {
                        continue;
                    }
                    if (wcm.GetChiledByText("保存(&S)") == null)
                    {
                        continue;
                    }

                    var dir       = save_dir_path;
                    var name_head = output_name + "_";
                    var file_type = "wav";

                    var text_box  = wcm.GetChiledByClassName("Edit");
                    var file_path = CreateNextPathByVoiceRoid(dir, name_head, file_type);
                    text_box.SendText(file_path);

                    // 入力が正常にされてるかチェック
                    // 正常に動作していない場合は、時間をおいて再入力
                    var text          = text_box.GetText();
                    var i             = 0;
                    var re_set_marign = 10;
                    while (text != file_path)
                    {
                        Console.WriteLine("NG");
                        WaitSleep.Do(10);
                        if (i % re_set_marign == 0)
                        {
                            text_box.SendText(file_path);
                        }
                        i++;
                    }

                    WaitSleep.Do(10);
                    var ok_button = wcm.GetChiledByText("保存(&S)");
                    ok_button.ClickL();
                    WaitSleep.Do(10);

                    break;
                }
            }
Exemple #3
0
            // 音声効果のテンプレートを適応する
            public void DoVoiceEffectTemplate(string template_key)
            {
                if (!voice_effect_templates.ContainsKey(template_key))
                {
                    return;                                                    // キーがないならキャンセル
                }
                var vet = voice_effect_templates[template_key];

                var wcm              = GetWCM();
                var hit_text         = "音声効果";
                var voice_effect_tab = wcm.GetChiledByText(hit_text);

                if (voice_effect_tab == null)
                {
                    // 音声効果タブが押されたことがない?
                    // 押すだけ押してみる...
                    SetupVocieEffectTab(false);
                    WaitSleep.Do(100);
                    wcm = GetWCM(true);
                }

                var wc_list = new List <WindowController>();
                var MAX     = 99;

                for (var i = 0; i < MAX; i++)
                {
                    var edit = wcm.GetChiledByClassNameNear(".EDIT.", i);
                    if (edit == null)
                    {
                        break;
                    }

                    // 親の親のテキストが該当のものであれば、追加する
                    var edit_o1 = edit.GetOwner();
                    if (edit_o1 == null)
                    {
                        continue;
                    }
                    var edit_o2 = edit_o1.GetOwner();
                    if (edit_o2 == null)
                    {
                        continue;
                    }
                    if (edit_o2.text == hit_text)
                    {
                        wc_list.Add(edit);
                    }
                }

                if (wc_list.Count == 4)
                {
                    // 縦の順に並べ替える
                    var wc_list_tmp = new List <WindowController>();
                    while (wc_list.Count > 0)
                    {
                        int top_y = 0;
                        WindowController top_wc = null;
                        foreach (var item in wc_list)
                        {
                            var rc = item.GetRectange();
                            if (top_y == 0 || top_y < rc.Top)
                            {
                                top_wc = item;
                            }
                        }
                        wc_list_tmp.Add(top_wc);
                        wc_list.Remove(top_wc);
                    }
                    wc_list = wc_list_tmp;

                    for (var i = 0; i < 4; i++)
                    {
                        wc_list[i].SendText(vet.status[i]);
                        wc_list[i].Active();
                        WaitSleep.Do(100);
                    }
                    wc_list[0].Active();
                }
            }