隱藏滑鼠游標調整

This commit is contained in:
jasonchenwork 2025-06-17 09:26:03 +08:00
parent 68501300a6
commit 3f5f0e5d08
2 changed files with 21 additions and 6 deletions

View File

@ -15,6 +15,7 @@ namespace DualScreenDemo
{
if (currentSequence[currentSequence.Count - 1] != correctSequence[currentSequence.Count - 1])
{
Console.WriteLine(currentSequence[currentSequence.Count - 1] +" 比對 " + correctSequence[currentSequence.Count - 1] +" 順序錯誤,重置序列");
// 順序錯誤,重置序列
currentSequence.Clear();
return;
@ -26,16 +27,23 @@ namespace DualScreenDemo
{
try
{
// 使用 Windows 命令關機
System.Diagnostics.Process.Start("shutdown", "/s /t 0");
// ✅ 這行要在主執行緒執行,避免 UI 錯誤
Cursor.Show();
Console.WriteLine("使用 Windows 命令關機");
// ✅ 關機動作移到背景執行緒
new System.Threading.Thread(() =>
{
System.Diagnostics.Process.Start("shutdown", "/s /t 0");
}).Start();
}
catch (Exception ex)
{
MessageBox.Show($"關機失敗: {ex.Message}");
// 如果關機失敗,退出程式
Application.Exit();
}
}
}
}
}

View File

@ -17,8 +17,15 @@ namespace DualScreenDemo
[STAThread]
static void Main()
{
Console.WriteLine("隱藏滑鼠游標");
Cursor.Hide();
AppDomain.CurrentDomain.ProcessExit += (s, e) =>
{
Cursor.Show();
};
Console.WriteLine("正在與中控取得聯繫");
var sender = new HeartbeatSender.heartbeatSender("http://zqd.superstar.dnsnet.cc/api/room/receiveRegister");
var sender = new HeartbeatSender.heartbeatSender();
// 同步呼叫非同步登入取得 token
bool loginSuccess = sender.LoginAndGetTokenAsync().GetAwaiter().GetResult();
@ -181,7 +188,7 @@ namespace DualScreenDemo
{
if (primaryForm.videoPlayerForm == null)
{
var filePath = @"C:\\video\\100015-周杰倫&aMei-不該-國語-vL-100-11000001.mpg";
var filePath = @"D:\\video\\100015-周杰倫&aMei-不該-國語-vL-100-11000001.mpg";
if (File.Exists(filePath))
{
Screen secondaryScreen = Screen.AllScreens.FirstOrDefault(s => !s.Primary);