def quit(self, force=False): self.trayIcon.setToolTip('正在退出...') self.hide() self.trayIcon.hide() if force: win32process.ExitProcess(0) # 强制退出,避免退出较慢的问题。 self.app.exit()
def kill(): try: print "Kill removed reg" for thread in TIMER_ARRAY: thread.cancel() print "Kill timers" for thread in THREAD_ARRAY: thread.join() print "Kill threadss" except Exception as e: print str(e) win32process.ExitProcess(0)
def kill_self(): try: import win32process win32process.ExitProcess(0) except: pass try: import os, signal os.kill(os.getpid(), signal.SIGKILL) except: pass print('Might have to kill this one with Ctrl+C...') sys.exit(0)
def handler(event): win32process.ExitProcess(1)
import IPython import win32console, win32file, win32process hfile = win32console.GetStdHandle(win32console.STD_OUTPUT_HANDLE) IPython.embed() win32file.WriteFile(hfile, "Hello, World!") win32process.ExitProcess(0)
def on_expired(self): win32process.ExitProcess(0)