using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace KeyBoard2 { internal class Program { static void Main(string[] args) { string exePath = @"D:\work\WindowsFormsTest\KeyBoard2\bin\Debug\CCOnScreenKeyboard.exe"; // 替换为你的 exe 路径 string argsParam = "1 \r\n-ShowNumPad"; // 如果有参数,例如 "config.txt" try { // 1. 启动程序(隐藏模式) Console.WriteLine("正在启动程序..."); CCOnScreenKeyBoardClass.Start(exePath, argsParam, hidden: true); // 模拟程序运行一段时间 System.Threading.Thread.Sleep(3000); // 2. 检查状态 if (CCOnScreenKeyBoardClass.IsRunning) { Console.WriteLine("程序正在运行中。"); } // 3. 关闭程序 Console.WriteLine("正在关闭程序..."); CCOnScreenKeyBoardClass.Stop(forceKill: false); // 先尝试优雅关闭 Console.WriteLine("操作完成。"); } catch (Exception ex) { Console.WriteLine($"发生错误: {ex.Message}"); } } } }