哔哔one
这可能不是在我原来的问题中完成任务的最佳方法,但在按照本指南在 Windows 10 中启用原始 Windows 照片查看器之后:How-to-make-windows-photo-viewer-your-default-image-viewer -在windows-10上我制作了 4 个文件夹,每个文件夹中都有相应的图片(左上角、右上角、左下角和右下角)。然后,我创建了默认应用程序来使用 Windows 照片查看器打开 png 图像。安装win32gui:pip install win32gui然后我写了这个似乎有效的脚本:import osimport win32guiimport timeFIRST_PATH = 'C:\\Gale\\Img_test\\left_bottom\\6.png'SECOND_PATH = 'C:\\Gale\\Img_test\\left_top\\1.png'THIRD_PATH = 'C:\\Gale\\Img_test\\right_bottom\\8.png'FOURTH_PATH = 'C:\\Gale\\Img_test\\right_top\\3.png'folder_paths = [FIRST_PATH, SECOND_PATH, THIRD_PATH, FOURTH_PATH]TOP_RIGHT_COORD = [954,0,980,530]TOP_LEFT_COORD = [-10,0,980,530]BOTTOM_RIGHT_COORD = [954,515,980,530]BOTTOM_LEFT_COORD = [-10,515,980,530]def openCharts(paths): for path in paths: os.startfile(path)def enumHandler(hwnd, lParam): if win32gui.IsWindowVisible(hwnd): if '1.png' in win32gui.GetWindowText(hwnd): win32gui.MoveWindow(hwnd, TOP_LEFT_COORD[0], TOP_LEFT_COORD[1], TOP_LEFT_COORD[2],TOP_LEFT_COORD[3], True) elif '3.png' in win32gui.GetWindowText(hwnd): win32gui.MoveWindow(hwnd, TOP_RIGHT_COORD[0], TOP_RIGHT_COORD[1], TOP_RIGHT_COORD[2],TOP_RIGHT_COORD[3], True) elif '6.png' in win32gui.GetWindowText(hwnd): win32gui.MoveWindow(hwnd, BOTTOM_LEFT_COORD[0], BOTTOM_LEFT_COORD[1], BOTTOM_LEFT_COORD[2],BOTTOM_LEFT_COORD[3], True) elif '8.png' in win32gui.GetWindowText(hwnd): win32gui.MoveWindow(hwnd, BOTTOM_RIGHT_COORD[0], BOTTOM_RIGHT_COORD[1], BOTTOM_RIGHT_COORD[2],BOTTOM_RIGHT_COORD[3], True)openCharts(folder_paths)time.sleep(0.5)win32gui.EnumWindows(enumHandler, None)