sst89c51 发表于 2010-9-14 14:03:01

如何用autoit来更改屏幕分辨率,求高人解答!很着急!

如何用autoit来更改屏幕分辨率,求高人解答!很着急!

比如说运行这个脚本,自动把屏幕分辨率从1280*960变成1024*768,有没有方法或者例子,告知下小弟谢谢了!

netegg 发表于 2010-9-14 14:10:41

winapiex里有函数和示例

xsjtxy 发表于 2010-9-14 14:10:42

http://www.autoitx.com/forum.php?mod=viewthread&tid=262&highlight=%B7%D6%B1%E6%C2%CA

yao1377 发表于 2010-9-14 15:57:46

本帖最后由 yao1377 于 2010-9-14 16:00 编辑


$nowWidth = @DesktopWidth
$nowHeight = @DesktopHeight
if $nowWidth <> 1024 and $nowHeight <> 768 then
_ChangeScreenRes(1024,768,@DesktopDepth,@DesktopRefresh)
endif
exit
Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh)
Local Const $DM_PELSWIDTH = 0x00080000
Local Const $DM_PELSHEIGHT = 0x00100000
Local Const $DM_BITSPERPEL = 0x00040000
Local Const $DM_DISPLAYFREQUENCY = 0x00400000
Local Const $CDS_TEST = 0x00000002
Local Const $CDS_UPDATEREGISTRY = 0x00000001
Local Const $DISP_CHANGE_RESTART = 1
Local Const $DISP_CHANGE_SUCCESSFUL = 0
Local Const $HWND_BROADCAST = 0xffff
Local Const $WM_DISPLAYCHANGE = 0x007E
If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting
If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting
If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting
If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting
Local $DEVMODE = DllStructCreate("byte;int;byte;int")
Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE))
If @error Then
$B = 0
SetError(1)
Return $B
Else
$B = $B
EndIf
If $B <> 0 Then
DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
DllStructSetData($DEVMODE, 4, $i_Width, 2)
DllStructSetData($DEVMODE, 4, $i_Height, 3)
DllStructSetData($DEVMODE, 4, $i_BitsPP, 1)
DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5)
$B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST)
If @error Then
   $B = -1
Else
   $B = $B
EndIf
Select
   Case $B = $DISP_CHANGE_RESTART
    $DEVMODE = ""
    Return 2
   Case $B = $DISP_CHANGE_SUCCESSFUL
    DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _
      "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width)
    $DEVMODE = ""
    Return 1
   Case Else
    $DEVMODE = ""
    SetError(1)
    Return $B
EndSelect
EndIf
EndFunc ;==>_ChangeScreenRes

3131806 发表于 2010-9-15 10:35:57

嘿嘿,偶是路过进来学习的,虽然现在用不到,不过做个路标,以后也许会用上,嘿嘿

4216730 发表于 2010-10-8 10:46:04

正好用的上,谢谢三楼四楼的朋友

hnhua 发表于 2011-3-24 14:35:01

谢谢!正需要一个这样的东西

731106 发表于 2011-3-24 21:08:44

不知道是不是还可以改成自己想要的分辨率,保存备用

wei999 发表于 2011-7-29 13:49:52

很好,不错,还能延续

lenovo_fly 发表于 2011-8-2 22:08:24

收藏下。准备试试

雨林GG 发表于 2011-9-6 05:30:11

搜索看到这儿,回贴是美德 !

twomax 发表于 2011-12-18 16:02:16

不錯的文件,值得收藏
页: [1]
查看完整版本: 如何用autoit来更改屏幕分辨率,求高人解答!很着急!