Trigger a KM Macro from an "open document action" on a PC connected on the same LAN

Hi there again and thanks to all for the amazing resources community!

Actually working in dubbing sessions for movie production, I use a Mac for audio (protools) and a PC for dubbing rythmo session (Mosaic and Synchronos softwares)

I have a folder on both computers, one with the pro tools sessions on the Mac, and the same with the dubbing projects on the PC.

KM installed on Mac of course...

I made a PDF with all the sessions I want to open, with an hypertext link on the title that opens the dubbing session.
Is there a way to trigger KM remotely so it opens the corresponding pro tools session, and the dubbing session, with only ony click on the pdf hypertext link ?

Thanks in advance for the amazing solutions I'm sure you'll find! :blush:

Could you do this with Hazel based on a folder sync service like Dropbox?

You can trigger a macro remotely with the Remote trigger.

Assuming a link in your PDF is just calling "path/to/dubbing/session", maybe you could instead have it call a PowerShell script containing something like this:

start "path\to\dubbing\session"
Invoke-WebRequest "https://trigger.keyboardmaestro.com/t/<UniqueID1>/<UniqueID2>?TriggerValue"

Thanks!

I just know nothing about powershell script, but I'll try to find out.!

To be more precise, I forgot the pdf and have an Excel sheet, where every project (it's a training session, so multiple projects) has a line that indicates the title and what it's about.
I already made hypertext links on the titles so it opens the Mosaic dubbing session on the PC.

what I'd like is when I click on that title, if I understood we'll, is to open the famous powershell script that will do both : opening the Mosaic session and sending a web request to trigger KM.

Am I right?

Well... I just have to find how to do that with powershell script :blush: unless some of you have an answer easy to apply :blush:

I assume your current hyperlink looks something like: file:///path/to/dubbing/session

You can create a PowerShell script (a text document with the .ps1 extension) and link to that instead: file:///path/to/yourscript.ps1

Model the contents of yourscript.ps1 after this:

PowerShell scripts in Windows are set to open in Notepad by default -- this is a safety measure.
If you're willing to accept the risk, you can open Properties and change the Opens with setting to PowerShell, which is probably here C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

After that, your new hyperlink should work.
Let me know if you have any issues.

Thank you sooo much for the very clean answer !

I understood everything and am dying to try it on monday at the studio.
For what i read, it will certainly work :slight_smile:

I'll let you know of course !

This forum is an gold mine and you're a nugget in this ocean of very specific demands some of us have... thanks again for taking time to explain clearly.

Xabi

1 Like

Damned...

I was so sure it would work.
Something is weird, but don't know what.

I did exactly how you explained, without the hyperlink, as i wanted to try to open the .ps1 document before, to be sure it would work.

Nothing happens, i see the Windows powershell opening quickly (blue window) then it shuts down by itself, and ...nothing.

I also modified the properties so it opens with PowerShell and not the notepad of course...

Is there something i'm doing wrong ?

EDIT : I modified the executionpolicy to "Retmote Signed" for both Local and User.
**The webrequest works : it opens my Pro Tools session ! :slight_smile: **
But the first command does not open the Mosaic file on the PC.

2023-10-26 18_03_42-Administrateur _ Windows PowerShell

Thanks again for your patience...

Xabi

What happens if you open PowerShell and run the start "/path/to/.mos" command directly?

Very weird...

If i run the command Start "C:\Users\Synchro\Desktop\DUB MOSAIC\1. MOS CINÉMA\ALABAMA MONROE - un couple se déchire - 1H 1F\Alabama Monroe - 1H 1F.mos" directly in PowerShell, it opens the corresponding file perfectly... (see the Noblurway Mosaic software lauching screen in front of the powershell window...)

But if i copy/paste the exact same command into the.ps1 document created, i have an error message, which i don't understand at all :slight_smile:

Here is my .ps1 document content :

And the error message i got :

The only command that worls when opening the .ps1 is the opening of my protools session. (Which is already super fine ! But useless if it doesn't open the .mos doc at the same time)...

Seems like a name/path/directory problem : If i copy the .mos file on the desktop on windows, copy the new path to the /ps1 document, it works and open both the Mosaic doc and the Pro Tools session.

Well.... we're close... but i can't copy all the 60 mosaic documents on the desktop and i have to find out what's wrong with the path name.

Thanks. I'll keep digging, but if you know what's going on...

Xabi

EDIT : FOUND A SOLUTION !

Well, the cause was an accent on "cinEma" on the file... (f... french ^)

Now, the PowerShell script works but only if the .ps1 file is on the desktop.
As soon as i put it in a file, it becomes impossible to run it. If i try to open it, i get a very quick blue "powershell" window, but no error message, nothing, it just closes by itself after half a second...

I can not have ALL my .ps1 documents (one for each session) on the desktop, impossible...

Any idea what causes the .ps1 doc not to open as soon as i move it from the desktop ???

I won't quit and sure there is an explanation :slight_smile:

Xabi

Sure enough, this is a character encoding problem.

I was able to reproduce the issue. When I created a new file in Notepad.exe to create the script, it saves it encoded as UTF-8 (without a BOM). This Stack Overflow answer explains why that's a problem.

I was able to fix it by opening the script in Notepad++ and selecting the menu item Encoding -> Convert to UTF-8-BOM.

You may also be able to do this in your text editor of choice, or with a PowerShell command similar to this:

$old = "/path/to/script-utf8.ps1"  
$new = "/path/to/script-utf8-2bom.ps1"  
(Get-Content -path $old) | Set-Content -Encoding UTF8BOM -Path $new

I solved the character encoding problem with deleting all the accents.
Done.

The only remaining problem is the path of the ps1 doc.

As soon as I move it from the desktop, nothing happens.
I read that folders have to be configured to allow script launching but I really don't know how to change that.

Or a execution policy not configured as desired....

Uhhhh this is a tough one for me, but we're getting so close....

Thank you so much for taking time to try to solve my problem.

Where are you trying to put it?
Another location on a local disk? A network share?

Nothing fancy : I just want to put my .ps1 files in a folder, on the desktop of the PC.

to resume, if I open it from the desktop, it works. If I put in a folder, on the same desktop, it doesn't.

There is an error being produced, but the interpreter window is disappearing before we can see what's wrong.

To see an error message, open a PowerShell window and run it from there by entering the full path to your script.

Okay, will do that as soon as I get back to the studio :ok_hand: