AutoHotkey Community

It is currently May 27th, 2012, 1:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 71 posts ]  Go to page Previous  1, 2, 3, 4, 5
Author Message
 Post subject:
PostPosted: December 2nd, 2009, 1:03 am 
Offline

Joined: November 22nd, 2009, 6:15 pm
Posts: 6
I don't know what it does.

_________________
System: Windows 7 64 Bit, 8GB Ram, GTX 260, Raptor Raid


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 15th, 2010, 6:42 pm 
Offline

Joined: March 29th, 2006, 12:28 am
Posts: 17
Nice! @ socd.

Here are all the switches, if needed:

Projector only
displayswitch /external

Monitor only
displayswitch /internal

Project and monitor both
displayswitch /extend

Monitor cloned
displayswitch /clone

_________________
Vitaly


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2010, 3:44 am 
Offline

Joined: November 22nd, 2009, 6:15 pm
Posts: 6
Thanks.

_________________
System: Windows 7 64 Bit, 8GB Ram, GTX 260, Raptor Raid


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 1:39 am 
Offline

Joined: March 10th, 2010, 1:34 am
Posts: 2
When I plug in my external monitor, it automatically takes the "\\.\DISPLAY1" name away from my laptop. and sets the display to clone.

I want to be able to make my laptop (now calling itself "\\.\DISPLAY1") the primary display and extend to my external monitor ("\\.\DISPLAY1")

Can anyone help me achieve this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 9:54 am 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
I think you can do that in your video card control panel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 10:24 am 
Offline

Joined: March 10th, 2010, 1:34 am
Posts: 2
Gauss wrote:
I think you can do that in your video card control panel


yes I can, but I have to do it every time I plug my monitor in, and I wanted AHK to speed up the task


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Secondary Monitor
PostPosted: May 7th, 2010, 9:59 pm 
Goodfare wrote:
Is it possible to enable/disable a secondary monitor using a hotkey?
If so can someone please explain.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2010, 11:36 am 
Offline

Joined: September 10th, 2009, 5:54 pm
Posts: 203
Code:
DisplaySwitch()
DisplaySwitch(){
   Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
   Gui, Color, White
   Gui, Font, s350, Ariel
   WinSet, TransColor, White 220
   SysGet, MonitorCount, MonitorCount
   Display := (MonitorCount = 2) ? "PC" : "TV", Switch := (MonitorCount = 2) ? "/internal" : "/extend"
   RunWait, displayswitch %Switch%
   Gui, Add, Text, x0 y0 w800 h600 center cGreen, %Display%
   Gui, Show, w800 h600 NoActivate
   Sleep, 1500
   Gui, Destroy
    }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2011, 1:43 pm 
Hello,

I have a notebook, and when it is attached to the docking station at the office, I use a second monitor. Now I tried all the scripts in this thread, but none of them switch this secondary monitor on or off.

Using the very first script from this thread I get the message: "Error getting display attached status."

Using this one:
Code:
; EnumDisplayDevices(Index [, ByRef Name, ByRef StateFlags ] )
;
; ... removed "documentation"
;
;/* Example 2:
    Loop {
        if ! EnumDisplayDevices(A_Index, DeviceName, StateFlags)
            break
        if (StateFlags & 4)
            text .= DeviceName " is the primary display device.`n"
        else if (StateFlags & 1)
            text .= "The desktop extends onto " DeviceName ".`n"
        if (StateFlags & 8)
            text .= DeviceName " is a pseudo-device.`n"
    }
    MsgBox %text%
;*/
EnumDisplayDevices(Index, ByRef DeviceName, ByRef StateFlags="", ByRef DeviceKey="")
{
    ; DISPLAY_DEVICE DisplayDevice
    VarSetCapacity(DisplayDevice, 424)
    ; lpDisplayDevice.cb := sizeof(DISPLAY_DEVICE)
    NumPut(424, DisplayDevice, 0)
   
    VarSetCapacity(DeviceName, 32, 0)
    VarSetCapacity(DeviceKey, 128, 0)
    ; For consistency, clear StateFlags in case of failure.
    StateFlags = 0
   
    if ! DllCall("EnumDisplayDevices"
        , "UInt", 0
        , "UInt", Index-1
        , "UInt", &DisplayDevice
        , "UInt", 0)
        return false
   
    StateFlags := NumGet(DisplayDevice, 164)
    DllCall("lstrcpynA", "Str", DeviceName, "UInt", &DisplayDevice+4,   "int", 32)
    DllCall("lstrcpynA", "Str", DeviceKey,  "UInt", &DisplayDevice+296, "int", 128)
    if (SubStr(DeviceKey,1,18)="\Registry\Machine\")
        DeviceKey := SubStr(DeviceKey,19)
    return true
}

I get a message box containing only the OK button.

Is there any possible solution to my problem out there?

Thanks,
ikarus


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2011, 10:18 pm 
Offline

Joined: October 29th, 2010, 5:58 am
Posts: 143
Location: Sydney, Australia
The Windows+P shortcut (on Win 7 at least) can be used to enable, disable, or set multiple monitors and projectors.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 29th, 2011, 1:00 pm 
Lexikos wrote:
Here is an updated EnableDisplayDevice:
Code:
; Enables, disables or toggles a display device.
;
; DeviceName:   The name of the device, e.g. \\.\DISPLAY1
;               Alternatively, it can be the index of the device, which might
;               not be the same as the number shown in Display Settings.
; Action:       The action to take.
;                    0   Disable (false is synonymous with 0)
;                    1   Enable (true is synonymous with 1)
;                   -1   Toggle
; NoReset:      If true, settings will be saved to the registry, but not applied.
;
; The following can be used to apply settings saved in the registry:
;   DllCall("ChangeDisplaySettings", "uint", 0, "uint", 1)
;
; Return values:
;    DISP_CHANGE_SUCCESSFUL       0
;    DISP_CHANGE_RESTART          1
;    DISP_CHANGE_FAILED          -1
;    DISP_CHANGE_BADMODE         -2
;    DISP_CHANGE_NOTUPDATED      -3
;    DISP_CHANGE_BADFLAGS        -4
;    DISP_CHANGE_BADPARAM        -5
;
EnableDisplayDevice(DeviceName, Action=1, NoReset=false)
{
    if (Action = -1) || (DeviceName+0 != "")
    {
        VarSetCapacity(DisplayDevice, 424), NumPut(424, DisplayDevice, 0)
        VarSetCapacity(ThisDeviceName, 32, 0)
        Index = 0
        Loop {
            if !DllCall("EnumDisplayDevices", "UInt", 0, "UInt", A_Index-1, "UInt", &DisplayDevice, "UInt", 0)
                return -5
            ThisDeviceState := NumGet(DisplayDevice, 164)
            Index += 1
            DllCall("lstrcpynA", "Str", ThisDeviceName, "UInt", &DisplayDevice+4, "int", 32)
            if (DeviceName = Index || DeviceName = ThisDeviceName)
            {
                if Action = -1
                    Action := !(ThisDeviceState & 1)
                DeviceName := ThisDeviceName
                break
            }
        }
    }
    VarSetCapacity(devmode, 156, 0), NumPut(156, devmode, 36, "UShort")
    if Action
        NumPut(0x000020, devmode, 40) ; Enable by setting position = {0,0}
    else
        NumPut(0x180020, devmode, 40) ; Disable by setting size = {0,0}
    err := DllCall("ChangeDisplaySettingsEx", "str", DeviceName, "uint", &devmode, "uint", 0, "uint", 0x10000001, "uint", 0)
    if !err && !NoReset
        err := DllCall("ChangeDisplaySettings", "uint", 0, "uint", 1)
    return err, ErrorLevel:=Action
}
It can be used as follows:
Code:
; disable display 2
EnableDisplayDevice(2, false)
Sleep, 10000

; simultaneously enable display 2 and disable display 1
EnableDisplayDevice(2, true, true)
EnableDisplayDevice(1, false)
Sleep, 10000

; ensure both are enabled
EnableDisplayDevice(2, true, true)
EnableDisplayDevice(1)

(Edit: corrected comment about device numbering and display settings.)
Lexikos' code still works well... under AHK-Basic. Could anybody adopt it to AHK_L? I don't have any knowledge on DllCall, NumPut and VarSetCapacity.
Thanks in advance.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], bobbysoon, JSLover, Tipsy3000 and 19 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