; 获取监视器1的分辨率
MsgBox % ScreenResolution_Get("\\.\DISPLAY1")

; 获取监视器1所有屏幕分辨率的有效匹配列表
MsgBox % ScreenResolution_List("\\.\DISPLAY1")

; 修改监视器1的分辨率
;MsgBox % ScreenResolution_Set("1280x720@60", "\\.\DISPLAY1")

; 这样写可检测监视器2是否存在,返回0为存在并启动,返回-1为存在但没启用,返回-2为监视器不存在
MsgBox % ScreenResolution_Set("", "\\.\DISPLAY2")

; DualMID()列出多个显示器名字
; https://www.autohotkey.com/boards/viewtopic.php?p=337650#p337650


/*
; https://baijiahao.baidu.com/s?id=1747660284751204306&wfr=spider&for=pc
; 声音 - 录制 页面
Run %A_WinDir%\System32\rundll32.exe shell32.dll`,Control_RunDLL mmsys.cpl`,`,1

设置 - 显示 - 分辨率
Run %A_WinDir%\System32\rundll32.exe shell32.dll`,Control_RunDLL desk.cpl
*/

ScreenResolution_Get(Disp:=0) {        ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution
  Local DM, N:=VarSetCapacity(DM,220,0) 
  Return DllCall("EnumDisplaySettingsW", (Disp=0 ? "Ptr" : "WStr"),Disp, "Int",-1, "Ptr",&DM)=0 ? ""
     : Format("{:}x{:}@{:}", NumGet(DM,172,"UInt"),NumGet(DM,176,"UInt"),NumGet(DM,184,"UInt")) 
}

ScreenResolution_List(Disp:=0) {       ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution
  Local DM, N:=VarSetCapacity(DM,220,0), L:="", DL:=","
  While DllCall("EnumDisplaySettingsW", (Disp=0 ? "Ptr" : "WStr"),Disp, "Int",A_Index-1, "Ptr",&DM)
    If ( NumGet(DM,168,"UInt")=32 && NumGet(DM,184,"UInt")>59)
      L.=Format("{:}x{:}@{:}" . DL, NumGet(DM,172,"UInt"),NumGet(DM,176,"UInt"),NumGet(DM,184,"UInt")) 
  Return RTrim(L,DL) 
}

ScreenResolution_Set(WxHaF, Disp:=0) {     ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution
  Local DM, N:=VarSetCapacity(DM,220,0), F:=StrSplit(WxHaF,["x","@"],A_Space)
  Return DllCall("ChangeDisplaySettingsExW",(Disp=0 ? "Ptr" : "WStr"),Disp, "Ptr",NumPut(F[3]
     , NumPut(F[2], NumPut(F[1], NumPut(32, NumPut(0x5C0000, NumPut(220,DM,68,"UShort")+2,"UInt")+92
     , "UInt"),"UInt"),"UInt")+4,"UInt")-188, "Ptr",0, "Int",0, "Int",0)  
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。