0

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
JDS
  • 16,388
  • 47
  • 161
  • 224
  • 1
    is this even possible in Windows? Do you know any other program which can do this? – furas Feb 20 '20 at 21:53
  • 1
    See https://stackoverflow.com/questions/20838201/resize-display-resolution-using-python-with-cross-platform-support – Demian Wolf Feb 20 '20 at 21:56
  • 1
    1. Can you change the resolution? Yes. You can use `winreg` to find the registry for your resolution and change that. 2. Can you offset it? I don't know but I doubt it. I don't think Windows will let you just have a black space. You could have a program that displays the normal resolution with the custom resolution inside of it, similar to VNC viewer or something like that. 3. Can you distort it? With windows, no. You would have to capture the screen output and run it through a distortion algorithm and then display that (similar to point 2). – Chrispresso Feb 20 '20 at 21:57

1 Answers1

1

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

Buzby
  • 345
  • 1
  • 11