import sys import win32gui import subprocess import time def pretreatmentHandle(): hwnd = win32gui.FindWindow("Progman", "Program Manager") workerW1 = None while 1: workerW1 = win32gui.FindWindowEx(None, workerW1, "WorkerW", None) if not workerW1: continue # print('workerW1: ', workerW1) subWinOfWorkerW1 = win32gui.FindWindowEx(workerW1, None, "SHELLDLL_DefView", None) if not subWinOfWorkerW1: continue # print('subWinOfWorkerW1: ', subWinOfWorkerW1) workerW2 = win32gui.FindWindowEx(None, workerW1, "WorkerW", None) if workerW2: # print('workerW2: ', workerW2) win32gui.SendMessage(workerW2, 0x0010, 0, 0) # WM_CLOSE break return hwnd if __name__ == "__main__": video_path = "D:\\Documents\\2439226.mp4" parameters = ["D:\\Downloads\\ffmpeg6.0\\bin\\ffplay.exe", video_path, "-noborder", "-x", "3440", "-y", "1440", "-fs", "-loop", "0"] time.sleep(0.2) startup_info = subprocess.STARTUPINFO() process = subprocess.Popen(parameters, startupinfo=startup_info) time.sleep(0.2) # 获取桌面管理器的窗口 program_win_h = win32gui.FindWindow("Progman", "Program Manager") print("原来的program窗口句柄:", program_win_h) # 发送消息新增Workrw窗口,有三/四层,顶层为Workrw,并且在Program窗口的上面 win32gui.SendMessageTimeout(program_win_h, 0x052C, 0, 0, win32gui.ILD_NORMAL, 300) # 将视频播放窗口设置为Program窗口的子窗口 time.sleep(1) program_win_h = win32gui.FindWindow("Progman", "Program Manager") print("分离后的program窗口句柄:", program_win_h) video_h = win32gui.FindWindow("SDL_app", None) win32gui.SetParent(video_h, program_win_h) pretreatmentHandle() process.wait()
标签:workerW2,workerW1,Python,win,None,Windows,program,win32gui,壁纸 From: https://www.cnblogs.com/cnLiou/p/17644839.html