windows-images icon indicating copy to clipboard operation
windows-images copied to clipboard

windows starts 1024x768 resolution even SCREEN_RESOLUTION changed to 1920x1080x24

Open toni-moreno opened this issue 4 years ago • 8 comments

Related also with https://github.com/aerokube/windows-images/issues/25

As you can see in this video . ( wait 20 seconds , to see vm running)

VIDEO

The container (X11) screen resolution is 1920x1080 but windows qemu vm is started at 1024x768.

There is any way to sync VM resolution with container Resolution ?

toni-moreno avatar Nov 24 '19 09:11 toni-moreno

Unfortunately resolution is windows setup and not qemu parameter...

вс, 24 нояб. 2019 г., 12:58 Toni Moreno [email protected]:

Related also with #25 https://github.com/aerokube/windows-images/issues/25

As you can see in this video .

VIDEO https://drive.google.com/file/d/11sPQYxd2xXJC8TaQi1BYeMwJqmZE_GA5/view?usp=sharing

The container (X11) screen resolution is 1920x1080 but windows qemu vm is started at 1024x768.

There is any way to sync VM resolution with container Resolution ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aerokube/windows-images/issues/26?email_source=notifications&email_token=AAKY23MHKYMXIP4CIVPYUNDQVJF3HA5CNFSM4JQ6J5EKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H3TVV2A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKY23JACJSA4RK6ZJG5X2TQVJF3HANCNFSM4JQ6J5EA .

aandryashin avatar Nov 24 '19 10:11 aandryashin

@toni-moreno I solved this issue by setting the screen resolution higher before saving the snapshot. I installed the video driver that comes in the same package as the network card. I end up setting the screen resolution to 4K so that I don't need to keep resizing if the needs changes. The last thing I did was pass the screen resolution to the container so that I can see the whole windows screen.

My broswers.json looks like this:

    "internet explorer": {
        "default": "11.0",
        "versions": {
            "11.0": {
                "image": "nexus.internal.com:8443/docker/windows:browsers",
                "port": "4444",
                "path": "/",
                "privileged": true,
                "env": ["SCREEN_RESOLUTION=3200x2450x24"]
            }
        }
    },
    "MicrosoftEdge": {
        "default": "18.0",
        "versions": {
            "18.0": {
                "image": "nexus.internal.com:8443/docker/windows:browsers",
                "port": "5555",
                "path": "/",
                "privileged": true,
                "env": ["SCREEN_RESOLUTION=3200x2450x24"]
            }
        }
    },

The windows VM inside the container looks like this:

windows-selenoid

emilorol avatar Dec 02 '19 15:12 emilorol

There is even no command in Windows to set screen resolution.

vania-pooh avatar Dec 02 '19 16:12 vania-pooh

@vania-pooh you are correct, there is no command you can pass that will change windows resolution on the fly, that's why I am suggesting to change the windows resolution before saving the snapshot and then adjust the VNC viewer resolution to see all of your screen as need it.

emilorol avatar Dec 02 '19 21:12 emilorol

@emilorol yes, this seems to be the only possible solution right now.

vania-pooh avatar Dec 03 '19 04:12 vania-pooh

I found this tool nircmd http://www.nirsoft.net/utils/nircmd.html In Windows, it can change the resolution setting through the command line. Like this:

> nircmd.exe setdisplay 1920 1080 32 But I don't know how to let qmeu call it with the specified parameters when it starts.

t880216t avatar Sep 26 '22 08:09 t880216t

@t880216t should be called during Windows startup. No way to call in qemu.

vania-pooh avatar Sep 26 '22 08:09 vania-pooh

@t880216t should be called during Windows startup. No way to call in qemu.

I found temporary methods that can be solved dynamically.

  1. Start a flask server to receive dynamic setting parameters.
  2. Call the win32api library to set the resolution of Windows

Use it like this after the sessionin starts:

driver.get('http://127.0.0.1:5000/setDisplay?width=1920&height=1080')
driver.get('https://www.google.com')

This is a short flash server: Dependent libraries:

# requirements.txt
click==8.1.3
colorama==0.4.5
Flask==2.2.2
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
pywin32==304
Werkzeug==2.2.2

Source code:

# run.py
from flask import Flask
from flask import request
from flask import jsonify
import win32api

app = Flask(__name__)

def setScreen(width, height):
    dm = win32api.EnumDisplaySettings(None, 0)
    dm.PelsWidth = int(width)
    dm.PelsHeight = int(height)
    dm.BitsPerPel = 32
    dm.DisplayFixedOutput = 0
    win32api.ChangeDisplaySettings(dm, 0)

@app.route('/setDisplay', methods=['GET'])
def index():
    height = request.args.get('height')
    width = request.args.get('width')
    setScreen(width, height)

    return jsonify({'width': width, 'height': height})

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000)

Keep the service running like as the browser webdriver server.

python run.py

t880216t avatar Sep 28 '22 14:09 t880216t