YT URL Macro (v11.0.2)

YT URL Macro (v11.0.2)

YT URL.kmmacros (6.1 KB)

Keyboard Maestro Export

The enclosed macro called YT URL.
When I run the macro. It gives me a user prompt to enter values for ams, pms and book. The values are placed in the variables by the perspective name.
What I am trying to do with the {} if All Conditions met Execute action is if I enter a string trigger of semicolon ytams have it write the variable info from ams to where the cursor happens to be. Same for pms and book. Will I need to write separate macros for each of the URLs or can I place all of differing macros into one Macro? I can’t find a way to have an if then statement for a trigger. Say if semicolon yt bring up the prompt to enter values or if I put in semicolon ams write the value that has been entered into that variable. Any help ideas appreciated.

I don't fully understand what you're trying to do, but what you have above won't work. One problem is that the conditionals won't be true unless you literally type value into one of the input boxes, because that's what your'e testing for.

I think you're conflating two separate tasks here into one, and I'm not sure that's the best way to do it. As I understand it, you have three values you'd like to set (ams, pms, and book). That's one task. Then the second task is to insert the values for whichever of those variables at the spot where the cursor is. If that's correct, then I think what you want is probably four macros:

  1. The Prompt for Input you have above to save your variables. Run this whenever you want to change them. You can even see what they currently are in the dialog by putting %Variable%ams%, %Variable%pms%, and %Variable%book%` where the "Default value" text is now.
  2. Three separate macros on typed string triggers, one for each variable. ;;yt trigger does an Insert Text by Pasting (or Typing) of %Variable%ams% (or whatever the right one is). Repeat with two new triggers for the other two, then use wherever you need to use them.

When it's time to change the values, run macro 1 again.

If this isn't what you're trying to do, then a bit more detail on the task would be welcomed.

-rob.

Yes sir that is basically it. the macro that would allow me to put the url in could I put a three choice in to just have one macro for pasting in the URL for a YouTube spot? I guess I could setup a YouTube palette for choosing the macro?

This is the the part I don't really understand. How would one macro function to insert one of three different things, which is what I think you want it to do? The macros have no context on the text you're in or what you need, so they can't really select which one to use for you.

You could use a conflict palette by giving all three macros the same shortcut, so you'd see a pop-up each time you invoked it, and could choose one of the three that way. Then you'd use one keyboard shortcut to see the palette (it shows all three macros it could run), and a second keystroke would choose which macro to run, which would then insert the chosen text.

Or you could give one macro three separate triggers, and use thet %TriggerValue% token to check for which trigger was used, and then an if-then would select the appropriate text.

-rob.

Really what I want is a way to choose one of three macros. Have a macro where I put in the URL for YouTube AM, One for YouTube PM and one for YouTube Book. Then when I was at the location to paste the URL in I would be presented with a prompt to choose which one I wanted pasted in. But I guess if I set this up in a Palette I would get a choice using the palette?

You can do it all in one by using a regular expression for the trigger then testing the %TriggerValue% to decide what to do:

YT URL.kmmacros (4.6 KB)

Image

I'm assuming this is just proof of concept, since it's pretty pointless to use a macro that shows a dialog that you type in to, just so KM can type the text for you!

1 Like

Dang, I always forget that you can use regex on typed string triggers! Brilliant.

-rob.

I was trying to use one string trigger and choose if the URL was for AM, PM or Book.

  1. Why? You're used to typing different TE strings for each, why not continue to use those same triggers in KM? But if you want to stop and use a dialog instead, that's easy enough.
  2. But you're still conflating getting those values in to your variables and, later, getting them out. You'd be better doing them as two separate macros.

Run this macro at the beginning of the week, to "load up" your URLs:

Monday Morning Setup.kmmacros (2.2 KB)

Image

...and run this one by typing ;yt whenever you want to insert one of the values:

Insert YT URL by Prompt.kmmacros (4.3 KB)

Image

If you do want to go back to your TE method of just typing the appropriate string for each value:

Insert YT URL.kmmacros (3.4 KB)

Image

...but remember to disable the other "Insert YT" macro first!

Will the name Global have an effect on if I do one of these for Rumble and one for Facebook. I actually have nine Video files I upload. The Book ones on Thursday a set of three for YouTube, three For Rumble and Three for Facebook. At the bottom of their descriptions will be URL links to the location of all three sites. Then Friday I edit both my ams and pms videos to all three sites making 6 more URL so the reason why I have been trying to set this up in Keyboard Maestro.
So my "game plan" is, lets use the book one as an example, to have a YTbook macro that will let me load ams URL, pms URL and Book URL into variables so when I go back and edit the descriptions I can make clickable links out of YouTube | Rumble | Facebook that are listed at the bottom of the description. I hope that isn't too convoluted.

The "Global" in the variable name just makes it very obvious that this is a global KM variable. Since it is a global its value will persist -- so you can set it on Monday and still access that value on Friday -- and it is available to all your other macros -- which is why we can set it in one and get it in another.

Compare that to a "Local" variable, which only "lives" for as long as a macro is executing and isn't available to other macros (unless they are sub-routines of that macro). Generally it is a good idea to use local variables so that your macros don't interfere with each other, but in this case that's exactly what we want to happen.

See the Wiki's Variables page for more. And, at the risk of repeating myself, have at least a skim of the manual where all this and more is explained.

For now I suggest you keep it simple and have 9 global variables -- the 3 we have here for YouTube, another 3 for Rumble, another 3 for Facebook. All you have to do is duplicate the macros above then alter them for the other services.

Get comfortable with using variables and tokens before you start worrying about more complex data structures like Dictionaries.

I loaded those macros and enabled but couldn’t get them to work

I got it going. Here is a png with a question?