Skip to content

Commit

Permalink
TvPcSwitch added
Browse files Browse the repository at this point in the history
  • Loading branch information
OsaPL committed Apr 26, 2021
1 parent 4800216 commit f7c60d5
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 0 deletions.
Binary file added tvpcswitch/AudioSwitch.exe
Binary file not shown.
40 changes: 40 additions & 0 deletions tvpcswitch/MultiMonitorTool.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[General]
ShowGridLines=0
SaveFilterIndex=0
ShowInfoTip=1
VerSplitLoc=10922
AutoRefresh=1
MonitorPreviewWindow=0
StartAsHidden=0
HideInactiveMonitors=0
PreviewMode=2
DrawCursorPreview=1
TrayIcon=0
MarkOddEvenRows=0
SelectedMonitior=\\.\DISPLAY2
MainFont=00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SortOnEveryUpdate=0
AlwaysOnTop=0
AlwaysOnTopMonitorPreview=0
LoadConfigUseMonitorID=1
PreviewUpdateRate=1000
ShowDuplicateMonitors=0
ShowDisconnectedMonitors=0
RepositionOnEnable=1
WinPos=2C 00 00 00 00 00 00 00 01 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF C9 00 00 00 CA 00 00 00 49 03 00 00 AA 02 00 00
PreviewWindowPos=2C 00 00 00 00 00 00 00 01 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 40 01 00 00 F0 00 00 00
Columns=78 00 00 00 78 00 01 00 78 00 02 00 5A 00 03 00 5A 00 04 00 5A 00 05 00 5A 00 06 00 5A 00 07 00 6E 00 08 00 78 00 09 00 C8 00 0A 00 C8 00 0B 00 FA 00 0C 00 FA 00 0D 00 02 01 0E 00 96 00 0F 00 96 00 10 00 96 00 11 00 96 00 12 00
Sort=10
WindowsListColumns=FA 00 00 00 64 00 01 00 64 00 02 00 64 00 03 00 5A 00 04 00 78 00 05 00 78 00 06 00 FA 00 07 00
WindowsListSort=0
[RecentFiles]
0=
1=
2=
3=
4=
5=
6=
7=
8=
9=
Binary file added tvpcswitch/MultiMonitorTool.exe
Binary file not shown.
Empty file added tvpcswitch/PcMode
Empty file.
22 changes: 22 additions & 0 deletions tvpcswitch/pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[Monitor0]
Name=0.Name
MonitorID=0.MonitorID
BitsPerPixel=32
Width=2560
Height=1440
DisplayFlags=0
DisplayFrequency=144
DisplayOrientation=0
PositionX=2
PositionY=1200
[Monitor1]
Name=2.Name
MonitorID=2.MonitorID
BitsPerPixel=32
Width=1920
Height=1200
DisplayFlags=0
DisplayFrequency=60
DisplayOrientation=0
PositionX=2562
PositionY=1189
7 changes: 7 additions & 0 deletions tvpcswitch/steamBigpicture.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tasklist|>nul find /i "Steam.exe"
if errorlevel 1 (
start E:\Steam\Steam.exe -bigpicture
) else (
taskkill /F /IM Steam.exe
start E:\Steam\Steam.exe -bigpicture
)
127 changes: 127 additions & 0 deletions tvpcswitch/switch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
function Write-ColorOutput($ForegroundColor)
{
# save the current color
$fc = $host.UI.RawUI.ForegroundColor

# set the new color
$host.UI.RawUI.ForegroundColor = $ForegroundColor

# output
if ($args) {
Write-Output $args
}
else {
$input | Write-Output
}

# restore the original color
$host.UI.RawUI.ForegroundColor = $fc
}

"Enabling all monitors..." | Write-ColorOutput green
# Enable all
"Enabling 1" | Write-ColorOutput yellow
.\MultiMonitorTool.exe /enable 1
Start-Sleep 5
"Enabling 2" | Write-ColorOutput yellow
.\MultiMonitorTool.exe /enable 2
Start-Sleep 5
"Enabling 3" | Write-ColorOutput yellow
.\MultiMonitorTool.exe /enable 3
Start-Sleep 5

"Gathering monitor parameters..." | Write-ColorOutput green
## Gather info
$devices = @{};

#Hardcoded placement
#$devices[0]= #AG241QG4
#$devices[1]= #SAMSUNG
#$devices[2]= #DELL U2412M

.\MultiMonitorTool.exe /scomma test
Start-Sleep 5
$mytable = Import-Csv -Path test

foreach($r in $mytable)
{
if($r.'Monitor Name'.Equals("AG241QG4")){
"Parsing 1..." | Write-ColorOutput yellow
$devices[0]= $r
}
elseif($r.'Monitor Name'.Equals("SAMSUNG")){
"Parsing 2..." | Write-ColorOutput yellow
$devices[1]= $r
}
elseif($r.'Monitor Name'.Equals("DELL U2412M")){
"Parsing 3..." | Write-ColorOutput yellow
$devices[2]= $r
}
}

"Preparing configs..." | Write-ColorOutput green
## Replace values
Copy-Item pc pcTemp
$configPc = Get-Content -path pcTemp -Raw
$configPc = $configPc.Replace('0.Name', $devices[0].Name)
$configPc = $configPc.Replace('0.MonitorID', $devices[0].'Monitor ID')
$configPc = $configPc.Replace('2.Name', $devices[2].Name)
$configPc = $configPc.Replace('2.MonitorID', $devices[2].'Monitor ID')
Set-Content -Path pcTemp -Value $configPc
"PC config ready" | Write-ColorOutput yellow

Copy-Item tv tvTemp
$configTv = Get-Content -path tvTemp -Raw
$configTv = $configTv.Replace('1.Name', $devices[1].Name)
$configTv = $configTv.Replace('1.MonitorID', $devices[1].'Monitor ID')
Set-Content -Path tvTemp -Value $configTv
"TV config ready" | Write-ColorOutput yellow

"Initialising switching..." | Write-ColorOutput green
## Switch
if(Test-Path PcMode)
{
"Found PcMode, switching to TV..." | Write-ColorOutput yellow
#$intButton = $sh.Popup("Switching to TV Mode!\r\nPlease wait...",20,"Switcher",0+64)
Remove-Item PcMode

.\MultiMonitorTool.exe /disable $devices[2].Name
Start-Sleep 5
.\MultiMonitorTool.exe /disable $devices[0].Name
#WHY THE FUCK DO I NEED TO LOAD THIS 2 TIMES?!
.\MultiMonitorTool.exe /loadconfig tvTemp
Start-Sleep 5
.\MultiMonitorTool.exe /loadconfig tvTemp

"Found PcMode, switching to TV..." | Write-ColorOutput yellow
# Start big picture
Start-Process steamBigpicture.bat

"Changing audio output" | Write-ColorOutput yellow
# Set audio output
.\AudioSwitch.exe -s "1 - AG241QG4 (AMD High Definition Audio Device)"
}
else
{
"No PcMode found, switching to PC..." | Write-ColorOutput yellow
New-Item PcMode

.\MultiMonitorTool.exe /disable $devices[1].Name
Start-Sleep 5
#WHY THE FUCK DO I NEED TO LOAD THIS 2 TIMES?!
.\MultiMonitorTool.exe /loadconfig pcTemp
Start-Sleep 5
.\MultiMonitorTool.exe /loadconfig pcTemp

"Changing audio output" | Write-ColorOutput yellow
# Set audio output
.\AudioSwitch.exe -s "Speakers (2- Realtek(R) Audio)"
}

Remove-Item pcTemp
Remove-Item tvTemp
Remove-Item test

"DONE!" | Write-ColorOutput green

Start-Sleep 20
Binary file added tvpcswitch/switchModes.lnk
Binary file not shown.
11 changes: 11 additions & 0 deletions tvpcswitch/tv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Monitor0]
Name=1.Name
MonitorID=1.MonitorID
BitsPerPixel=32
Width=3840
Height=2160
DisplayFlags=0
DisplayFrequency=59
DisplayOrientation=0
PositionX=0
PositionY=0

0 comments on commit f7c60d5

Please sign in to comment.