Mac Can't stop an Applescript with Automator

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
Hello,

I'm new here, thanks to accept me and please apologize my rude english.

I have made an AppleScript with Automator which allows me to run a Canon software (Eos Utility) and a Python Script.
I saved that flow as an application so I can open it with a session and let it run.

It works, I am an happy man...

Not exactly because I want to allow the computer (a macmini 10.6.8) to take some rest.

So I tried to make an Ical Alarm with Automator : I saved my actions : stop Eos Utility and stop the previous script (the one working as an app). But each time I have an error message and that second script refuses to kill the previous one.
It accepts to stop Eos Utility but then refuses to go forward.

Dear membersn have you got any idea ?

Thanks so much
 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
Dear membersn have you got any idea ?

Thanks so much
Please post the code from your script, the actions used in your workflow and the exact error message it produces. You can attach screenshots to your posts so make use of it. Right now it's just a guessing game in trying to figure out exactly what you're trying to do and why it doesn't work.
 

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
Thanks for your answer.

HEre is a link for the script i've made (it's all in french, do you want me to translate ?)



Here is the message of the error



Thanks for helping
 

chown33

Moderator
Staff member
Aug 9, 2009
8,423
4,425
Pale blue comma
Instead of translating, here's how to force Automator to use English.

1. Quit Automator.
2. Launch System Preferences.
3. Click the "Language and Text" pane.
4. Click the "Language" sub-pane if necessary.
5. Observe a list of languages appears.
6. Drag "English" to the top of the list.
7. Launch Automator.
8. Observe that menus, etc. are in English.

Now you can remake your screenshots.

The primary language choice persists in the logged-in account until you change it. This means you can make an account, set the language to English, and whenever you login or fast-switch to that account, the Finder and all the apps run in that account will use English. In the past, I've used this trick to set up a language-specific account, usually for testing localized versions of an app I'm working on.
 

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
thanks Chown33

Well it's not completely translated

Here is the workflow and the message

I've translated (in red) where the problems occurs : when the script has to stop the previous script which is running as an application

Thanks


 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
I'm going to answer in English, my French is a bit rusty.
The Watch Me Do action in Automator is a PITA to use/debug and error prone as you have noticed by your error. I personally have never used it and would advise you to do the same. Some things you've recorded have an equivalent Automator action. Only the first step in the action eg clicking the Stop button from the EOS Utility poses a minor problem which can be solved by using AppleScript and System Events.

  • Quitter EOS Utility and Fading_DEF --> Quit Application action
  • Next two Finder things are unclear what you're doing.
  • Simulating keystrokes can be done with AppleScript and System Events
  • Emptying the trash can be done with AppleScript
  • Éteindre(is that sleep or shutdown?) can be done with AppleScript and System Events

I think anything you've recorded can be done in a Run Applescript action.
Is the EOS Utility a free application I can download so I can take a look at it?
Note : I don't own a Canon EOS DSLR.
 

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
Thanks very much Kryten

But if I had to try a watch-to-do process it's because the automator usual actions didn't want to work correctly and to stop the previous script.

When Eos Utility is running (in my Script1) I have to stop it before quiting the application that why it needs a watch-to-do action

I'm gonna try the way you suggest but I don't know how to stimulate "keystrokes" with AppleScript... could you a little more explicite

Thanks very much again
 

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
I've tried this




But the action "Quit Eos" is not working because Eos Utility is running... that why I've tried a watch-to-do action

 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
Thanks very much Kryten

But if I had to try a watch-to-do process it's because the automator usual actions didn't want to work correctly and to stop the previous script.

When Eos Utility is running (in my Script1) I have to stop it before quiting the application that why it needs a watch-to-do action

I'm gonna try the way you suggest but I don't know how to stimulate "keystrokes" with AppleScript... could you a little more explicite

Thanks very much again
Here's an example how to simulate keystroke a using command down in the Finder :

Code:
activate application "Finder"
tell application "System Events"
	tell process "Finder"
		keystroke "a" using command down
	end tell
end tell
Is there any equivalent key combination in the menu of the EOS Utility software for Cliquez sur le button Arrêt? If so what is it?
 
Last edited:

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
I really appreciate your help, thanks

I'll try that in a couple of hours but I'm not sure that I can stop the Eos Utility process with a keystroke

Here is a second screenshot

 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
I really appreciate your help, thanks

I'll try that in a couple of hours but I'm not sure that I can stop the Eos Utility process with a keystroke
Is there any chance I can get that Timer shooting status window without having a Canon DSLR? Probably not so let's take another approach, with little steps one step at a time. Start with a new new workflow(not an iCal alarm!) in Automator with the following actions :

Watch Me Do action with one Event : Cliquez sur le bouton arrêt
Quit Application action : EOS Utility --> uncheck Ask to save changes!
Run Applescript action with the following statement in :
Code:
tell application "nameofyourapp" to quit
Remove any existing code from the action eg on run ... end run!
Replace "nameofyourapp" with the name of your application you're trying to quit. Looking at one of your screenshots I think that would be Fading_DEF.

Do your stuff with EOS Utility, start your application and run the workflow

Note : Why is your first action always Launch Application Automator? It is not needed. You can attach the screenshots directly to your post. No need to upload them to Noelshack.com.
 
Last edited:

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
[sorry but when I want to insert a picture in the message, it asks me an url]

For a weird reason whenever I want to ask automator to quit "Eos Utility" the workflow is been interrupted...

As you can see I have tried several ways to quit Eos Utility : with the "Quit application" action, with your special script, with a watch-to-do action

But what is very strange is that actually Eos Utility is quitted (no more blue spot in the dock, and it no longer appears as working)

So I don't understant... Maybe a bug...

And of course because Eos Utility is supposed to be working, Mac Os refuses to shut down (which is what I want)

I've tried the workflow you mentionned. I think I need an Ical alarm because that process should be working every night by itself. So I though my first action should be to launch automator:confused:

Thanks

----------

Here are the screenshots ! sorry I can't attach them directly



 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
Good. I see we're making some progress in your screenshots and you've even put in a Run Applescript action telling the system to shut down. Have you searched for EOS Utility canceled shut down? Can you try this to quit EOS Utility?

Code:
tell application "System Events"
	set the processID to get unix id of every process whose name is "EOS Utility"
end tell
do shell script "kill -9 " & quoted form of processID
tell application "System Events" to shut down

------Another way------------------------

(*
tell application "System Events"
	set processName to name of every process whose name is "EOS Utility"
end tell
do shell script "killall " & quoted form of processName
tell application "System Events" to shut down
*)

------To get the name of every process---------

(*
tell application "System Events"
	name of every process
end tell
*)
 

Attachments

Last edited:

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
Thanks for your answers.

I don't know why but your applescripts don't work

I thing I need what-to-do actions for that Eos Utility.

It works like this. I've added a 10 seconds pause because otherwise for a strange reason it says that Eos Utility canceled shut down (but Eos Utility is supposed to have been already quitted !)

Anyway : a last problem each time I want to shut down the mac, now it asks me if I want to save the script.
What shall I do ?

Thanks again for your help
 

Attachments

chown33

Moderator
Staff member
Aug 9, 2009
8,423
4,425
Pale blue comma
I think you need to take a step back and find out exactly how to terminate Eos Utility. That appears to be the obstacle here.

Do the following:
1. Launch Eos Utility.
2. Copy and paste this exact command-line into a Terminal.app window:
killall -s -m "eos"
3. There should ba at least one line of output. If not, post that fact.
4. Copy and paste the line of output, and post it here. (It's text, so you can copy and paste it as text, rather than posting a screenshot).

Once you've done the above, I can give additional Terminal commands to test.


The goal of this process is to learn two things:
1. To discover exactly how Eos Utility responds to the signals that should tell it to quit.
2. If Eos Utility doesn't respond to signals, or does so in a way that's blocking shutdown, then to discover what other commands will have to come into play, and to see how those work.

Depending on what the actual observed responses are to signals or other mechanisms, an alternative plan may need to be developed. The first thing is to learn exactly how it responds in an unscripted situation. Once that's known, we can put the known-good command into a script. But without knowing exactly what to put into the script, attempts at scripting are premature.

It may turn out that Eos Utility simply isn't amenable to any signals or attempts at sending it AppleEvents. That would be unfortunate, but at least we would have gone through all the possibilities while focusing on the direct problem (quitting Eos Utility), without having to write a script that may or may not contain the correct scripting commands.
 

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
Thanks !

I'm gonna try this right know but just want to tell I managed to quit Eos Utility with a "watch-to-do" action
It works
But still I can't shut down the computer...
I'm coming back

----------

here is the terminal answer

~ admin$ killall -s -m "eos"
No matching processes belonging to you were found
 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
Thanks for your answers.

I don't know why but your applescripts don't work

I thing I need what-to-do actions for that Eos Utility.

It works like this. I've added a 10 seconds pause because otherwise for a strange reason it says that Eos Utility canceled shut down (but Eos Utility is supposed to have been already quitted !)

Anyway : a last problem each time I want to shut down the mac, now it asks me if I want to save the script.
What shall I do ?

Thanks again for your help
Your workflow reached the end and the last action is to shutdown the system. Because Automator is still open the system ask if you want to save your workflow before it shuts down. Seems logical to me. If everything works it's time to test that iCal alarm. Remember I don't have the EOS Utility to work with so I'm taking a wild guess that it is in fact called EOS Utility. You can check the name with this :

Code:
tell application "System Events"
	name of every process
end tell
Run this in the AppleScript Editor while EOS Utility is running, NOT in Automator and post the output of the result pane.
 

Niouky

macrumors newbie
Original poster
Apr 17, 2014
10
0
HEllo


There was no result when I tried

Code:
tell application "System Events"
	name of every process
end tell
But maybe I didn't know exactly what I was supposed to do.
Run this in the AppleScript Editor while EOS Utility is running, NOT in Automator
Anyway, finally I've found a script that allows to shut down the computer

Code:
on run

  do shell script "shutdown -h now" user name "your_user_name" password "your_password" with administrator privileges

end run
So now, I think it's working :

1/ On login, Script1 is running

2/ I've made an Ical event that will run the "killing script" every night.

Need a few more tests, but it's in the right way

Thanks very much for your help