Jump to content

Applescript not working


Recommended Posts

Hi 

I've been moving all my hotkeys over to V2. I can get all the apps and files to open OK, but none of my Applescripts are working.

 

(Three of my applescripts do stuff in Mail for the currently selected email, and one other launches app Minuteur and passes a number to it).

 

I've tried both

     run script  with  usr/bin/osascript selected

and

     run NSapplescript

 

What do I have to do ?

 

thanks

k

 

 

Link to comment

Hi 

I've been moving all my hotkeys over to V2. I can get all the apps and files to open OK, but none of my Applescripts are working.

 

(Three of my applescripts do stuff in Mail for the currently selected email, and one other launches app Minuteur and passes a number to it).

 

I've tried both

     run script  with  usr/bin/osascript selected

and

     run NSapplescript

 

What do I have to do ?

 

thanks

k

 

Could you post an example workflow which isn't working then I can take a look :)

 

Cheers,

Andrew

Link to comment

Andrew

 

Here's the shortest one - it starts the timer app to countdown 10 minutes.  In Alfred 1 I use Shift-F8 to activate

 

 

tell application "Minuteur"

activate (StartCountdown 1000)

end tell

 

 

And here's a Mail one to move selected emails to my Done folder.   In Alfred 1 I use Shift-F2 to activate

 

 

 

tell application "Mail"

set s to selection

repeat with eachMessage in s

set read status of eachMessage to true

move eachMessage to mailbox "Done"

end repeat

end tell

 

So there's not much happening in them.  I'm running os 10.7.5  Alfred V2.0.2(178)

 

 

 

thanks 

Link to comment

Andrew

 

Here's the shortest one - it starts the timer app to countdown 10 minutes.  In Alfred 1 I use Shift-F8 to activate

 

 

tell application "Minuteur"

activate (StartCountdown 1000)

end tell

 

 

And here's a Mail one to move selected emails to my Done folder.   In Alfred 1 I use Shift-F2 to activate

 

 

 

tell application "Mail"

set s to selection

repeat with eachMessage in s

set read status of eachMessage to true

move eachMessage to mailbox "Done"

end repeat

end tell

 

So there's not much happening in them.  I'm running os 10.7.5  Alfred V2.0.2(178)

 

 

 

thanks 

 

Unsure if this is your issue as well but the mail AppleScript didn't work for me without specifying the account as well. So, in my case I had to modify your script to say...

tell application "Mail"
set s to selection
repeat with eachMessage in s
set read status of eachMessage to true
move eachMessage to mailbox "Done" of the first account
end repeat
end tell

Obviously the "first account" would vary depending on what accounts you have.

Link to comment

David

 

You're probably right but the script has worked fine for me in Alfred 1 for years.  The other script, which launches Minuteur, is so simple and just nothing happens.

 

I'm looking for help to make it run at all. Starting from pressing the circle with a plus in it in Workflow. Do I use Action ? Output?   and what sub options within those selections.

 

Thanks

 

K

Edited by kazza
Link to comment

David

 

You're probably right but the script has worked fine for me in Alfred 1 for years.  The other script, which launches Minuteur, is so simple and just nothing happens.

 

I'm looking for help to make it run at all. Starting from pressing the circle with a plus in it in Workflow. Do I use Action ? Output?   and what sub options within those selections.

 

Thanks

 

K

 

Let's try this...

 

For launching Minuteur, you won't actually need AppleScript, this could be done a little easier. So, on the left side of the Workflows area, you have a list of installed/available workflows. At the bottom of that list, there is a +, click it, select Templates->Files and Apps->Launch File group from hotkey. Double click the hotkey item to set your desired hotkey for actioning this workflow, then Save. Double click the Launch Apps/Files item and then drag and drop Minuteur into the list. To speed up this a bit, just pop up Alfred, search for Minuteur. Click and drag Minuteur from the results list and drop it in the Launch list in the background. Save that piece and then test it out with your new hotkey.

 

As for the other action, I'm not sure how it worked before and doesn't work now. As mentioned, I tried your code alone (outside of Alfred) in AppleScript Editor and was getting errors. After specifying which account that mailbox was in, it began working normally. To recreate this item, you can add another piece to the new workflow you just created, or, you can create another new workflow to continue. If you create a new one, click the plus in the left list again and select a "Blank Workflow" to get started.

 

Once you have your new workflow, or are ready to create it in the previously mentioned workflow area, click the + in the top right of the workflow area. Select Trigger->Hotkey. Then, click the + again and select Actions->Run Script. Once again, double click the Hotkey to set it, and then save. After that, double click the Run Script item. Set your language to /usr/bin/osascript and paste in the AppleScript code for the Mail action. Be sure to use the updated code I provided to you, with the correct account specified. When you are done with that, save the Run Script item. The next step is important. You must connect the Hotkey to the Run Script item. Select the Hotkey, then move to the right edge of it. A little tab should appear on the right edge. Click it and drag it to the Run Script item to connect the pieces together. This tells Alfred to execute <this> when the hotkey is pressed. See example below.

 

Alfred-ConnectItems.gif

 

Let me know if you have any other questions. 

Link to comment

David

 

D'uh ! I've just realised what I was doing wrong.... instead of putting the actual script in I just had the full path to the script....the same as when you run an app or file.... Yes, now I see that it says "Script" but it didnt occur to me when I set it up. I first did all the apps and files so it made sense to me at the time.

 

All sorted now.... thanks for you help.

 

cheers

K

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...