aerokube / windows-images

Step by step instructions for building Docker images with Windows
Apache License 2.0
221 stars 44 forks source link

windows starts 1024x768 resolution even SCREEN_RESOLUTION changed to 1920x1080x24 #26

Open toni-moreno opened 5 years ago

toni-moreno commented 5 years ago

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 ?

aandryashin commented 5 years ago

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

вс, 24 нояб. 2019 г., 12:58 Toni Moreno notifications@github.com:

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 .

emilorol commented 4 years ago

@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

vania-pooh commented 4 years ago

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

emilorol commented 4 years ago

@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.

vania-pooh commented 4 years ago

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

t880216t commented 2 years ago

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.

vania-pooh commented 2 years ago

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

t880216t commented 2 years ago

@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