Jump to content

Code to change from Mirror Dual Display to Extended


Recommended Posts

Hi I am writing a program to automate many things. In that program I want to switch from dual screen mirror mode to dual screen extend mode or from a dual screen extend mode back to mirror mode with a hotkey.

 I was wondering if someone can help me out with the code to do this.  I have seen examples online in my search on how to determine whether the computer is in single monitor mode or dual monitor mode but I found nothing on how to make the change happen with code only. Thanks for the help.

Link to comment
Share on other sites

Does this help? 
 

HotKeySet("{F1}", "ExtendDisplay")
HotKeySet("{F2}", "Secondmonitor")
HotKeySet("{F3}", "ComputersMonitor")
HotKeySet("{F4}", "DuplicateDisplay")

While 1
    sleep(1000)
WEnd

Func ExtendDisplay()
    Run("DisplaySwitch.exe /extend")
EndFunc

Func Secondmonitor()
    Run("DisplaySwitch.exe /external")
EndFunc

Func ComputersMonitor()
    Run("DisplaySwitch.exe /internal")
EndFunc

Func DuplicateDisplay()
    Run("DisplaySwitch.exe /clone")
EndFunc

 

Link to comment
Share on other sites

On 10/16/2017 at 1:46 AM, IanN1990 said:

Does this help? 
 

HotKeySet("{F1}", "ExtendDisplay")
HotKeySet("{F2}", "Secondmonitor")
HotKeySet("{F3}", "ComputersMonitor")
HotKeySet("{F4}", "DuplicateDisplay")

While 1
    sleep(1000)
WEnd

Func ExtendDisplay()
    Run("DisplaySwitch.exe /extend")
EndFunc

Func Secondmonitor()
    Run("DisplaySwitch.exe /external")
EndFunc

Func ComputersMonitor()
    Run("DisplaySwitch.exe /internal")
EndFunc

Func DuplicateDisplay()
    Run("DisplaySwitch.exe /clone")
EndFunc

 

Thanks. This worked partially.  When going from clone to extend mode the mouse gets stuck on the left-hand corner of the screen and unable to move it anywhere. Also the Windows taskbar disappears.  any idea why this is happening.  the screens do go to extend mode or clone mode.  In clone mode everything works fine,  it's the extended mode that is causing problems. Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...