Hello I'm trying to build a very simple Automator service to automatically turn on Auto Loop within a Keynote document. I'm not a very familiar with AppleScript, but I have used it a few times to do minor things. I'm gettin the following error when using this script within an automator service:
Synatax Error
"Can’t set «class aulp» to true."
Im sure it is something very obvious, but I'm not that well versed in AppleScript. Any help would be greatly appreciated.
Here is the script
on run {input}
set thisDocument to input
tell application "Keynote"
tell thisDocument
set auto loop to true
save thisDocument
end tell
end tell
end run
Related
I am trying to move from using Evernote to apple note.
One function that I am missing is from the print menu on a mac to be able to save the PDF to a new note.
I figured that I can create a print_plugin from Automator. I am trying to have an apple script handling the creation of a new note. Googling and using my limited knowledge of apple script I figured that I need to do something like
property accountName : "iCloud"
on run {input, parameters}
tell application "Preview"
open input
end tell
tell application "Notes"
activate
set theFolder to choose from list ((name of folders of account accountName) as list)
if theFolder is not false then
set newNote to make new note in folder (item 1 of theFolder) of account accountName
if input is not {} then
tell newNote
make new attachment with input
show
end tell
end if
end if
end tell
end run
The preview part of the code is to see if the pdf is passed correctly. Preview can indeed open the pdf correctly.
When I run the script I get the following error
The action “Run AppleScript” encountered an error: “Notes got an error: Can’t make show id "x-coredata://726D28C7-1847-43DA-9A8D-A9A1B379DF6F/ICNote/p6780" into type specifier.”
Notes got an error: Can’t make show id "x-coredata://726D28C7-1847-43DA-9A8D-A9A1B379DF6F/ICNote/p6780" into type specifier
If I remove the line
make new attachment with input
the script runs without error (but clearly no attachment is created).
Does anyone have a solution?
Best,
E
Ok, after a lot of meddling I found this sort of solution:
property accountName : "iCloud"
on run {input, parameters}
tell application "Notes"
open input
end tell
end run
When saved as a print plugin, it creates a new note with the title of the webpage and the pdf attached. It creates it in the "Notes" folder, which works fine for me.
Best,
E
I have found the applescript code on internet, to start a terminal and launch Elasticsearch
the code is
tell app "Terminal"
do script "elasticsearch-5.5.0/bin/./elasticsearch"
end tell
It works fine,
now I want to add more stuff on it, I need to open 4 more new tab not new window just tab (command + T). and then run different command such as log tail command, start kibana like one after another in each tab.
I am new to applescript and got tired by searching samples and tutorials, can anyone suggest a solution or your idea to achieve the automation.
Terminal's scripting dictionary isn't very good — a lot of 'Apple Event Handler Failed' errors — but you can manage it with code like the following:
tell application "Terminal" to activate
my makeTab("ls -al")
my makeTab("top")
my makeTab("cd ~/Documents")
on makeTab(cmd)
tell application "System Events" to keystroke "t" using {command down}
tell application "Terminal"
do script cmd in last tab of front window
end tell
delay 0.2
end makeTab
Just put whatever commands you want run inside the makeTab() call.
I'm new to AppleScript and I'm trying to make a simple AppleScript that will pop-up a dialog asking for user input and based on the input it will open one application or another. To do this I've used:
tell application "atom"
activate
end tell
One of the applications is stored on an external hard drive called Tardis. The problem with my code below is that it automatically opens Atom every time I run the script AND the dialog window at the same time. I only want it to open Atom when the input a is given. Thanks for the help! Code is below:
on run {input, parameters}
set inputText to text returned of (display dialog "Options: p - a - j" default answer "")
set p to "p"
set a to "a"
set j to "j"
if (inputText = p) then
tell application "Terminal"
if it is running then
do script "cd Python_Workspace; source ~/tensorflow/bin/activate"
end if
activate
end tell
tell application "Finder" to open POSIX file "/Volumes/Tardis/EXTRA Applications/Sublime Text.app"
end if
if (inputText = a) then
tell application "Atom"
activate
end tell
tell application "Terminal"
if it is running then
do script ""
end if
activate
end tell
end if
if (inputText = j) then
tell application "Terminal"
if it is running then
do script "cd /Java_Workspace"
end if
activate
end tell
tell application "IntelliJ IDEA CE"
activate
end tell
end if
return input
end run
So some applications that support Applescript do - or did, require the application to launch to compile the Applescript at all (if I remember correctly these are applications that support Applescript poorly, which I'm betting is Atom).
This may not be exactly what's happening, especially since if you are launching a compiled Applescript, but maybe you are running a .applescript (text) file.
What I would do, instead of tell application "Atom" to activate (a one line version of what you have), instead: activate application "Atom".
If that does work for you, activate vs tell here's what's going on:
Applescript notices you're talking about Atom. It needs a dictionary to translate your typing into... events.
Applecript can't find the dictionary, so it launches the application, hoping that it can get more information from it when it launches
Atom launches, Applescript realizes that every application supports activate.
Where activate application you're not trying to do anything Atom specific... just activate an app. No dictionary lookup required.
(It's also worth noting that I've been doing this a very long time. I could actually be quoting you information that's a decade or more out of date, or "new" in 10.4 - not 10.14, but 10.4)
I've made my first apple script (with a bit of help).
It works fine:
delay 5
tell application "SelfControl"
activate
end tell
tell application "System Events"
tell process "SelfControl"
click button "Start" of window 1
end tell
end tell
This was running inside applescript. Now I'm trying to run it as an application, So I've added the line
on run {input, parameters}
[at the top]
and the lines
return input
end run
[at the bottom]
and then exported as an application. however I get the error
"current application doesn’t match the parameters {input, parameters} for run." when I try to run.
Any advice?
What use do you have of these parameters in your code?
How are you going to give them as an input and receive the output?
When I exported AppleScript codes as applications, I didn't add these lines and they worked completely fine. Just try to export without them!
The on run handler with parameters belongs to the Automator AppleScript action.
Every script / application script provides an implicit on run handler (without parameters) and without return value.
on run
...
end run
This handler is only needed explicitly if other basic handlers like on idle or on open are specified, too. In all other cases just omit it.
Good morning,
I am trying to write an AppleScript that I can run that will send all the files on my desktop to Evernote, and then delete the files. My code to date is:
on run {input}
tell application "Finder"
select every file of desktop
end tell
tell application "Evernote"
repeat with SelectedFile in input
try
create note from file SelectedFile notebook "Auto Import"
end try
end repeat
end tell
tell application "Finder"
delete every file of desktop
end tell
end run
If I run this then the first and last 'tell' work fine (ie. the script highlights then deletes all the files on the desktop), but the middle 'tell' doesn't do anything.
However, if I manually highlight all the files on the desktop and then run just the middle 'tell' then it imports fine - each item into a separate note as intended.
As you can tell, I am new to AppleScript - I suspect I need to put the selected files in an array of some sort, but can't figure it out. Help!
Many thanks
Rich
Your code fails because there is no relation between your input variable and the selection of files via Finder – which means that your list is empty, and Evernote is not processing anything at all. You have obfuscated the problem by wrapping the Evernote import command in a try block without any error processing, which means all errors just go unnoticed (to avoid this kind of problem, it is good practice to always log the error message in an on error clause, if nothing else).
Also, you don’t actually need to select files on the Desktop via AppleScript to process them. The following code will grab all visible files (excluding pseudo-files like packages / apps):
tell application "System Events"
set desktopFiles to every disk item of (desktop folder of user domain) whose visible is true and class is file
end tell
Pass the list you retrieved that way to Evernote for processing:
repeat with aFile in desktopFiles as list
try
tell application "Evernote" to create note from file (aFile as alias) notebook "Auto Import"
tell application "System Events" to delete aFile
on error errorMessage
log errorMessage
end try
end repeat
and you are good to go.
Note that by judiciously placing the deletion command (right after the import command, inside the try block, inside the loop over all files), you make sure it is only called if Evernote does not error on import while avoiding having to iterate over the files several times.
A final note: you don’t have to use the block syntax for tell statements if there is only one command to execute – using tell <target> to <command> is easier and will keep you out of nested context hell.
Thanks #adayzone for corrections on list handling and alias coercion
Try
tell application "System Events" to set xxx to get every file of (desktop folder of user domain) whose visible is true
repeat with i from 1 to count of xxx
set SelectedFile to item i of xxx as alias
try
tell application "Evernote" to create note from file SelectedFile notebook "Auto Import"
tell application "Finder" to delete SelectedFile
end try
end repeat
Thanks #fanaugen