Card to exectute multiple actions

Here you are welcome to share your Push2Run cards

PLEASE NOTE:
If you are downloading a Push2Run card from here or anywhere else, please inspect it carefully before running it or any software associated with it. If you don't do this you may end up with seriously unwanted results.

When sharing a card, please leave any special instructions that are required for its use. For example, if additional software is needed to enable the card, you should leave a link to the program's official webpage.
Post Reply
slimjim69
Posts: 4
Joined: Sun Jun 28, 2020 2:51 am

Card to exectute multiple actions

Post by slimjim69 »

I am new to this all and am having trouble creating a card that will a do number of things. I wish for the command to 1) switch to secondary monitor, 2) open Steam Big Picture mode, 3) switch audio output to TV. I have already written a working .BAT file that works when clicked on but doesn't work when executed through Push2Run. The .BAT file is written below.

start C:\Windows\System32\DisplaySwitch.exe /external
start "C:\Program Files (x86)\Steam\Steam.exe" steam://open/bigpicture -fulldesktopres"
nircmd setdefaultsounddevice "TV" 1
exit

This is the error I get when executing the command through Google Assistant/Push2Run
https://imagehost.com.au//icB4D

Any help on this would be extremely appreciated!!
RobLatour
Site Admin
Posts: 1003
Joined: Mon Feb 19, 2018 11:43 am

Re: Card to exectute multiple actions

Post by RobLatour »

Well, I would say you've done very well.

I think you're just getting tripped up by one of those "gotta love Windows" things.

In your bat file, please try changing:

start C:\Windows\System32\DisplaySwitch.exe /external
to
start start "" "C:\Windows\system32\DisplaySwitch.exe" /external

for more information please see:
https://stackoverflow.com/questions/154 ... ed-program

Also, another potential trip up if have a 64-bit version of Windows (which most people do these days), is that if you want to execute the DisplaySwitch command directly from a Push2Run card, then you have to use the Sysynative folder in place of the System32 folder as shown below:
sysnative.png
sysnative.png (13.02 KiB) Viewed 7018 times

ref: https://www.samlogic.net/articles/sysna ... indows.htm

Again, gotta love Windows.

Hope this helps!
slimjim69
Posts: 4
Joined: Sun Jun 28, 2020 2:51 am

Re: Card to exectute multiple actions

Post by slimjim69 »

Hi Rob!

Thanks so much your your reply, I really appreciate your help. I tried your recommendations but unfortunately still no improvement... :cry:

The .BAT file currently reads:

start start "" "C:\Windows\system32\DisplaySwitch.exe" /external
start "C:\Program Files (x86)\Steam\Steam.exe" steam://open/bigpicture -fulldesktopres"
nircmd setdefaultsounddevice "TV" 1
exit


And the Pusgh2Run card is setup with the Start Directory as "C:\Windows\Sysnative"
https://imagehost.com.au//Hp045

Unforuntately still getting the same error: https://imagehost.com.au//icB4D

The .BAT file still works perfectly when clicked by a mouse but it seems like Push2Run is still struggling to access system32\DisplaySwitch.exe. There was another post in the forums with a working card to switch monitors through Push2Run so it is possible. I just wanted to be able to swich monitors, open Big Picture and switch audio output all in once voice command instead of multiple. I don't personally understand any of the below code but this is the working monitor switch .p2r file here. Any clues?

<?xml version="1.0" encoding="utf-8"?>
<Card xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" DateTimeValue="2019-04-09T00:10:00.4874157+01:00">
<Description>win 2nd monitor</Description>
<ListenFor>2nd monitor
tv</ListenFor>
<Open>DisplaySwitch.exe</Open>
<StartDirectory>C:\Windows\Sysnative</StartDirectory>
<Parameters>/external</Parameters>
<StartWithAdminPrivileges>false</StartWithAdminPrivileges>
<StartingWindowState>3</StartingWindowState>
<KeysToSend />
</Card>

Thanks again for your help!!
RobLatour
Site Admin
Posts: 1003
Joined: Mon Feb 19, 2018 11:43 am

Re: Card to exectute multiple actions

Post by RobLatour »

Does your .bat file really read:

start start "" "C:\Windows\system32\DisplaySwitch.exe" /external

if yes, it should read:

start "" "C:\Windows\system32\DisplaySwitch.exe" /external

also

As you have fully qualified (including both path and filename) the .bat file in your Push2Run card's 'open' field, you should leave the 'Start directory' field on your Push2Run card blank.
slimjim69
Posts: 4
Joined: Sun Jun 28, 2020 2:51 am

Re: Card to exectute multiple actions

Post by slimjim69 »

https://imagehost.com.au//icB4D
Unfortunately still getting the same error :( P2R Start Directory is blank and BAT file reads:

start "" "C:\Windows\system32\DisplaySwitch.exe" /external
start "C:\Program Files (x86)\Steam\Steam.exe" steam://open/bigpicture -fulldesktopres"
nircmd setdefaultsounddevice "TV" 1
exit


Any other ideas would be greatly appreciated :D
RobLatour
Site Admin
Posts: 1003
Joined: Mon Feb 19, 2018 11:43 am

Re: Card to exectute multiple actions

Post by RobLatour »

ok - so I did some testing and I seem to have found a workaround.

For some reason, DisplaySwitch.exe cannot be run out of the C:\Windows\system32 folder,

Accordingly, I copied the file DisplaySwitch.exe into a directory I created called c:/temp

it would then work when run out of the temp directory.

Because of my screen configuration, in testing DisplaySwitch kinda messed up my screens, but I was able to manually put things back in place.

In my testing my bat file contained the following:

c:
cd \
cd temp
DisplaySwitch /external

but my guess is the start command will work as well (as you have above) - I just don't want to mess up my screens again to test it further.

Please let me know if this helps.
slimjim69
Posts: 4
Joined: Sun Jun 28, 2020 2:51 am

Re: Card to exectute multiple actions

Post by slimjim69 »

Rob you are my absolute hero! It works a charm!
My computer desk/couch gaming setup is now fully automated with my Google Home and it's all thanks to you!! :D
RobLatour
Site Admin
Posts: 1003
Joined: Mon Feb 19, 2018 11:43 am

Re: Card to exectute multiple actions

Post by RobLatour »

glad to have helped
Post Reply