Jump to content
Sign in to follow this  
kazza

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

 

 

Share this post


Link to post

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

Share this post


Link to post

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 

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

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. 

Share this post


Link to post

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
×
×
  • Create New...