-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-ScreenScale.ps1
More file actions
28 lines (22 loc) · 882 Bytes
/
Set-ScreenScale.ps1
File metadata and controls
28 lines (22 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[CmdletBinding()]
param (
[Parameter(Mandatory=$false)]
[int]$scaling = 0,
[Parameter(Mandatory=$false)]
[int]$screenNum = 1
)
function Set-ScreenScale {
$typeName = "SystemParamInfo.WinAPICall"
$type = [System.Reflection.Assembly]::GetExecutingAssembly().GetType($typeName)
if ($type) {
Remove-TypeDefinition $typeName
}
$source = @"
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
"@
$apicall = Add-Type -MemberDefinition $source -Name WinAPICall -Namespace SystemParamInfo -PassThru
$apicall::SystemParametersInfo(0x009F, $scaling, [int]$screenNum, 1) | Out-Null
Write-Host "Screen scale set to $scaling for screen $screenNum"
}
Set-ScreenScale -scaling $scaling -screenNum $screenNum