AutoHotkey Community

It is currently May 27th, 2012, 5:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: January 30th, 2007, 6:43 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
BoBo wrote:
@Guest
please use a nick (you don't have to register for it). Thx. 8)


@Bobo
8) Please register for a nick (you don't have to use a real email address for it, try pookmail.com). Thx. 8)


(I like being able to search by author)

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2007, 7:02 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Or mailinator.com 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 5th, 2007, 7:19 pm 
This looks like it might work for me! I find myself needing to write an executible on my bosses desktop that he can click that will switch him between two different resoulutions.

example: if he is on 1280x1024 it will switch him to 1024x768 and viceversa.

Ill look around the fourms in a bit for the right code. maybe I just need to modify this.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2007, 7:32 pm 
Hello,

do anybody know the possebility to change the resolution of the 2nd Display of an Dualview with two Monitors?

I allready uses the search function - but found nothing.

I want to use my PC also to watch vidos over beamer. There I have to switch the resolution down to 1280x720, diable the second Diplay and activate TV-Out in 720p.

Thank you

Holger


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 3:12 am 
Offline

Joined: December 9th, 2007, 11:46 pm
Posts: 19
Could somome please review the code below as I get an error that EncodeInteger is already defined (not surprising) and I'm sure it can be simplified but I'm not sure how. FYI - I'm try to get it to swap refresh rates depending on which of the two progs I am running.

Thanks in advanace!
Nathan

Code:
; --------------------------------------------------------
; JR Media Center 12 TheaterView Integration Script for PowerDVD BluRay / HD-DVD playback
; --------------------------------------------------------

; --------------------------------------------------------
; The following script will (if MC12 is running) Close PMC12, Set Freq 24hz, Run PowerDVD, push mouse off the screen when the "#" button is pressed
; --------------------------------------------------------
#IfWinExist Media Center 
#::
   Run MC12.exe /close
   colorDepth = 32 ; bits (quality) - you can change to suit your requirments
   screenWidth = 1920 ; pixels - you can change to suit your requirments
   screenHeight = 1080 ; pixels - you can change to suit your requirments
   refreshRate = 24 ; Hz (frequency) - you can change to suit your requirments
   ; Don't change anything below!
      struct_devicemode_size = 156
      VarSetCapacity(device_mode, struct_devicemode_size, 0)
      EncodeInteger(struct_devicemode_size, 2, &device_mode, 36)
      success := DllCall("EnumDisplaySettings", "uint", 0, "uint", -1, "uint", &device_mode)
      ; DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY
      EncodeInteger(0x00040000|0x00080000|0x00100000|0x00400000, 4, &device_mode, 40)
      EncodeInteger(colorDepth, 4, &device_mode, 104)
      EncodeInteger(screenWidth, 4, &device_mode, 108)
      EncodeInteger(screenHeight, 4, &device_mode, 112)
      EncodeInteger(refreshRate, 4, &device_mode, 120)
      DllCall("ChangeDisplaySettings", "uint", &device_mode, "uint", 0)
      EncodeInteger( p_value, p_size, p_address, p_offset )
      {
         loop, %p_size%
            DllCall( "RtlFillMemory"
               , "uint", p_address+p_offset+A_Index-1
               , "uint", 1
               , "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
      }
   Run C:\Program Files\CyberLink\PowerDVD\PowerDVD.exe d:
   Mousemove 4000,0
return


; --------------------------------------------------------
; The following script will (if PowerDVD is running) Close PowerDVD, Set Freq back to 50hz, Run MC12 when the MCE "Back" button is pressed
; --------------------------------------------------------
#IfWinExist CyberLink PowerDVD 
Browser_Back::
   WinActivate
   WinClose
   colorDepth = 32 ; bits (quality) - you can change to suit your requirments
   screenWidth = 1920 ; pixels - you can change to suit your requirments
   screenHeight = 1080 ; pixels - you can change to suit your requirments
   refreshRate = 50 ; Hz (frequency) - you can change to suit your requirments
   ; Don't change anything below!
      struct_devicemode_size = 156
      VarSetCapacity(device_mode, struct_devicemode_size, 0)
      EncodeInteger(struct_devicemode_size, 2, &device_mode, 36)
      success := DllCall("EnumDisplaySettings", "uint", 0, "uint", -1, "uint", &device_mode)
      ; DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY
      EncodeInteger(0x00040000|0x00080000|0x00100000|0x00400000, 4, &device_mode, 40)
      EncodeInteger(colorDepth, 4, &device_mode, 104)
      EncodeInteger(screenWidth, 4, &device_mode, 108)
      EncodeInteger(screenHeight, 4, &device_mode, 112)
      EncodeInteger(refreshRate, 4, &device_mode, 120)
      DllCall("ChangeDisplaySettings", "uint", &device_mode, "uint", 0)
      EncodeInteger( p_value, p_size, p_address, p_offset )
      {
         loop, %p_size%
            DllCall( "RtlFillMemory"
               , "uint", p_address+p_offset+A_Index-1
               , "uint", 1
               , "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
      }
   Run C:\Program Files\J River\Media Center 12\Media Center 12.exe
return


; Credit to shimanov for ChangeDisplaySettings.ahk see http://www.autohotkey.com/forum/viewtopic.php?t=8355


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 4:28 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
EncodeInteger() should be replaced with in-built NumPut()!

I hope you can adapt from the following code!

Code:
cD = 32   ; bits (quality) - you can change to suit your requirments
sW = 1440 ; pixels - you can change to suit your requirments
sH = 900  ; pixels - you can change to suit your requirments
rR = 60   ; Hz (frequency) - you can change to suit your requirments

ChangeDisplaySettings( cD, sW, sH, rR )

Return

ChangeDisplaySettings( cD, sW, sH, rR ) {
  VarSetCapacity(dM,156,0), NumPut(156,dM,36)
  DllCall( "EnumDisplaySettings", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)
  NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)
  Return DllCall( "ChangeDisplaySettings", UInt,&dM, UInt,0 )


:)


Last edited by SKAN on February 8th, 2009, 12:11 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 5:14 am 
Offline

Joined: December 9th, 2007, 11:46 pm
Posts: 19
Thanks Skan - looks good and seems to do the trick!
Nathan

Code:
; --------------------------------------------------------
; JR Media Center 12 TheaterView Integration Script for PowerDVD BluRay / HD-DVD playback
; --------------------------------------------------------

; --------------------------------------------------------
; The following script will (if MC12 is running) Close PM12, Set Freq 24hz, Run PowerDVD, push mouse off the screen when the "#" button is pressed
; --------------------------------------------------------
#IfWinExist Media Center 
#::
   cD = 32   ; bits (quality) - you can change to suit your requirments
   sW = 1920 ; pixels - you can change to suit your requirments
   sH = 1080  ; pixels - you can change to suit your requirments
   rR = 24   ; Hz (frequency) - you can change to suit your requirments

   ChangeDisplaySettings( cD, sW, sH, rR )
   Run MC12.exe /close
   Run C:\Program Files\CyberLink\PowerDVD\PowerDVD.exe d:
   Mousemove 4000,0
return

; --------------------------------------------------------
; The following script will (if PowerDVD is running) Close PowerDVD, Set Freq back to 50hz, Run MC12 when the MCE "Back" button is pressed
; --------------------------------------------------------
#IfWinExist CyberLink PowerDVD 
Browser_Back::
   WinActivate
   WinClose

   cD = 32   ; bits (quality) - you can change to suit your requirments
   sW = 1920 ; pixels - you can change to suit your requirments
   sH = 1080  ; pixels - you can change to suit your requirments
   rR = 50   ; Hz (frequency) - you can change to suit your requirments

   ChangeDisplaySettings( cD, sW, sH, rR )
   Run C:\Program Files\J River\Media Center 12\Media Center 12.exe
return


ChangeDisplaySettings( cD, sW, sH, rR ) {
  VarSetCapacity(dM,156,0), NumPut(156,2,&dM,36)
  DllCall( "EnumDisplaySettings", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)
  NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)
  Return DllCall( "ChangeDisplaySettings", UInt,&dM, UInt,0 )


; Credit to shimanov and Skan for the ChangeDisplaySetting code see http://www.autohotkey.com/forum/viewtopic.php?t=8355


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 4:51 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776

      Image


Code:
; Change Display Settings Demo...  by Skan 08-Feb-2009
; Credit: shimanov www.autohotkey.com/forum/viewtopic.php?t=8355
; Caution: This Short script is meant for Demonstration purpose only..
; Applying incompatible settings ( refresh rate in particular ) may damage your hardware.

Gui, +AlwaysOnTop +Owner
Gui, Font, S10, Tahoma
Gui, Add, ComboBox, w200 Simple R10 vEDS gUpdateButton, % EnumDisplaySettings()
Gui, Add, Button, xp+10 y+10] w180 h41 vSetting gChangeSetting
GuiControlGet, EDS
Gui, Show,, %EDS%

UpdateButton:
 GuiControlGet, EDS
 GuiControl,, Setting, Change Display`n%EDS%
Return

ChangeSetting:
 GuiControlGet, EDS
 StringReplace, EDS, EDS, x, % " / "
 Loop, Parse, EDS, /, %A_Space%
  F%A_Index% := RegExReplace( A_LoopField, "[^0-9]" )
 ChangeDisplaySettings( F3, F1, F2, F4 )
 GuiControl,, EDS, % EnumDisplaySettings()
 GuiControlGet, EDS
 Gui, Show,, %EDS%
Return

ChangeDisplaySettings( cD, sW, sH, rR ) {
  VarSetCapacity(dM,156,0), NumPut(156,dM,36)
  DllCall( "EnumDisplaySettings", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)
  NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)
  Return DllCall( "ChangeDisplaySettings", UInt,&dM, UInt,0 )
}

EnumDisplaySettings() {
  VarSetCapacity(DM,156,0), NumPut(156,&DM,36, "UShort")
  ,DllCall( "EnumDisplaySettings", UInt,0, UInt,-1, UInt,&DM )
  ,CS:=NumGet(DM,108) "x" NumGet(DM,112) " / " NumGet(DM,104) "bit / " NumGet(DM,120) "Hz"
 Loop
 If DllCall( "EnumDisplaySettings", UInt,0, UInt,A_Index-1, UInt,&DM )
  EDS:=NumGet(DM,108) "x" NumGet(DM,112) " / " NumGet(DM,104) "bit / " NumGet(DM,120) "Hz"
  ,DS.=(!InStr(DS,EDS) ? "|" EDS : "")
  Else Break
 StringReplace, DS, DS, %CS%|, %CS%||, All
Return SubStr(DS,2)
}

GuiClose:
GuiEscape:
 ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2010, 1:51 pm 
Any ideas why this does not work on Vista
Already ran it as admin and compatibility with xp!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2010, 1:59 pm 
was refering to
Code:
cD = 32   ; bits (quality) - you can change to suit your requirments
sW = 1440 ; pixels - you can change to suit your requirments
sH = 900  ; pixels - you can change to suit your requirments
rR = 60   ; Hz (frequency) - you can change to suit your requirments

ChangeDisplaySettings( cD, sW, sH, rR )

Return

ChangeDisplaySettings( cD, sW, sH, rR ) {
  VarSetCapacity(dM,156,0), NumPut(156,dM,36)
  DllCall( "EnumDisplaySettings", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)
  NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)
  Return DllCall( "ChangeDisplaySettings", UInt,&dM, UInt,0 )
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2010, 4:19 am 
here is some Win7 code related to this older great wrapper posted on this thread frm shimanov. it should be good with Vista since it based on similar principles




...someone may know how to translation each flag ChangeDisplaySettings are just from user32.dll!
note this is a C# wrapup



Code:

using System;
using System.Runtime.InteropServices;


namespace SwitchOrientation
{
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    public struct DEVMODE
    {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
        public string dmDeviceName;

        public short dmSpecVersion;
        public short dmDriverVersion;
        public short dmSize;
        public short dmDriverExtra;
        public int dmFields;
        public int dmPositionX;
        public int dmPositionY;
        public int dmDisplayOrientation;
        public int dmDisplayFixedOutput;
        public short dmColor;
        public short dmDuplex;
        public short dmYResolution;
        public short dmTTOption;
        public short dmCollate;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
        public string dmFormName;

        public short dmLogPixels;
        public short dmBitsPerPel;
        public int dmPelsWidth;
        public int dmPelsHeight;
        public int dmDisplayFlags;
        public int dmDisplayFrequency;
        public int dmICMMethod;
        public int dmICMIntent;
        public int dmMediaType;
        public int dmDitherType;
        public int dmReserved1;
        public int dmReserved2;
        public int dmPanningWidth;
        public int dmPanningHeight;
    };




Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2010, 1:22 pm 
Offline

Joined: January 24th, 2010, 9:41 pm
Posts: 1
How can I tell what resolution settings the user already has?

I want to write code that reads the colour depth if not 16bit then change to 16bit and run a external program, when program is finished change back to 32bit


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2010, 1:34 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Quote:
How can I tell what resolution settings the user already has?


Part code from: http://www.autohotkey.com/forum/viewtop ... 978#164978

Code:
VarSetCapacity(DM,156,0), NumPut(156,&DM,36, "UShort")
DllCall( "EnumDisplaySettings", UInt,0, UInt,-1, UInt,&DM )
CS := NumGet(DM,108) "x" NumGet(DM,112) " / " NumGet(DM,104) "bit / " NumGet(DM,120) "Hz"
MsgBox, 64, Current Display Setting, %CS%


Report this post
Top
 Profile  
Reply with quote  
 Post subject: monitor positions
PostPosted: January 7th, 2011, 10:08 pm 
Can the relative monitor positions be changed using changedisplaysettings on a multiple monitor system ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2011, 9:58 pm 
Offline

Joined: November 20th, 2010, 6:58 am
Posts: 76
Location: Tennessee
Most people in my office have 2 screens. How do I get it to adjust 2 screens?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], Google Feedfetcher and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group