INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Is there a way to enforce a detached display?  (Read 932 times)

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Is there a way to enforce a detached display?
« on: May 21, 2024, 04:25:41 pm »

I would like to find a way to enforce the use of a detached display for the MC zone I use for playing videos.

An old thread https://yabb.jriver.com/interact/index.php?topic=79166.msg537977 includes a script for doing just that. I updated the code to use MC32 and to target Zone #3, as shown below. This was saved as a .wsf file but it doesn't work. It opens MC but doesn't make the switch to a detached display. Are such scripts no longer valid for MC or does it just need a little tweak?

Code: [Select]
<package>
<job id="vbs">
<script language="VBScript">

'Create our handy dandy Shell object
set WshShell = WScript.CreateObject("WScript.Shell")

'Start MC
WshShell.Run "mc32.exe"

'Pause for a bit
WScript.Sleep 1000

'Detach display on Zone 3
WshShell.Run "mc32.exe /MCC 10037, 1:2"
</script>
</job>
</package>
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Is there a way to enforce a detached display?
« Reply #1 on: May 21, 2024, 04:55:12 pm »

Try testing the mc32 commands in a cmd prompt first.
I think you need to remove the space between the MCC arguments. This works for me:

mc32 /mcc 10037,1
mc32 /mcc 10014
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #2 on: May 21, 2024, 05:56:21 pm »

Try testing the mc32 commands in a cmd prompt first.
I think you need to remove the space between the MCC arguments. This works for me:

mc32 /mcc 10037,1
mc32 /mcc 10014

Those commands work via a command prompt but not via the .wsf script.
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #3 on: May 22, 2024, 03:56:13 am »

I seem to have it working now.

I was very confused about zone numbering. I've no idea what controls the order of the zones in my MC installation, but it's certainly not in alphabetical order. I was originally following the guidance provided by Glynor (the author of the wsf script) in the thread I linked in my OP, which stated "1:0 corresponds to the first zone, 1:1 to the second, 1:2 to the third and so on and so forth". That does not appear to be correct in my case.

A process of trial and error (greatly assisted by the Overview that appears at the top of the Playing Now section in the MC interface and indicates which zones have a detached display) proved that Zone 0 was my 2nd zone, Zone 2 was my 5th zone, and Zone 3 was my 4th zone. I don't know the meaning of Zone 1, as it simply generated a black rectangle and didn't trigger any detached display indicator in Playing Now: Overview.   

I tried to add another command to set Zone 0 as the current zone but mc32.exe /MCC 10011,0 doesn't work. Have I got the syntax wrong for that command?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Is there a way to enforce a detached display?
« Reply #4 on: May 22, 2024, 05:28:53 am »

You can list the zones and their index/internal IDs via MCWS:
http://localhost:52199/MCWS/v1/Playback/Zones?hidden=1

There's also the /Playback/SetZone MCWS command to switch zones. That one can switch by zone index, zone ID, or zone Name.
http://localhost:52199/MCWS/v1/
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #5 on: May 22, 2024, 06:49:42 am »

You can list the zones and their index/internal IDs via MCWS:
http://localhost:52199/MCWS/v1/Playback/Zones?hidden=1

Thanks for that very useful zone information :)

Rather non-intuitively, the successive zone IDs stepping down my zone list (as displayed in MC) are 10038, 0, 10036, 10035, 10018, etc. What is the logic behind the ordering of the zone list in MC? 

Quote
There's also the /Playback/SetZone MCWS command to switch zones. That one can switch by zone index, zone ID, or zone Name.
http://localhost:52199/MCWS/v1/

The SetZone example provided via your link let me switch to my 1st zone by using the following browser entry.

http://localhost:52199/MCWS/v1/Playback/SetZone?Zone=10038ZoneType=ID

How would I incorporate that in the SWF script mentioned earlier?

On a wider issue, that script was published in this forum long before the Adobe Flash SWF format became defunct. Is there another way to automate MC startup?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Is there a way to enforce a detached display?
« Reply #6 on: May 22, 2024, 07:22:31 am »

Rather non-intuitively, the successive zone IDs stepping down my zone list (as displayed in MC) are 10038, 0, 10036, 10035, 10018, etc. What is the logic behind the ordering of the zone list in MC? 
Internal IDs are... internal. No logic is required :P Maybe you should use the Index or Name instead.

Quote
How would I incorporate that in the SWF script mentioned earlier?
Use Curl to do the HTTP calls.

Quote
On a wider issue, that script was published in this forum long before the Adobe Flash SWF format became defunct. Is there another way to automate MC startup?
It's not SWF, it's WSF (Windows Script File). It's not related to Flash.
If you just need a script to run as a shortcut or as a scheduled task on windows startup/logon, you do not need a WSF file. You can use a simple .bat or .cmd file with the same commands, something like this:

Code: [Select]
@echo off
mc32
timeout 2
curl -u YourUser:YourPass http://localhost:52199/MCWS/v1/Playback/SetZone?Zone=10038ZoneType=ID
mc32 /MCC 10037,1
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #7 on: May 22, 2024, 08:50:09 am »

Thanks for the clarification. My OP correctly referred to a .wsf file but my aging brain subsequently converted it to .swf :(

Since my last post I had already discovered that a .bat file was an alternative to a .wsf, though batch files have the disadvantage of causing a short flash on the screen. However, I've never used Curl before, so thanks for that info.

I still have an issue with the MCC 10037 command, as it appears to be behaving in a rather erratic manner.

Using the command prompt, I can turn detached display on for the current zone with MC32 /MCC 10037,1 and turn it off with MC32 /MCC 10037,0. So far, so good, but when I specify the ZoneID the situation becomes more complicated.

MC32 /MCC 10037,1:0 correctly detaches the display for Zone 0, but MC32 /MCC 10037,1:10038 also detaches the display for Zone 0 (but not Zone 10038). The same applies when I use other ZoneIDs in the command. They all detach the display for Zone 0. What might explain such behaviour?
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #8 on: May 22, 2024, 09:12:00 am »

Forget that last question. That MCC command requires the Zone Index not the Zone ID!!
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #9 on: May 22, 2024, 11:59:17 am »

Using the command prompt to issue MCC commands is now working as expected and I can turn the detached display setting on and off for five different zones. I can also do the same thing using the following .bat file.

Code: [Select]
@echo off
MC32.exe
timeout 2

rem  ZoneIndex 0 = AV system(video)
rem  ZoneIndex 2 = Zoom Zone
rem  ZoneIndex 3 = This PC
rem  ZoneIndex 4 = Sue's projector
rem  ZoneIndex 5 = AV system (SACD)
rem  MC32.exe /MCC 10037,1:ZoneIndex

MC32.exe /MCC 10037,1:0

However, it's not working for me when I use the same MCC command in a .wsf file. What might I be doing wrong?

Code: [Select]
<package>
<job id="vbs">
<script language="VBScript">

'Create our handy dandy Shell object
set WshShell = WScript.CreateObject("WScript.Shell")

'Start MC
WshShell.Run "MC32.exe"

'Pause for a bit
WScript.Sleep 1000

'Detach display
WshShell.Run "MC32.exe /MCC 10037,1:0"
</script>
</job>
</package>
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Is there a way to enforce a detached display?
« Reply #10 on: May 22, 2024, 12:20:45 pm »

Why do you need it as a .wsf?
Maybe the sleep delay is not enough, try 5 seconds.
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #11 on: May 22, 2024, 01:19:50 pm »

I've already tried a 10 second delay but it made no difference. Using a .wsf file is not vital, but it's been the long established solution for enforcing a detached display, so I was assuming I must just have made a simple mistake.

A .wsf file also doesn't cause the annoying screen flash of a .bat file (though I can fix that by running it from a .vbs file).
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4199
Logged

eve

  • Citizen of the Universe
  • *****
  • Posts: 689
Re: Is there a way to enforce a detached display?
« Reply #13 on: May 22, 2024, 01:50:27 pm »

https://nircmd.nirsoft.net/exec.html#:~:text=The%20%5Bshow%2Fhide%2Fmin,application%20window%20will%20be%20maximized.

Nircmd hide should do the job for that purpose

This.


Was just about to pop in with this recommendation (or just AHK, I use AHK scripts for this because I need to switch focus / ensure placement). Basically, a bunch of AHK / powershell commands that get initiated remotely by my API on the target machine.


Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #14 on: May 22, 2024, 04:26:04 pm »

https://nircmd.nirsoft.net/exec.html#:~:text=The%20%5Bshow%2Fhide%2Fmin,application%20window%20will%20be%20maximized.

Nircmd hide should do the job for that purpose

The author of nircmd describes it as a command-line utility. How do I create a program that exploits nircmd to run my .bat file in hidden mode?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Is there a way to enforce a detached display?
« Reply #15 on: May 22, 2024, 04:36:10 pm »

https://www.digitalcitizen.life/shortcut-arguments-parameters-windows/

Create a shortcut to nircmd.exe then edit the shortcut properties to add the arguments, something like "nircmd.exe exec hide c:\yourpath\yourscript.bat"

... or use nircmd to create the shortcut :)
> nircmd.exe cmdshortcut "~$folder.desktop$" "Start MC" exec hide c:\yourpath\yourscript.bat

You can change the shortcut icon after creating it.
Logged

haggis999

  • Citizen of the Universe
  • *****
  • Posts: 514
Re: Is there a way to enforce a detached display?
« Reply #16 on: May 22, 2024, 05:46:48 pm »

https://www.digitalcitizen.life/shortcut-arguments-parameters-windows/

Create a shortcut to nircmd.exe then edit the shortcut properties to add the arguments, something like "nircmd.exe exec hide c:\yourpath\yourscript.bat"

... or use nircmd to create the shortcut :)
> nircmd.exe cmdshortcut "~$folder.desktop$" "Start MC" exec hide c:\yourpath\yourscript.bat

You can change the shortcut icon after creating it.

Many thanks for that. I now have a shortcut on my desktop that opens MC, detaches the display for a specific zone, and then makes that the current zone. I could not have achieved that without all your help, for which I am very grateful :):):)

I'm not yet sure if hiding the screen flash created by a batch file by using nircmd is a slicker solution than my previous method of triggering the .bat file via a .vbs file, but it's good to have more than one way to do things. 


EDIT:  When I wrote this post I had only tried creating the nircmd shortcut in the conventional manner, which is a slightly fiddly task. I've now tried the suggested alternative of using nircmd itself to create the shortcut and was impressed. On balance, I have now decided to use nircmd for my future batch files instead of wrapping them in VBS scripts. 
Logged
Pages: [1]   Go Up