Saving info after prompt for user action

Sorry, you didn't properly upload them. I think it's important to show your macros if you want an answer to "how do I fix my macros?" Without seeing your macros, you may get a completely different solution.

Thanks Airy. Your feedback is VERY much appreciated! (Without it I would have been sitting here and waiting for an answer)... :slight_smile:
Will retry now.

On a website like this, never hold your breath, as some of the people here live in time zones on the other side of the world.

1 Like

Saving info PFUA



Copy all info (Title, Artist etc), Search for song name+ artist in Safari Wikipedia, fix what needs to and go bk 2 music and paste it there..kmmacros (31.6 KB)
Supp1 for "Copy all info (Title, Artist etc), Search for song name+ artist in Safari Wikipedia, fix what needs to and go bk 2 music and paste it there. copy.kmmacros (8.2 KB)

OK, this time I found the instructions in the wiki and uploaded the macros and the images.
As I said, thanks a lot for your help.
Saul

1 Like

I'm looking at your macros now. I see the second macro simply helps the user do a web search and then waits for the confirmation that the user is ready to proceed then gets the user to enter new values. So far, I understand that. Now I'm looking at the first macro.

Now I'm looking at the first macro. Okay, it's just fetching data from the Music app into your variables. Check. However I will say that this macro looks like it's dependent on a certain version of macOS or its Music app. I don't think it will work for me because the tab stops appear to be different.

I'm now looking at your question. Okay, you just want to put the data back into the Music app. Not a problem. Hmm, at this point I'm always asking myself, do I inform the questioner about better ways of doing this, or just help them with the way they have chosen. I think I'll just help you with your chosen way, because I want you to succeed using your own method.

Basically, all you have to do is the same kind of thing you did in your first macro. You will activate the Music app, select the correct fields, probably by tabbing, and paste the new values into the old fields. Then you will press the OK button. I think that's about it. But remember, my version of Music appears to be different from yours, so I can't actually write the code that will work for you. What I will do is outline the solution for you, as I see it. I'm summarizing it in English. If there's something you don't understand, ask me.

  1. Create a third macro called Save Data.
  2. Add an action that will "Activate Music"
  3. Since the original Music dialog box appears to still be open (you didn't close it) you can simply click the mouse in the first box (the title box) and then use the "Type a Key" action to press CMD-A which will select all the text in that box.
  4. Then you use the action "Insert text by pasting" using the variable "MussicTitle"
  5. Then you use the action "Type Tab Key". Then you will be in there Artist box, and the text will already be selected, so you can skip the CMD-A action, and just paste the next string that you saved. Then you can press Tab TWICE because you have skipped the "Album" field.
  6. I think this will work with the remaining fields, but you will have to Tab appropriately.
  7. Then to close the window, use the action "Type Return Key"

That should be it. Based on what you've achieved so far, I suspect you can write this. But if not, ask questions, and if you're totally stuck, I may write it for you.

Should you succeed, you will be very pleased with yourself for solving this. However you then may be a little surprised that there are slightly easier approaches. I think it may be possible to reduce the number of actions by 50% or 75%.

1 Like

Hello Airy.
First let me tell you that I am SO impressed and appreciative of your reply!!!
I want to thank you for the time you took and for your efforts to make it clear and understandable!!! (And you certainly did!)

Sorry, forgot to mention one of the most important pieces of info: I am using a 15” 2019 MBP (MacBook Pro) with macOS Sonoma 14.1.1, Music ver 1.4.1.29 and KM ver 11.0.1.

This is my problem. I can manually input the new/changed info in the prompt for input dialog, (pic # 2) but don’t find a way to save it to the corresponding variables. (If I do that and hit “OK” the new/changed info is not saved and the variables carry the same old uncorrected info).

OK, I see that I didn’t explain myself properly.

I said “(…The macro goes on and I figured how to finish it, just missing this piece, where I want to change the info manually and save it then to the variables, so I stopped the macro at this point in my post)…”
I wanted to focus on the problem, so I cut the macro. I guess it was just confusing.
What I will do now: I will upload the 2nd FULL/UNCUT macro. Sorry for the inconvenience.
(There is even a 3rd macro that I DIDN’T FINISH YET. I will upload it too, maybe to check how it can be done the right way if I already made mistakes)…

The opposite! You are just answering a question I didn’t ask (yet)… :grinning:
Please do enlighten me! I will be more than happy to learn a bit (or a lot) more how to do things more efficiently/elegant.

Again, thanks a lot for your time and wonderful will to help me!!!
Saul

This is a great macro for this type of info. Here is the output for mine and I don't even have to go look for it:

Model Name: Mac mini
Model Identifier: Mac14,12
Model Number: Z170000G5LL/A
Total Number of Cores: 12 (8 performance and 4 efficiency)
Memory: 32 GB
System Firmware Version: 10151.41.12
OS Loader Version: 8422.141.2.700.1
Chipset Model: Apple M2 Pro
Total Number of Cores: 19
System Version: macOS 13.6.1 (22G313)
Kernel Version: Darwin 22.6.0
System Integrity Protection: Enabled
Time since boot: 2 days, 3 hours, 48 minutes

iirc, there may be something similar for currently-running App version info etc., but this one surfaces quite a bit of useful info as it is.

Thanks cfriend. Will take a look once I'm done with this one. :grinning:


Supp1 for "Copy all info (Title, Artist etc), Search for song name+ artist in Safari Wikipedia, fix what needs to and go bk 2 music and paste it there.kmmacros (29.8 KB)

Supp2- Check about lyrics and artwork for "Copy all info (Title, Artist etc), Search for song name+ artist in Safari Wikipedia, fix what needs to and go bk 2 music and paste it there.kmmacros (18.2 KB)

OK, uploaded the full macros. What I just realized is that supp1 gets stuck in the "Pause until the key F2 is down" action

One issue I see is that you don't want the ResultButton variable, but rather the text that is %PromptButton%, as explained in the wiki:

The %PromptButton% token (v8+) is set to the name of the button pressed, and can be used in actions later in this instance like any other text token.

https://wiki.keyboardmaestro.com/action/Prompt_for_User_Input?s[]=promptbutton

-rob.

Oh. I understand what you mean now. In my defence, the part you didn't upload originally was the part that contained the problem.

I tested pressing CMD-N instead of pressing OK and I agree it doesn't save that way. That's odd. That's not what I would expect either.

So in a way your question is "why does CMD-N not save data in the Music App." You want the Music App to behave differently. But the real question is how can we make KM do what we want when an App is doing something we don't want. That's easy. You simply have your KM macro press the OK button and then have KM move to the next song.

It looks to me like if you replace "Type CMD-N" with "Type Return, Type Down-Arrow, Type CMD-I", you will achieve the same result. I think that's your quickest solution.

KM is not a tool that can make a program (like Music) change its own internal behaviour. Instead, KM can work around bad programming by letting you perform workarounds, such as I have proposed above.

Try that, and see if it works. I think it will work.

Once you get it working, perhaps we can discuss streamlining or different approaches.

Will do! Thx!

I'm sorry and apologize if I'm "giving you a hard time" :blush: but that's not the question. I don't want the app to behave differently either.

I will start with the “easier part”: in the Music app (that I’m working with) it doesn’t matter what I press CMD-N or OK. Both of them save the changed info.
The only difference is that CMD-N saves and moves to the next song and OK saves and goes back to the playlist (out of the info tab, then you need the additional Type Return, Type Down-Arrow, Type CMD-I).
I went to a random song that the composer field was empty. Wrote Airy (nothing personal)… :blush: pressed OK and when I pressed on CMD-I again the composer was Airy.
Then I changed it to Griffman (nothing personal)… :blush: and pressed CMD-N. Moved to the next song and hit cancel and then again, went back to the same song and the composer was Griffman, meaning it saved the info.

But, again, the problem I need to solve is way earlier: how to save the new/changed info and then paste it back to the original info.
Let me try to find an easier way to explain it. It may take me a while but I'll be back...

I am doing my best to understand. I would understand if you feel frustrated by my failings. But I never give up, and never surrender.

The way I read your macro, you extract the data from the Music Pane, you place that data into a dialog box, you let the user change the data, then you paste each line of the new data back into the Music app. From the looks of it, you are doing everything right.

I know you said you were going to rewrite your question, but I reread your post. You said "you just realized the Pause until F2 action is down is where your program gets stuck." If that's the cause of your program failing, it could be because your Mac is set up to require that you press the FN/GLOBE key in combination with the F2 button. From where I stand, that could be your issue. There are several ways to fix that, but maybe the simplest is to change the key from "F2" to "End", which kinda makes more sense anyway. (But waiting for a key to be pressed is a bad idea, unless it's the Shift key, which doesn't trigger any actions.)

But again, this could be another failed attempt to diagnose your problem. And I'm worried that you could fire me for all my failings.

OK, so, I’d like to clarify some things before we “get to the point”…
1-

Trying to understand and not succeeding failing.
Not trying to understand = failing.
2-

a- Read 1
b-You’ve earned the “for life winner position” in my posts. :blush: Why?|

That’s enough for me.

Now, let’s try one more time:

Yes, that's what I WANT to do: paste each line of the new data back into the Music app.
Now, let;s go back to the very beginning, pic # 1. As you can see the fields "composer" and "year" are empty.
I'd like to "fix" it and write Johny as the composer and year 2019 (as in new pic # 3 now) and that's fine, I can go into the text fields and do that just fine.
And here is the problem, next thing I need to do is get this info (the old+ the new/changed) into the corresponding variables. Meaning at THIS STAGE I need to copy the current info, from EACH field, set their variables to text %CurrentClipboard%, so I will be able in the next step to paste them ("Insert Text %Variable%Whatever% by Pasting").
But I have no way of doing THAT (copying the info) and if I hit "OK" all variables contain only the older info.
I hope this time I explained myself properly. If not, plz tell me and we'll try another way till we succeed.
BTW, we can delete or disable the "pause till F2 is pressed" is something I wanted to try but didn't work and is not necessary for the macro, as well as all the rest of the actions until "Activate Music". I assumed that I will be able to pass the changes to the variables and those will be updated.

Maybe I understand now, or maybe I don't. Let's try again. I'm 80% sure I've spotted the problem. When you are pasting the text back into the Music App, you are using the wrong variables names! The "Prompt for User Input" action which you successfully used is storing the data in variables by the names of "Title", "Artist", etc., while you are pasting other variables by the names of "MusicTitle", "MusicArtist", etc into the Music App.

I think the reason you did this incorrectly is because you thought that the names of the variables where the data was saved are in the right hand side of the Prompt action, when actually they are on the left hand side. Look above them, and it says "Variables and Default values." That means the variables are on the left and the default values are on the right.

Of course, there's a 20% chance I'm wrong. As always.

1 Like

Airy!!!
YOU-DID-IT!!!!!
Changed the names to the variables and... voilà.
I TAKE MY HAT OFF TO YOU!!!


Wowwww!!! I'm so happyyyyyyy!!!!! :person_raising_hand: :laughing:
THANKS A LOT!!!!

1 Like