JDS
JDS

Reputation: 17008

Python background program to modify Windows screen resolution, shape?

I'm looking to make a Python program, that while running in the background (e.g. started through command line), will change the screen resolution of Windows (and shift the screen position). And then the user is free to continue to use their computer in this different resolution.

E.g.: (fake code below)

import os
os.changeResolution(800,600)        
# the entire windows desktop resolution changes to a (800,600) box, with black/empty around it

os.changeScreenPosition(100,200)    
# shifts the (800,600) window of the desktop to position (100,200)

while 1:
    # do nothing, just keep the screen like we set it above while this little python program is running somewhere
    continue

Picture below showing before/after:

enter image description here

after:

enter image description here

(screen is shrunk to new resolution, position is offset, background surrounding is black)

Now while this program is running minimized somewhere the user can go about their other desktop tasks. Is this possible with Python and Windows 10?

As a follow-up, what if I wanted to change the shape, from say a rectangular box, to a circle? E.g. to distort / bulge the screen.

Upvotes: 0

Views: 557

Answers (1)

Buzby
Buzby

Reputation: 355

Resizing the window will only make it fill your monitor at a lower resolution. You can mess about with the magnify function to make it larger or live copy an area at the same resolution. You can use thumbnails (the way windows 10 shows a preview when you hover over a window in the task bar) to make it look smaller, but it won't pass control to a smaller window. Both are by the DWM (Desktop Window Manager) and don't let you intervene with the image short of adjusting the colour (magnify can tint the window or make it black and white)

Distorting to a round window is a whole can of worms. There are a few options explored in my old post below. I've still to give it a go, when I get some time, but think I'll be going down the route of trying to hook into DWM.

Realtime video processing for the complete Windows desktop

Upvotes: 1

Related Questions