From 0892515367798ec6b29dc80e2c4416c3cf3450d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Fri, 14 Jun 2024 10:57:11 +0800 Subject: [PATCH] yh --- CPF_Cef/Devices/WindowStalker.cs | 28 ++++++++++++++++++++++++++++ CPF_Cef/FrmMain.cs | 4 ++-- CPF_Cef/MainModel.cs | 6 ++---- CPF_Cef/Parame.cs | 2 +- 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 CPF_Cef/Devices/WindowStalker.cs diff --git a/CPF_Cef/Devices/WindowStalker.cs b/CPF_Cef/Devices/WindowStalker.cs new file mode 100644 index 0000000..0c1de42 --- /dev/null +++ b/CPF_Cef/Devices/WindowStalker.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace AksWebBrowser.Devices +{ + public class WindowStalker + { + [DllImport("libX11")] + private static extern bool XRaiseWindow(IntPtr display, IntPtr window); + + [DllImport("libX11")] + private static extern IntPtr XOpenDisplay(string displayName); + + [DllImport("libX11")] + private static extern IntPtr XDefaultRootWindow(IntPtr display); + + public static void BringWindowToFront() + { + IntPtr display = XOpenDisplay(null); + IntPtr rootWindow = XDefaultRootWindow(display); + XRaiseWindow(display, rootWindow); + } + } +} diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index 2f65d84..dce87ed 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -89,8 +89,8 @@ namespace AksWebBrowser //浏览器大小 Parame.webBrowser.Width = w; Parame.webBrowser.Height = h; - Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out"; - //Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; + //Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out"; + Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; //Parame.webBrowser.Url = Application.StartupPath + @"\html\index.html"; //开发者工具暂时只能支持Windows //webBrowser.ShowDev(); diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index e119d5c..b4b754a 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -1072,10 +1072,8 @@ namespace AksWebBrowser { try { - Task.Run(() => - { - Bash("/usr/bin/python3 /usr/bin/onboard"); - }); + // 在你的窗口或应用程序需要时调用 + Bash("/usr/bin/python3 /usr/bin/onboard"); return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + "唤醒键盘成功" + "\"}"; } catch (Exception ex) diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs index 0dfc4b5..186e4c6 100644 --- a/CPF_Cef/Parame.cs +++ b/CPF_Cef/Parame.cs @@ -19,7 +19,7 @@ namespace AksWebBrowser public static Window frm { get; set; } public static List FuncObject { get; set; } //接口地址 - public static string apiUrl ="http://127.0.0.1:8098"; // "http://192.168.0.34:92"; + public static string apiUrl = "http://192.168.0.34:92";// "http://127.0.0.1:8098"; //授权key public static string key = "1"; //硬件Ip