Skip to content

Instantly share code, notes, and snippets.

@oflow
Last active December 27, 2016 07:37
Show Gist options
  • Save oflow/36ddb876a9c0ff078980bfa61c70cd8f to your computer and use it in GitHub Desktop.
Save oflow/36ddb876a9c0ff078980bfa61c70cd8f to your computer and use it in GitHub Desktop.
change display resolution & refresh rate toggle script
Option Explicit
Dim wsh, ret, vc, lnk
Dim width, height, dcNum
Dim dcPath, dcOpt, lnkPath, lnkDesc, icoPath, id
' dccmd.exe : http://12noon.com/?page_id=80
' dccmd.exe -listmonitors
' change monitor 1 (= \\.\DISPLAY1, = VideoController1)
dcPath = "D:\apps\dc64cmd.exe"
dcNum = 1
lnkPath = "D:\Display Toggle.lnk"
' get display[dcNum] width & height
Set ret = WScript.CreateObject("WbemScripting.SWbemLocator") _
.ConnectServer.ExecQuery("Select * From Win32_VideoController Where DeviceID = 'VideoController" & dcNum & "'")
For Each vc In ret
width = vc.CurrentHorizontalResolution
height = vc.CurrentVerticalResolution
' WScript.Echo(vc.DeviceID & ": " & vbCrLf & vc.Name & vbCrLf & _
' width & "x" & height & " " & vc.CurrentRefreshRate & "Hz")
Next
' set option
If width = 1920 And height = 1080 Then
' 1440x900 60Hz
dcOpt = "-width=1440 -height=900 -refresh=60"
lnkDesc = "1440 -> 1920"
icoPath = "D:\icons\dc-1440.ico"
Else
' 1920x1080 144Hz
dcOpt = "-width=1920 -height=1080 -refresh=144"
lnkDesc = "1920 -> 1440"
icoPath = "D:\icons\dc-1920.ico"
End If
Set wsh = WScript.CreateObject("WScript.Shell")
' set lnk icon
Set lnk = wsh.CreateShortcut(lnkPath)
lnk.Description = lnkDesc
lnk.IconLocation = icoPath
lnk.Save
' run dc64cmd
wsh.Run """" & dcPath & """ -monitor=""\\.\DISPLAY" & dcNum & """ " & dcOpt, 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment