Opening File One a A Time Then closing the App

Hi I just want to ask can anyone give me some times on how to execture a macros where it opens a file on a specific app then closes the app after.

The idea is i have an app called Claquette.

I want it to do the following:
Look in folder for all files with .claquette filename

open up the claquette program for each file.

Export the file into the same folder as Prores

Close the program down

Go to the next one.

Look in folder for all files with .claquette filename

open up the claquette program for each file.

Export the file into the same folder as Prores

Close the program down

  • Type a Keystroke: Command-W or Command-Q

Continuing the discussion from Opening File One a A Time Then closing the App:

HI!!! THANKS FOR THE RESPONSE

I manage to make one but the problem now is that I have set it up so that when it goes to the screen where you choose the directory to export i followed your earlier advice on using COMMAND SHIFT G then Pause then insert in the text to the directory...

The problem is that if I put multiple files in a folder what happens is that for some weird reason when it comes to the part where COMMAND SHIFT G happens and insert text. it inserted the path twice??? Here is my macro.

When Claquette File is In folder.kmmacros (33.6 KB)

I was wondering what could be wrong.

I don't know why the text would be inserted twice, but you don't want to type the full path of the file anyway.

Presumably the app automatically sets the file name and file extension when you select the ProRes export, right? If you specify the full path, including the name of the source file, then you will end up overwriting that.

Instead, just specify the target directory, which in this case is just ~/Desktop.

Hi Sir Peter. Yeah I tried your suggestion and still for some reason it attachces or types 2 instances of ~Desktop

When Claquette File is In folder.kmmacros (33.5 KB)

Here is the macro I got now :confused:
Also here is a video on what happens if i put multiple files. HELP!

https://youtu.be/52z6hccgNPU

I want it to work with multiple files but this error happens... :frowning: Thanks for your assistance

The problem is your trigger.

You are triggering this macro every time a file is added to the Desktop folder. And your macro adds a file to the desktop folder, triggering a second copy of your macro to run simultaneously, and when you create a third file, you’ll have three copies of your macro running.

Either trigger the folder manually and process the whole folder, or trigger it when a file is added and only process that one file. Don’t do both.

Hi Sir Peter, managed to circumvent that now thanks :smile:
The problem now is that for some reason it processes the first file but it sometimes stops or failes after it and never proceed to the second one?

I forgot to mention I set it now to a hot key trigger instead of a folder trigger.

We can't guess what the "some reason" might be without more information.

Is there a notification of an error, anything in the Engine.log file for example?

where can I find the engine.log file?

I’ll report back when it happens again thanks sir Peter for the help :slight_smile: LOVE THE SUPPORT

Sincerely,

Ken

Hi Sir Peter is their a way to pause this process so that it can wait until it finishes rendering before moving to the next step?

Use the Pause Until action.

Its possible you can pause until a menu becauses enabled (for example, the Export menu or other menu items may be disabled while the export is in progress). Otherwise you will have to use Pause Until with the Found Image condition to pause while the image is on the screen.

Hey Keane,

Please don’t post remote images.

https://wiki.keyboardmaestro.com/Forum?&#Sharing_Images_and_Macro_Files_on_the_Forum

An alternative to Peter’s suggestion is to use AppleScript and System Events – IF it can see that dialog (or sheet).

-Chris

Chris, sorry, I think I broke your URL with my latest update of the wiki.
The link would now be:
How to Post/Upload Your Macro to the Forum

https://wiki.keyboardmaestro.com/Forum?&#How_to_PostUpload_Your_Macro_to_the_Forum

Ok thanks, will keep in mind when it comes to sharing images and macros

Hi Sir Peter.

Can you give me some help on making an apple script that
opens the system preferences
Goes to Desktop & Screen Saver
then goes to the Screen Saver Tab
Then sets the Drop down STart after to Never
then goes back to the main system preferences
selects energy Saver
then check the prevent the computer from sleeping checkbox
and then close system preferences

Ask in a new topic.

But don't ask specifically me, because there are many people here who know way more AppleScript that me.

Also, as a general rule, don't specify the "how" of what you want to do (AppleScript), worry only about what you actually want to do and why - there may be a much better way to do it, or a completely different way to solve your problem.

For example, in this case, you want to disable the screen saver and sleeping. It's likely that you can do that using the caffinate utility more effectively, but you haven't described what you want to do and why.

But always start a new topic for a new question unless it is well related to the existing question.

If you have an AppleScript question that does not involve KM, you may want to post your question at http://macscripter.net/ .

We do have some great AppleScript gurus here, but you might get a quicker and more diverse response there.

As Peter suggested, you will get the best results if you will:

  • State the objective of your script/macro
  • Post questions on a new subject in a new topic.

In addition, you might:

  • Post the script/macro you have tried to write, and be specific about what problems you are having.
  • Do your homework. A google of "AppleScript" and whatever the main action you are trying to use will often give immediate results.
  • For example, in your case, I'd google "AppleScript system preferences"
  • I just did this, and found quite a few hits that look promising

Hey Keane,

That's about a half hour job (or more) for someone not readily familiar with scripting the system preferences.

For that matter you DON'T want to use System Events to UI-Script the prefs.

This will set the start time of the screen saver to none:

tell application "System Preferences" to if running then quit

tell application "System Events"
  tell screen saver preferences to set its delay interval to 0
end tell

The following shell script will set the sleep interval to “never”.

sudo pmset sleep 0

You can make this run without having to enter your password by adjusting your sudoers file.

(I haven't done this, so you'll have to research it yourself.)

If you're willing to enter your username and password in a script then you can combine the above by running this AppleScript:

tell application "System Preferences" to if running then quit

tell application "System Events"
  tell screen saver preferences to set its delay interval to 0
end tell

do shell script "sudo pmset sleep 0" user name "yourUserName" password "yourPassword;" with administrator privileges

This trounces sluggish GUI-Scripting.

References for Learning and Using Applescript

See in particular the Online Applescript Communities section.

For more than you want to know see:

Learning & Using AppleScript & JavaScript for Automation (JXA)

-Chris