图形窗口和用户输入

2024-09-27 21:29:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码是特定于屏幕分辨率的,所以我需要让脚本根据用户的分辨率进行操作。你知道吗

我试过:

from win32api import GetSystemMetrics

print("Width =", GetSystemMetrics(0))
print("Height =", GetSystemMetrics(1))

以及pip安装pypiwin32来让这个^代码工作,但它没有

我当前的代码迭代如下所示:

resolution = input ("What resolution is your monitor?")
print (resolution)

if resolution == "1440":

但是,这会干扰全屏命令:

import ctypes
user32 = ctypes.WinDLL('user32')
SW_MAXIMISE = 3
hWnd = user32.GetForegroundWindow()
user32.ShowWindow(hWnd, SW_MAXIMISE)

用户输入“1440”后,窗口开始最小化,如何在输入后使窗口开始最大化。窗口在没有输入提示的情况下运行良好,顺便说一句,这就是我知道问题所在的原因。你知道吗


Tags: 代码用户fromimport脚本屏幕分辨率sw

热门问题