Skip to content

Manipulate scaling percentage per resolution #69

Open

Description

@ody

I often find myself wishing I could have Windows select a specific scaling factor based on resolution. When setting desktop resolution to 2560×1440 to play games sitting at my desk I prefer 100% but when I am connected via my Steam Deck at 2560x1600, I prefer 175% and 4k connected via my 55” TV, 200%.

Could you please add some mechanism for defining a resolution to scaling factor relationship?

Activity

  1. Nonary commented on Jun 7, 2024

    @Nonary
    Owner

    Unfortunately there isn’t a Windows API call I am aware about that allows adjusting the monitor DPI setting. The only one I’ve found was essentially a reverse engineered call. If you happen to know the proper API calls for it I can implement it, otherwise I’d suggest getting a dummy plug and having the dummy plug set at 200%

  2. ody commented on Jun 7, 2024

    @ody
    Author

    That is a bummer. The request was so I could manipulate the scaling factor of my dummy plug. When I mentioned being at my desktop I am streaming to my Mac. My Windows PC is a headless dedicated streaming machine. I’ll keep my eye out for a proper API

  3. CrazyCoder commented on Jun 7, 2024

    @CrazyCoder

    There is a fork that seems to adjust scaling: main...danielmartina:ResolutionAutomation-custom:main.

  4. ody commented on Jun 7, 2024

    @ody
    Author

    The parameter utilized, 0x009F is documented by Microsoft as “do not use”

    https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa

  5. ody commented on Jun 7, 2024

    @ody
    Author

    Also getting the vibe this is steps above recommended, which would mean I’d need a negative number at 1440p and that isn’t possible

  6. Nonary commented on Jun 8, 2024

    @Nonary
    Owner

    I tried that API call earlier and it completely broke my DPI scale dropdown. I couldn't pick a setting anymore and was forced to use custom scaling. Had to do a system restore to fix it again

  7. ody commented on Jun 8, 2024

    @ody
    Author

    I was poking around at this again this morning and thought maybe looking for an API which applies a scaling factor is incorrect.

    If you run something like this...you get the virtual resolution of the desktop after the chosen scaling factor has been applied.

    [System.Windows.Forms.Screen]::AllScreens
    

    I wonder though if when you select the factor through Display Settings it isn't actually setting a percentage anywhere, it is just taking the desired frame buffer resolution, applying a reverse percentage (so 4k becomes 1920x1080 at 200%), then setting the virtual desktop size to that resolution. I saw a similar thing when working with Special-K, if it was made DPI aware it would report my resolution as a fraction of what I had set the actual display resolution to.

    Looking more through what's available from user32.dll though, I couldn't find anything which obviously provided a way to set that virtual desktop resolution. I am new to Windows API stuff so maybe I am not seeing it or not looking in the right place...

  8. nooblikejagger commented on Jun 12, 2024

    @nooblikejagger

    I have the same need, looking forward to the update.

  9. vaughngx4 commented on Oct 25, 2024

    @vaughngx4

    I have a workaround for now. Using this executable, drop SetDPI.exe in the ResolutionAutomation folder and modify Events.ps1.

    At the end of the OnStreamStart function I have:

    if ($env:SUNSHINE_CLIENT_HEIGHT -gt 1079) {
        .\SetDPI.exe 125
    }
    

    At the end of the OnStreamEnd function I have:

    .\SetDPI.exe 100
    

    So that anything 1080p or higher will get a 125% scaling. You can adjust this to your liking.

    EDIT 1: Fixed code error
    EDIT 2: Updated for v3.1

  10. Boppyman commented on Apr 18, 2025

    @Boppyman

    I have a workaround for now. Using this executable, drop SetDPI.exe in the ResolutionAutomation folder and modify Events.ps1.

    At the end of the OnStreamStart function I have:

    if ($env:SUNSHINE_CLIENT_HEIGHT -gt 1079) {
        .\SetDPI.exe 125
    }
    

    At the end of the OnStreamEnd function I have:

    .\SetDPI.exe 100
    

    So that anything 1080p or higher will get a 125% scaling. You can adjust this to your liking.

    EDIT 1: Fixed code error EDIT 2: Updated for v3.1

    Just what I need this but I can't seem to get this to work for 3.1.2.

    In the OnStreamStart should the bottom look like this?

        Set-ScreenResolution -Width $expectedRes.Width -Height $expectedRes.Height -Freq $expectedRes.Refresh
        Assert-ResolutionChange -width $expectedRes.Width -height $expectedRes.Height -refresh $expectedRes.Refresh
    
    if ($env:SUNSHINE_CLIENT_HEIGHT -gt 1079) {
        .\SetDPI.exe 125
    }
    

    Same for the OnStreamEnd

    Is that just

        Set-ScreenResolution -Width $originalResolution.Width -Height $originalResolution.Height -Freq $originalResolution.Refresh   
        Write-Debug "Screen resolution set to: $($originalResolution.Width) x $($originalResolution.Height) x $($originalResolution.Refresh)"
    
        return $true
    }
    
    .\SetDPI.exe 100
    

    So there is no curly brace after?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions