 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Tue Jan 30, 2007 5:43 pm Post subject: |
|
|
| BoBo wrote: | @Guest
please use a nick (you don't have to register for it). Thx.  |
@Bobo
Please register for a nick (you don't have to use a real email address for it, try pookmail.com). Thx.
(I like being able to search by author) _________________
(Common Answers) |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 2951 Location: Minnesota
|
Posted: Tue Jan 30, 2007 6:02 pm Post subject: |
|
|
Or mailinator.com  |
|
| Back to top |
|
 |
fishfilet Guest
|
Posted: Mon Feb 05, 2007 6:19 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
HoPe Guest
|
Posted: Tue Oct 23, 2007 6:32 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
jmone
Joined: 09 Dec 2007 Posts: 19
|
Posted: Mon Dec 10, 2007 2:12 am Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Dec 10, 2007 3:28 am Post subject: |
|
|
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 Sun Feb 08, 2009 11:11 am; edited 1 time in total |
|
| Back to top |
|
 |
jmone
Joined: 09 Dec 2007 Posts: 19
|
Posted: Mon Dec 10, 2007 4:14 am Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Dec 10, 2007 3:51 pm Post subject: |
|
|
| 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 |
|
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jan 12, 2010 12:51 pm Post subject: |
|
|
Any ideas why this does not work on Vista
Already ran it as admin and compatibility with xp! |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jan 12, 2010 12:59 pm Post subject: |
|
|
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 )
} |
|
|
| Back to top |
|
 |
GwHL Guest
|
Posted: Wed Feb 10, 2010 3:19 am Post subject: |
|
|
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;
};
|
|
|
| Back to top |
|
 |
arcanine
Joined: 24 Jan 2010 Posts: 1
|
Posted: Sat Apr 24, 2010 12:22 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Apr 26, 2010 12:34 am Post subject: |
|
|
| Quote: | | How can I tell what resolution settings the user already has? |
Part code from: http://www.autohotkey.com/forum/viewtopic.php?p=164978#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% |
|
|
| Back to top |
|
 |
tinku99_guest Guest
|
Posted: Fri Jan 07, 2011 9:08 pm Post subject: monitor positions |
|
|
| Can the relative monitor positions be changed using changedisplaysettings on a multiple monitor system ? |
|
| Back to top |
|
 |
tcnt9176
Joined: 20 Nov 2010 Posts: 76 Location: Tennessee
|
Posted: Fri May 06, 2011 8:58 pm Post subject: |
|
|
| Most people in my office have 2 screens. How do I get it to adjust 2 screens? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|