- if other_hwnd != 0:
- sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- sock.sendto('\0'.join(files), ("127.0.0.1", portNr))
-
- windll.user32.SetForegroundWindow(other_hwnd)
- return
+ if len(files) > 0:
+ try:
+ other_hwnd = windll.user32.FindWindowA(None, ctypes.c_char_p('Cura - ' + version.getVersion()))
+ if other_hwnd != 0:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ sock.sendto('\0'.join(files), ("127.0.0.1", portNr))
+
+ windll.user32.SetForegroundWindow(other_hwnd)
+ return
+ except:
+ pass