有时候游戏全屏、窗口模式,或者办公软件
莫名其妙弹回桌面或者切换为非当前窗口
就可以用这个软件了
原理:通过检测当前窗口进程,路径,发现真凶是谁
使用方法:运行后挂到后台,等被弹窗了,就看看是哪个进程导致的
源码:
[Python] 纯文本查看 复制代码
import time
import win32gui
import win32process
import win32api
import win32con
import win32security
import psutil
def get_active_window_process_name():
last_fore = None
while True:
fore = win32gui.GetForegroundWindow()
if fore != last_fore:
last_fore = fore
tid, pid = win32process.GetWindowThreadProcessId(fore)
try:
process = psutil.Process(pid)
process_name = process.name()
username = process.username()
process_path = process.exe()
except Exception as e:
process_name = "N/A"
username = "N/A"
process_path = "N/A"
print(f"当前窗口名称: {process_name}, 系统用户名: {username}, 窗口路径: {process_path}")
time.sleep(0.01)
if __name__ == "__main__":
get_active_window_process_name()
成品软件下载