1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- '''
- @Contact : liuyuqi.gov@msn.cn
- @Time : 2022/10/05 06:14:26
- @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
- @Desc :
- '''
- import threading
- from ctypes import *
- import time
- import subprocess
- class ComputerMonitor:
- '''
-
- '''
- def __init__(self, callback):
- self.callback = callback
- self.started = False
- def monit_windows_lock(self):
- while True:
- process_name='LogonUI.exe'
- callall='TASKLIST'
- outputall=subprocess.check_output(callall)
- outputstringall=str(outputall)
- if process_name in outputstringall:
- print("Locked.")
- if self.callback:
- self.callback()
- else:
- pass
- time.sleep(1)
- def start(self):
- monitor_threading = threading.Thread(target=self.monit_windows_lock, args=())
- monitor_threading.start()
- self.started = True
-
|