“Extend my Windows desktop onto this monitor” programmatically

后端 未结 8 1038
不思量自难忘°
不思量自难忘° 2020-12-24 03:02

I would like to be able to set \"Extend my Windows desktop onto this monitor\" via code. A PowerShell script would be ideal. WMI seems the way forward but I have zero knowle

8条回答
  •  有刺的猬
    2020-12-24 03:41

    2 lines in autohotkey

    2nd display on:

    RunWait C:\Windows\System32\DisplaySwitch.exe /extend
    

    2nd display off:

    RunWait C:\Windows\System32\DisplaySwitch.exe /internal
    

    -

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; #Warn  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    #Persistent 
    
    Any1stKeyUWantToTurnOn::RunWait C:\Windows\System32\DisplaySwitch.exe /extend
    Any2stKeyUWantToTurnOff::RunWait C:\Windows\System32\DisplaySwitch.exe /internal
    

    or

    You can check and try out my tool on github / BNK3R-Boy / DisplaySwitch. I published it right now.

提交回复
热议问题