0
votes
@echo off
DisplaySwitch.exe /extend
start "" "C:\Program Files (x86)\Steam\Steam.exe" -bigpicture
tasklist /fi "imagename eq steam.exe" |find ":" > nul
if errorlevel 1 (
DisplaySwitch.exe /external
)

DisplaySwitch.exe changes my monior settings from second screen only to extended line 3 starts steam in big picture mode im not to familiar with line 4, basically it should list steam and generate an error level, 0 means the program is running, 1 means it is not. if statement, if the prgram isn't running change monitor settings back to second screen only.

I have a dual monitor setup, then a tv beside it that I use for steam big picture. (I dont have it enabled for instances other than big picture) I recently got a new keyboard that had programmable keys so I wanted to program a key to run big picture, switch monitors, and all that jazz. So when I press this button, I want my monitor settings to change to extended, (So my TV has a computer signal) than launch steam big picture, which I was able to achieve. The problem arose when I wanted to go back to normal monitor settings. I wanted to test to see if steam was running, if it isn't (me exiting steam big picture) I want it to go back to my default monitor settings. I made this code using a plethora of internet resources but I just can't seem to get the last part right. Any help would be greatly appreciated!

1

1 Answers

0
votes

Perhaps it would help if you were to say what it IS doing rather than leave us to wonder. Evidently, it appears to be executing the switch-back despite the presence of steam.exe. Would that be correct?

AFAICS, possibly steam is not actually loaded when the tasklist is executed. You may need to insert a delay.

timeout /t 1 >nul

should take care of that - 1 second.

OR, perhaps you could try

start /WAIT "" "C:\Program Files (x86)\Steam\Steam.exe" -bigpicture

which should wait for steam to exit before continuing to the next step. Probably wouldn't need the tasklist at all that way...


Edit : start line for added clarity