r/PowerShell • u/Wise_Scientist_3963 • Mar 12 '26
Question Noob Q
Hi good people of the powershell sub!
I have a problem that I thought could be solved with PS.
My display sometimes changes the refresh rate, while i'm playing games for example. When this happens, 3/4 of my display goes either black or fuzzy. I then have to go to desktop, right click to get to display settings -> adv. displ. settings and there change the refresh rate back to 60 and then my display is fine. The problem is, sometimes there is not enough space of display to actually be able to reach what I have to click and so I need to restart with power button.
I include a picture of the settings screen that i change. Now, is it possible to change this setting in PS and can someone help me mb with a script, or point me in a direction?
I would be so grateful if sosmeone could help me, I don't have the money to get a new display unfortunately.
Thank y'all so much in advance
-LiNX
Oh right, my system is win 10 64.
5
u/aleques-itj Mar 12 '26
It can be done, but you will probably need to call the Win32 API.
You will need to PInvoke a few functions. At a glance, this looks like a good starting point.
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumdisplaysettingsa
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsexa
3
u/BetrayedMilk Mar 12 '26
It feels like it'd be worth the time trying to understand why this is happening in the first place and fixing that problem instead. There's no native powershell way to do this, you'd have to call into win32.
1
u/The-Snarky-One Mar 12 '26
I’d look into the underlying reason why this is happening.
If it’s only during games, or something with heavy load, you might want to replace your video cable. You may also want to see if there is a firmware update for your GPU and/or monitor itself. Are you using the latest drivers? Is your PSU properly rated for your GPU?
If your monitor has a 60Hz refresh rate and it downgrades to a lower rate, you may want to turn on VSYNC or whatever it’s called now in the game. That will sync your video card frame rate to your monitor refresh rate.
If you really want to try and script something, you can give this a try:
https://www.powershellgallery.com/packages/PSWinUtil/1.5.8/Content/functions/Set-Monitor.ps1
2
u/NotNotWrongUsually Mar 12 '26
Have you tinkered with display driver settings?
E.g., Nvidia Control Panel has an option for preferred refresh rate that can either be "highest available" or "application controlled".
Edit: and in Windows 11 I can see that there is something called "Dynamic refresh rate" that can switch your refresh rate to save power. Probably want that set to "off" if it isn't already.
2
u/GisseGisseGiss Mar 12 '26
Try nircmd and setdisplay by Nirsoft. Quick and easy set resolution, color and refresh rate.
https://nircmd.nirsoft.net/setdisplay.html
The just create a shortcut to the full command/a script with it and just pin it somewhere useful.