private void Btn再生開始_Click(object sender, EventArgs e) { if (Gnd.I.Proc再生 != null) // ? already started { return; } this.MT_Enabled = false; try { string selFile = SaveLoadDialogs.LoadFile("実行するバッチファイルを選択して下さい", "バッチ:bat", Gnd.I.OutDir, "*.bat"); if (selFile != null) { if (selFile.StartsWith("\\\\")) { MessageBox.Show( "ネットワークパスは開けません。", "ファイル名に問題があります", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return; } if (JString.IsJString(selFile, true, false, false, true, false) == false) { MessageBox.Show( "Shift_JIS で表現出来ない文字を含むパスは開けません。", "ファイル名に問題があります", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return; } if (StringTools.IsSame(".bat", Path.GetExtension(selFile), true) == false) { MessageBox.Show( "選択されたパスはバッチファイルではありません。", "ファイル名に問題があります", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return; } Gnd.I.LastRanBatFile = selFile; Gnd.I.OutDir = Path.GetDirectoryName(Gnd.I.LastRanBatFile); Gnd.I.Proc再生 = CommonTools.StartProc(Gnd.I.LastRanBatFile); this.RefreshUi(); if (Gnd.I.StartMin) { this.WindowState = FormWindowState.Minimized; } } } finally { GC.Collect(); this.MT_Enabled = true; } }
private void MainTimer_Tick(object sender, EventArgs e) { if (this.MT_Enabled == false || this.MT_Busy) { return; } this.MT_Busy = true; try { if (Gnd.I.Proc記録 != null) { if (Gnd.I.Proc記録.WaitForExit(0)) { Gnd.I.Proc記録 = null; this.RefreshUi(); this.RecEnded(); return; } } if (Gnd.I.Proc再生 != null) { if (Gnd.I.Proc再生.WaitForExit(0)) { Gnd.I.Proc再生 = null; this.RefreshUi(); this.BatchEnded(); return; } if (Gnd.I.RCtrl中断 && CommonTools.IsRCtrlPressed()) { Gnd.I.Proc再生.Kill(); Gnd.I.Proc再生 = null; this.RefreshUi(); this.KilledBatch(); return; } } if (Gnd.I.AntiScreenSaver) { switch ((int)(this.MT_Count % 300L)) { case 0: Utils.WriteLog("ES_SYSTEM_REQUIRED"); Win32.SetThreadExecutionState(Win32.ExecutionState.ES_SYSTEM_REQUIRED); break; case 1: Utils.WriteLog("ES_DISPLAY_REQUIRED"); Win32.SetThreadExecutionState(Win32.ExecutionState.ES_DISPLAY_REQUIRED); break; } } } finally { this.MT_Busy = false; this.MT_Count++; } }
private void BtnOpenOutDir_Click(object sender, EventArgs e) { CommonTools.StartProc("CMD.exe", "/C START \"\" \"" + Gnd.I.OutDir + "\""); GC.Collect(); }