Jump to content



Photo

Screen Resolution Changing UDF


  • Please log in to reply
43 replies to this topic

#21 PartyPooper

PartyPooper

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 676 posts

Posted 26 May 2008 - 12:33 PM

Glad you liked it and it works for you.





#22 madflame991

madflame991

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 07 June 2008 - 09:52 AM

PartyPooper hi all wokks but the code will not exit


Same for me... please try to fix it

#23 PartyPooper

PartyPooper

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 676 posts

Posted 10 June 2008 - 12:57 AM

Same for me... please try to fix it


Little more info please like what OS are you using, is it the compiled version that doesn't work or the code itself, which version of AutoIt etc.

#24 Wooltown

Wooltown

    Alpha Geek

  • Active Members
  • PipPipPipPipPipPip
  • 478 posts

Posted 10 June 2008 - 08:15 AM

Works nice on Win 2000 SP 4, English version !

#25 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 17 December 2008 - 03:39 PM

Sorry to resurrect an old post again, but...
Works well on Vista sp1 as well! Nice job.

My only issue is with multiple monitors, it only affects my primary monitor. I looked at the EnumDisplaySettings on msdn and tried to switch the device call so it might also work with my secondary monitor, but no dice. Any ideas how one would go about modifying this to support an additional display device?

Thanks :)

Edited by james3mg, 17 December 2008 - 03:42 PM.

Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#26 PartyPooper

PartyPooper

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 676 posts

Posted 18 December 2008 - 01:03 PM

Not off the top of my head but I know there are several topics on multiple monitors on here that may be useful. Unfortunately, I don't run multiple monitors at the moment.

#27 DangerousDan

DangerousDan

    Seeker

  • Active Members
  • 44 posts

Posted 18 January 2009 - 10:38 PM

Same for me... please try to fix it

in response to the script not exiting/remaining in system tray.

comment out lines 62 and 63
;~              DllCall($dll, "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ ;~                      "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width)


that's what was making the function hang for me on Vista SP1.



on another note: for some reason Vista constantly resets my screen res to 1024x768 after it resumes from suspend mode... I wrote a script to keep in the quick launch bar until I can figure it out lol.

#28 PsaltyDS

PsaltyDS

    Most Venerable Penguin

  • MVPs
  • 13,279 posts

Posted 27 January 2009 - 08:11 PM

A modification using ChangeDisplaySettingsEx, so that specific display instances can be targeted:

From bobchernow in Multiple monitor change resolution:

OK, Here goes. This is my first UDF so be gentle.

Plain Text         
#include-once ;=============================================================================== ; Function Name:    _ChangeScreenResEx() ; Description:    Changes the current screen geometry, colour and refresh rate. ; Version:        1.0.0.0 ; Parameter(s):  $i_DisplayNum - Display to change, starting at 1 ;                  $i_Width - Width of the desktop screen in pixels. (horizontal resolution) ;                  $i_Height - Height of the desktop screen in pixels. (vertical resolution) ;                   $i_BitsPP - Depth of the desktop screen in bits per pixel. ;                   $i_RefreshRate - Refresh rate of the desktop screen in hertz. ; Requirement(s):   AutoIt Beta > 3.1 ; Return Value(s):  On Success - Screen is adjusted, @ERROR = 0 ;                  On Failure - sets @ERROR = 1 ; Forum(s):       ; Author(s):        Original code - psandu.ro, PartyPooper ;                  Modifications - bobchernow ;=============================================================================== Func _ChangeScreenResEx($i_DisplayNum = 1, $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[32];int[10];byte[32];int[6]")     Local $s_Display         $s_Display = "\\.\Display" & $i_DisplayNum         Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "int", 0, "ptr", DllStructGetPtr($DEVMODE))         If @error Then         $B = 0         SetError(1)         Return $B     Else         $B = $B[0]     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", "ChangeDisplaySettingsEx","str", $s_Display, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "dword", $CDS_TEST, "lparam", 0)         If @error Then             $B = -1         Else             $B = $B[0]         EndIf         Select             Case $B = $DISP_CHANGE_RESTART                 $DEVMODE = ""                 Return 2             Case $B = $DISP_CHANGE_SUCCESSFUL                 DllCall("user32.dll", "int", "ChangeDisplaySettingsEx","str", $s_Display, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "dword", $CDS_UPDATEREGISTRY, "lparam", 0)                 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;==>_ChangeScreenResEx

And here is what I have been using to test it.

#include <ChangeResolutionEx.au3> _ChangeScreenResEx(1,1024,600,-1,-1) _ChangeScreenResEx(2,1680,1050,-1,-1)

I am still struggling with the DetachMonitorEx.Au3 UDF but I hope to get that working soon. It seems to involve mucking with the $DEVMODE flags and then calling the ChangeDisplaySettingsEx twice, but it is not working as of now.

Bob

:)
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

#29 WorknMan

WorknMan

    Seeker

  • Active Members
  • 37 posts

Posted 29 January 2009 - 12:41 AM

Hey guys,

I can use this au3 file to change to any resolution I've tried except for 1152x864. If I try it, I get the error that says can't change resolution - check parameters.

I can switch to this resolution via the Display properties (Winxp SP3), so not sure why it doesn't work in the script? Is there something hard-coded in the au3 file to only allow certain resolutions?

EDIT: n/m, works on another PC, so it's obviously something specific with the monitor.

Edited by WorknMan, 29 January 2009 - 07:24 PM.


#30 bobchernow

bobchernow

    Seeker

  • Active Members
  • 42 posts

Posted 07 February 2009 - 04:45 AM

Hey guys,

I can use this au3 file to change to any resolution I've tried except for 1152x864. If I try it, I get the error that says can't change resolution - check parameters.

I can switch to this resolution via the Display properties (Winxp SP3), so not sure why it doesn't work in the script? Is there something hard-coded in the au3 file to only allow certain resolutions?

EDIT: n/m, works on another PC, so it's obviously something specific with the monitor.


Are you working on a single monitor or on multiple monitor system?
--------------------bobchernow, Bob ChernowWhat a long strange trip it's beenUDFs: Multiple Monitor Screen Resolution Change

#31 maison09

maison09

    Seeker

  • New Members
  • 1 posts

Posted 18 April 2009 - 12:44 AM

Thanks a lot for your sharing ^_^

maison de credit


Edited by maison09, 18 April 2009 - 12:44 AM.


#32 catcat

catcat

    Seeker

  • New Members
  • 1 posts

Posted 24 April 2009 - 09:34 AM

I am a new commer, I want to have more information

simulation assurance vie



#33 jaenster

jaenster

    There is no spoon.

  • Active Members
  • PipPipPipPipPipPip
  • 670 posts

Posted 27 June 2009 - 04:33 PM

here it dont work, Dont care witch res i set.

(Win XP PRO SP3)
-jaenster

#34 AlienStar

AlienStar

    Wayfarer

  • Active Members
  • Pip
  • 95 posts

Posted 11 August 2009 - 07:58 PM

hello everybody

how can add a condition for this script ????

I mean :

if ( width <= 800 ^ Height <= 600 ) change to 1024x768 and even if one of them ( width or height ) was <= last value also change to 1024x768

I mean I wanna the width > 800 and the height > 600

but if the resolution was bigger than 800x600 for example (1152x864) don't do any thing

thanks so much

Edited by AlienStar, 11 August 2009 - 08:01 PM.


#35 PartyPooper

PartyPooper

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 676 posts

Posted 12 August 2009 - 07:15 AM

Have a read about @DesktopHeight and @DesktopWidth in the help file.

#36 TheGeneral

TheGeneral

    Seeker

  • Active Members
  • 34 posts

Posted 13 August 2009 - 03:02 AM

How can i change a monitor to primary, through dll call?
There's any possibility to change the default sound output through the same method?

#37 pitchalov

pitchalov

    Seeker

  • New Members
  • 1 posts

Posted 26 November 2010 - 09:46 AM

Inspired by original thread. All credit should go to psandu.ro, I just converted his code into a UDF and modified it slightly.


Hi,

I am new to this forum and AutoIt in general. I discovered this old post and this could be interesting for me, but i can't manage to find the "ChangeResolution.au3" file to test it (it is not in the AutoIt standard library, isn't it?).
Could someone tell me how to download it?

PS. I am using the version v3.3.6.1 of AutoIt
Thanks in Advance for the answers.

#38 E1M1

E1M1

    Newbie

  • Active Members
  • PipPipPipPipPipPip
  • 1,073 posts

Posted 26 November 2010 - 04:00 PM

PsaltyDS posted it, just copy code and save it as au3 file.
edited

#39 Esquared

Esquared

    Seeker

  • Active Members
  • 23 posts

Posted 06 December 2010 - 08:11 PM

PsaltyDS posted it, just copy code and save it as au3 file.


I'm really new to Scripting and AutoIt and am having a lot of trouble with this. All I want to do is change a users screen resolution. I copied PsaltyDS's code and saved it as "ChangeResolution.au3" in the include folder in AutoIt. I've tried running the following code:

#include <ChangeResolution.au3>

$iWidth = 1024
$iHeight = 768
$iBitsPP = 32
$iRefreshRate = 60

$vRes = _ChangeScreenRes($iWidth, $iHeight, $iBitsPP, $iRefreshRate)
If @error Then
MsgBox(262160, "ERROR", "Unable to change screen - check parameters")
EndIf


And all I get is the following error:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\<username>\Desktop\AutoIt3\Scripts\resolution test.au3"
C:\Users\<username>\Desktop\AutoIt3\Scripts\resolution test.au3 (8) : ==> Unknown function name.:
$vRes = _ChangeScreenRes($iWidth, $iHeight, $iBitsPP, $iRefreshRate)
$vRes = ^ ERROR
>Exit code: 1 Time: 0.244


I've been through tons of posts and I'm pretty frustrated, I didn't thing changing the screen resolution would be so complicated...

Any help would be appreciated!!!

Thanks

#40 PartyPooper

PartyPooper

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 676 posts

Posted 09 December 2010 - 12:27 AM

Check that the SciTE config User Include Dir is pointing to the folder where you stored ChangeResolution.au3




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users