Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get refresh rate #79

Open
nsde opened this issue Apr 6, 2023 · 4 comments
Open

Get refresh rate #79

nsde opened this issue Apr 6, 2023 · 4 comments

Comments

@nsde
Copy link

nsde commented Apr 6, 2023

Hello, could you please implement an attribute called .refresh_rate?
I only managed to get the primary monitor's refresh rate using:

# pip install pywin32
import win32api

device = win32api.EnumDisplayDevices()
settings = win32api.EnumDisplaySettings(device.DeviceName, -1)
hz = settings.DisplayFrequency

print(hz)

I don't know how/if this works on other OSes and with multi-monitor setups.

@Sha-yol
Copy link

Sha-yol commented Aug 23, 2023

+1, could be a really useful addition

@ShaiAvr
Copy link

ShaiAvr commented Sep 25, 2023

+1, couldn't find a cross-platform way to get the monitor's refresh rate.

@Jpdude
Copy link

Jpdude commented Jan 20, 2025

+1 👍
That would be amazing and I wonder why it hasn't been added yet.
In the meantime a workaround would be to just get a list of all monitor modes with Monitor.allModes and usually the last set of modes in the list contain the highest possible refresh rate.

@nsde
Copy link
Author

nsde commented Jan 27, 2025

UPDATE - My own workaround doesn't seem to work now. It returns:

Traceback (most recent call last):
  File "c:\Users\Lynx\Desktop\getprice\a.py", line 5, in <module>
    settings = win32api.EnumDisplaySettings(device.DeviceName, -1)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (126, 'EnumDisplaySettings', 'The specified module could not be found.')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants