Notification center documentation for applescript

Where can I find documentation for notification center method and properties to use it in applescript? I can’t find anything in script editor’s dictionary neither on web.

This is example code to work with notification center:

on run     tell application "System Events"         tell process "Notification Center"            set theseWindows to every window            display notification (count of theseWindows)         end tell    end tell end run 

How to refer to Applescript library objects with spaces in the name

I’m trying to write an Applescript that accesses EyeTV (yes, I still have one running!). I’m trying to list the recordings in the programs window. From the library:

application n [see also Standard Suite] : the EyeTV application   elements    contains player_windows, programs, recordings, channels, favorites lists.   properties    current recording (double integer, r/o) : unique id of the current (frontmost) recording. Returns 0 if there is none.   programs window (programs_window, r/o) : schedule dialog 

Further down in the dictionary is:

programs_window n [inh. window] : window containing the list of programs and recordings   elements    contains programs, recordings.   properties    selection (list of list) : A list containing every selected recording, channel or schedule (program) in the programs window, depending on what the current category is. 

If I right click the library and choose “New script” it will helpfully start the script for me:

tell application "EyeTV"  end tell 

I then add the line that is the problem:

tell application "EyeTV"     set recordList to recordings of programs window end tell 

If I compile this I get “Syntax Error Expected end of line but found class name.”

If I use programs_window instead, on running the script the error will be The variable programs_window is not defined.

I found a script someone else has written to export recordings from EyeTV to Plex, and it uses programs window. If I copy and paste the whole script and try to compile it I again receive the error Syntax Error Expected end of line but found class name.

I’m unsure how to proceed. Should I be referring to the programs window property of the application or the programs_window class? How can I get rid of the errors?

I have a copy of the AppleScript Language Guide but it seems to say nothing on the topic of application libraries.

Any help with this would be much appreciated.

Applescript not working on High Sierra

I created an applescript code to help rename a bunch of images and create a text file with the file names and dimensions so we can send out to another team to program into an email.

The code worked perfectly fine when I was on Sierra, but ever since I updated to High-Sierra it does not rename all the files. Usually our emails probably have 4-20 images that need to be renamed, but with the new macOS the script will rename 2 images and stop with this message

**error "Can’t get item 1 of {}." number -1728 from item 1 of {}** 

Here is the code, but the problem happens at

set h to (item 1 of dimensions) --/ dpi_to_dpmm -- works out pixel height as mm 

If anyone can help out I would appreciate it.

    --PopUp Window to select folder of files needing to be renamed set iFolder to (choose folder with prompt "Select Folder") --Sets folder path to readable location set fPath to POSIX path of iFolder --Sets folder path parent folder set pPath to POSIX path of ((iFolder as text) & "::") --removes listing invisible files set fContent to list folder iFolder as list without invisibles --seperates file name from extension set text item delimiters to "."   tell application "Finder"     --set gPath to fPath as string     set all_files to every item of (iFolder) as list      -- Multiple Selections     set theDeviceList to {"Regular", "Luxury", "Holiday"}      set theDevice to (choose from list theDeviceList with title "Device Selection" with prompt "Choose a Naming Convention:")      set choices to the result as string     -- Multiple Selections      -- Begin Normal Email     if choices is equal to "Regular" then         -- Normal Email          set new_FirstnameCol1 to "row"         set new_LastNameCol1 to "-1col1image-responsive-image"          set new_FirstnameCol2 to "row"         set new_LastNameCol2 to "-2col2images-responsive2-image"          set new_FirstnameCol3 to "row"         set new_LastNameCol3 to "-3col3images-responsive2-image"          --**Counter Begins         --1 Column Counter         set col1 to 1         --2 Column Counter         set col2 to 0         --3 Column Counter         set col3 to 0         --Keeps count of all grouped columns         set columnCounter to 0         --Numbering convention to file name         set universalCounter to 0         set oopsCounter to 0         --**Counter Ends          repeat with i from 1 to the count of all_files             --using our index, we select the appropriate file from our list             set universalCounter to i - columnCounter - oopsCounter             set this_file to item i of all_files             set file_name_count to text items of (get name of this_file)             set {itemName, itemExtension} to {name, name extension} of this_file              set source_file to item i of fContent             set fName to do shell script "basename " & quoted form of POSIX path of source_file             set wholePath to fPath & source_file              --Creates text file             try                 do shell script "touch " & pPath & "results.txt"             end try              --Check to see if there is a file extension             if itemExtension is "" then                 -- "" means there is no file-extension present.                 set file_extension to ""             else                 --yup, we are currently processing a file that has a file-extension                 --we have to re-add the original file-extension after changing the name of the file!                 set file_extension to "." & itemExtension             end if              --Gets the height and width of each file             set dimensions to paragraphs of (do shell script "sips -g pixelHeight -g pixelWidth " & quoted form of wholePath & " | grep pixel | cut -d':' -f 2 | cut -d ' ' -f 2")             set h to (item 1 of dimensions) --/ dpi_to_dpmm -- works out pixel height as mm             set w to (item 2 of dimensions) --/ dpi_to_dpmm -- works out pixel width as mm               if w is greater than or equal to 548 then                 --Col1                 set the name of this_file to new_FirstnameCol1 & universalCounter & new_LastNameCol1 & col1 & file_extension as string                 set txtName to new_FirstnameCol1 & universalCounter & new_LastNameCol1 & col1 as string               else if w is greater than or equal to 288 then                 --Col2                 set col2 to col2 + 1                 set the name of this_file to new_FirstnameCol2 & universalCounter & new_LastNameCol2 & col2 & file_extension as string                 set txtName to new_FirstnameCol2 & universalCounter & new_LastNameCol2 & col2 as string                 if col2 > 1 then                     set col2 to 0                  else                     set columnCounter to columnCounter + 1                 end if             else if w is greater than or equal to 101 then                 --Column 3                 set col3 to col3 + 1                 set the name of this_file to new_FirstnameCol3 & universalCounter & new_LastNameCol3 & col3 & file_extension as string                 set txtName to new_FirstnameCol3 & universalCounter & new_LastNameCol3 & col3 as string                 if col3 > 2 then                     set col3 to 0                  else                     set columnCounter to columnCounter + 1                 end if             else if w is greater than or equal to 1 then                 --Oops                 set the name of this_file to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i & file_extension as string                 set txtName to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i as string                  set oopsCounter to oopsCounter + 1             else                 --Oops                 set the name of this_file to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i & file_extension as string                 set txtName to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i as string                  set oopsCounter to oopsCounter + 1             end if             do shell script "echo '" & txtName & " " & w & " x " & h & "' >> " & pPath & "results.txt"          end repeat         --End Normal Email          --** remove this section if adding more options     else         display alert "Something Went Wrong"         --** remove this section if adding more options         end if end tell 

Applescript Powerpoint to create a new presentation from selected slides

I’m having a hard time believing this isn’t a command directly in Powerpoint, seeing as the one thing I hear more than anything is “can you send me just that slide?”. But MS isn’t exactly known for efficiency or catering to actual needs of the users. So I set about to scripting.

This one works:

–create new presentation with selected slides

tell application “Microsoft PowerPoint”

activate  copy object slide range of selection of active window  set newPresentation to make new presentation  paste object newPresentation 

end tell

–then save it

tell application “System Events”

tell process "Microsoft Powerpoint"       keystroke "S" using command down   end tell 

end tell

There’s only one more thing I’d like to do… paste using “Keep Source Formatting” so that the master styles are intact. I’ve tried many things trying to invoke the special paste option, but nothing works. I even added the “Keep Source Formatting” to the both the Ribbon and the Quick Access Toolbar and tried to invoke it as a menu item, but Applescript does not recognize either from what I’ve tried. Any ideas? (BTW, feel free to copy and use the script, because it works fine, just doesn’t preserve any formatting).

How can a terminated delimiter be rendered on a result with pure AppleScript?

In Script Editor to show a \t (tab) or \r (carriage return) it must be terminated, example:

"\t\nfoo\n\t\tbar" 

When performing a return on the above the terminated delimiter is present, such as:

set test to "\t\nfoo\n\t\tbar" as Unicode text return test 

but on the result it shows as:

enter image description here

removing the terminated text as:

set test to "\t\nfoo\n\t\tbar" as Unicode text return test 

however once compiled will result in:

set test to "    foo         bar" as Unicode text return test 

with the proper result. Only when a do shell is introduced, such as:

set test to "\t\nfoo\n\t\tbar" as Unicode text return do shell script "echo " & quoted form of test 

the result is correct:

enter image description here

Is there a way in pure AppleScript to terminate the delimiter but have it also render correctly in the result?


Edit:

To address the comment I am aware of return, space and tab but the content is dynamically created and I do not think it would be a good practice to replace delimiters with a text item delimiter. If I could, I’d like to limit any modification to the variable test.

AppleScript checking if folder exists causes “AppleEvent handler failed” error -10000

AppleScript on macOS Mojave and can’t work out why this script gives the expected “TRUE” on the first folder, but instead of “FALSE” on the second folder it aborts with the error message:

[error “Finder got an error: AppleEvent handler failed.” number -10000 from folder (file “Felix HD:Users:Billy:TESTING:FOLDER2”]

tell application "Finder"      set targetFolder to POSIX file "/Users/Billy/TESTING/FOLDER1" -- Existing folder      if exists folder targetFolder then         say "TRUE"     else         say "FALSE"     end if      set targetFolder to POSIX file "/Users/Billy/TESTING/FOLDER2" -- Non-existing folder      if exists folder targetFolder then         say "TRUE"     else         say "FALSE"     end if  end tell 

AppleScript: Can I ‘get’ highlighted text from Mail.app?

I’m trying to make a script that takes selected text in Mail.app, gets it into the script and does some processing to it.

I don’t want to have a GUI script that emulates command-C to copy the text to the clipboard. I’d like to be able to set a variable in my script directly to whatever text is selected. This text might be in a ‘compose’ window, or it might be non-editable text in a ‘read message’ window.

Right now I have this Mail script set up so it asks for input. And I copy the selected text, and paste it into the dialog box. But it would be very nice to skip that step and have the script get the selection directly.

How to iterate over Reminders using AppleScript

I’m trying to write an AppleScript that simply iterates over uncompleted Reminders and displays the name. The code below generates this error: Reminders got an error: Can’t make name of reminder (reminder id \"x-apple-reminder://838D4BDF-C520-440A-ADF2-B66FD602ADDC\") into type string

I figured out how to make it work by iterating from 1 to (count of notCompleted); but I would like to understand why the code below doesn’t work. (The fact that I expect the code below to work suggests that I am misunderstanding what kind of objects are in notCompleted.) What exactly is contained in notCompleted, and what exactly is the type of currentReminder?

tell application "Reminders"     set snoozeList to "Snooze"     set notCompleted to reminders in list snoozeList whose completed is false     repeat with currentReminder in notCompleted         display dialog (name of reminder currentReminder)     end repeat end tell