'Can you change screen resolution in nvidia control panel through a script in e.g. python?

I'm trying to write a program that automatically changes the resolution of the screen when it sees that a particular app is running on my computer (so it's easier to alt-tab when the res of a game is different than the native res of the screen). So my question is, is that even possible, and if it is, how should I even start writing the code itself?



Solution 1:[1]

From everything that I can find, no, it isn't possible to change your resolution through NVIDIA stuff whatsoever. A Reddit post I found suggests maybe possible use with NVAPI, the API for NVIDIA GPUs, but that it's not recommended.

The same Reddit thread proposes it may be easier to instead use PyWin32 to change display resolution instead, and even links to another StackOverflow question that shows a possible implementation of it.

However, I wouldn't necessarily recommend messing with that, personally. Windows should automatically change the resolution for you based on the program you're running -- especially in games that don't run natively at higher resolutions but request full screen, like those from the early 2000s.

Running a script -- and one that would have to run continuously in the background at that, eating up resources and potentially causing memory leaks if implemented wrong -- could cause problems with settings and may even render your display useless if done incorrectly, and since there's no CLI method in Windows to change your resolution in the event it gets screwed up, I don't even know where I would start to fix a problem like that.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 simbyte