Windows 7 Win+p -> Duplicate by shortcut or CLI command?

freddan

New Member
Joined
Sep 4, 2009
Messages
2
Hi!

I'm trying to make an easy way to put my computer in and out of a TV-mode, where the TV will be attached as a secondary monitor in clone mode when in the TV-mode, and detached when out of the TV-mode. To do this, I need a command/shortcut that does exactly what happens when you press Win+p and select "Duplicate". Is there any way to achieve this?

I appreciate any help or tips regarding this, thanks!
 

Solution
To create a quick and easy way to switch your computer in and out of TV-mode where the TV acts as a secondary monitor in clone mode, you can use a script that simulates the Win+P keypress and selects the "Duplicate" option. Here's a step-by-step guide on how you can achieve this using PowerShell:
  • Create a PowerShell Script:
  • Open Notepad or any text editor.
  • Copy and paste the following PowerShell script into the editor:
    Code:
    $wsh = New-Object -ComObject WScript.Shell $wsh.SendKeys('{LWIN down}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{P}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{LWIN up}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{DOWN}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{DOWN}') Start-Sleep...
To create a quick and easy way to switch your computer in and out of TV-mode where the TV acts as a secondary monitor in clone mode, you can use a script that simulates the Win+P keypress and selects the "Duplicate" option. Here's a step-by-step guide on how you can achieve this using PowerShell:
  • Create a PowerShell Script:
  • Open Notepad or any text editor.
  • Copy and paste the following PowerShell script into the editor:
    Code:
    $wsh = New-Object -ComObject WScript.Shell $wsh.SendKeys('{LWIN down}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{P}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{LWIN up}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{DOWN}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('{DOWN}') Start-Sleep -Milliseconds 100 $wsh.SendKeys('~')
  • Save the Script:
  • Save the script with a .ps1 extension (e.g., SwitchToTVMode.ps1).
  • Create Shortcuts:
  • Right-click on the script file and select "Create shortcut."
  • Drag the shortcut to your desktop or any convenient location.
  • Set Shortcut Hotkey:
  • Right-click on the shortcut and select "Properties."
  • In the "Shortcut key" field, press the key combination you want to use (e.g., Ctrl+Alt+T for TV mode).
  • Click "Apply" and "OK."
  • Run the Script:
  • Now, whenever you press the assigned shortcut key (e.g., Ctrl+Alt+T), it will simulate the Win+P keypress and select "Duplicate" to switch your computer to TV mode. By following these steps, you can quickly switch your computer in and out of TV mode with a simple key combination. This solution automates the process of selecting the "Duplicate" option similar to using Win+P and selecting the display mode manually.
 

Solution
Back
Top