rambo 7 hónapja
szülő
commit
290bdd8048
2 módosított fájl, 15 hozzáadás és 1 törlés
  1. 15 1
      python/mcu/DeviceControl.py
  2. BIN
      python/requestments.txt

+ 15 - 1
python/mcu/DeviceControl.py

@@ -15,7 +15,8 @@ from databases import insert_photo_records
 from .McuDeviationSet import McuDeviationSet
 from .OtherSet import OtherSet
 from .DebugUart import DebugUart
-
+import win32api, win32gui, win32con
+from win32gui import EnumWindows, GetWindowText
 # mcu命令
 class DeviceControl(BaseClass, metaclass=SingletonType):
     lock = threading.Lock()
@@ -132,6 +133,18 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         )
         self.msg_type = "mcu"
 
+    def close_other_window(self):
+        hwnd_list = []
+        def callback(hwnd, _):
+            title = GetWindowText(hwnd)
+            if title == "digiCamControl by Duka Istvan":
+                hwnd_list.append(hwnd)
+        EnumWindows(callback, None)
+        if hwnd_list:
+            hwnd = hwnd_list[0]
+            win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
+            return True
+
     def setOtherMaxMinValue(self,item, value):
         value = int(value)
         parameter_limits = {
@@ -180,6 +193,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
                 self.send_cmd()
                 # time.sleep(0.01)
                 self.get_basic_info_mcu()
+                self.close_other_window()
             except BaseException as e:
                 print("121231298908", e)
                 break

BIN
python/requestments.txt