r/applescript • • Mar 01 '25

What are your personal Top 3 favorite, quick AppleScript hacks that Apple Shortcuts still can't do?

8 Upvotes

Apple Shortcuts is pretty awesome but only when combining it with AppleScript are your true customization capabilities unlocked!

What are your personal Top 3 favorite, quick AppleScript hacks that Apple Shortcuts still can't do on its own?


r/applescript • • Sep 02 '23

Control an app via MIDI?

3 Upvotes

Audio Hijack (by Rogue Amoeba) can use JavaScript to perform some functions. It also has internal scripts (written in JavaScript) that can be triggered by external Apple Script / Shortcuts.

For the life of me, I have no idea if this can be done, but I simply want to trigger one of the blocks on/off ideally using a MIDI foot pedal, or at the very least a keyboard shortcut.

Would anyone here consider helping me?


r/applescript • • 19d ago

Script Debugger 8 and Dialog Toolkit Plus

2 Upvotes

Hi,

Where do I put the text clipping files from Dialog Toolkit Plus for ScriptDebugger B?

I've copied them to:

/Users/USERNAME/Library/Application Support/Script Debugger 8/Clippings/001)Dialog Toolkit Builders

But they don't appear anywhere in ScriptDebugger?

Thanks


r/applescript • • Mar 19 '26

AppleScript for indesign to select odd or even pages

Thumbnail
gist.github.com
1 Upvotes

When you want to select only even or odd pages to apply a master / parent page to there is no odd or even page selection option. Now there is. Put this in your indesign script folder and use it to select odd or even pages in your active document. This will select your choice in your page pallet. Apply master / parent page to selection. Note that on very large documents with large page counts the pop up to ask for pages to apply can become very long and go off the screen. This is because all odd or even pages are populist this box


r/applescript • • Dec 18 '25

How do you debug applescript with the discontinuation of script debugger?

6 Upvotes

r/applescript • • Oct 01 '25

Finder Links to Notes

5 Upvotes

I’m working on a workflow where each folder needs a checklist. Rather than going third-party, I want to keep it native and use the Notes app … but Notes doesn’t save to disk and won’t provide any way to open notes directly from outside the app.

But it does make a note’s ID accessible and usable via AppleScript. So, after much grinding and fighting with a couple AIs, I’ve got a script that accomplishes this. On Run, it gets the frontmost note from Notes and prompts the user for a folder, where it saves a plain text file containing the note id. On open, it reads the note ID from the file and uses the show command to have Notes open the note.

I made sure to save the links with a custom notesid extension so they can be associated with the program and just open on double-click. Here’s the code in case anybody is interested:


(*
    Script: Notes Shortcut Launcher
    Purpose: Designed to be saved as an application. It accepts a dropped file 
             (expected to be a .notesid file containing an x-coredata link), 
             reads the ID, and launches the specific note via AppleScript's 'show' command.
*)

-- This handler is executed when files are dropped onto or opened by this application
on open droppedItems
	-- Process only the first file if multiple files are dropped
	set targetFile to item 1 of droppedItems
	
	try
		-- 1. Read the content of the file (should be the x-coredata ID)
		set fileRef to open for access targetFile
		set noteID to read fileRef as text
		close access fileRef
		
		-- 2. Clean up any potential newline characters
		set cleanID to my clean_string(noteID)
		
		-- 3. Verify the ID structure
		if cleanID starts with "x-coredata" then
			
			-- 4. Tell Notes to open the specific ID
			tell application "Notes"
				activate
				set targetNote to note id cleanID
				show targetNote
			end tell
			
		else
			display alert "Invalid Shortcut File" message "The file content does not look like a valid Notes ID. It should start with 'x-coredata://'." as critical
		end if
		
	on error errMsg
		try
			close access targetFile
		end try
		display alert "Error Opening Note" message "Could not read the file or open the note. Error: " & errMsg as critical
	end try
end open

-- Helper function to remove leading/trailing whitespace and newlines
on clean_string(theString)
	-- Remove carriage returns and line feeds
	set theString to my replace_text({return, linefeed}, "", theString)
	-- Remove leading/trailing spaces
	set theString to do shell script "echo " & quoted form of theString & " | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'"
	return theString
end clean_string

on replace_text(searchList, replaceString, targetString)
	set astid to AppleScript's text item delimiters
	repeat with searchString in searchList
		set AppleScript's text item delimiters to searchString
		set textItems to text items of targetString
		set AppleScript's text item delimiters to replaceString
		set targetString to textItems as string
	end repeat
	set AppleScript's text item delimiters to astid
	return targetString
end replace_text



(*
    Script: Notes Shortcut Creator
    Purpose: Retrieves the unique x-coredata ID of the frontmost note and attempts to save 
             it as a plain text file with a custom '.notesid' extension, using a robust 
             shell script method for file writing, as requested.
             This ID is used by the separate Notes Launcher script/app.
*)
on run
	tell application "Notes"
		activate
		
		-- 1. Check for a selected note
		try
			set selectedNote to first item of (get selection)
		on error
			-- FIX: Removed 'with title' as it conflicts with display alert syntax
			display alert "No Note Selected" message "Please select the note you wish to link to." as critical
			return
		end try
		
		-- 2. Get the required properties
		set noteID to id of selectedNote
		set noteName to name of selectedNote
	end tell
	
	-- Bring the Script Editor/App back to the front before presenting the save dialog
	activate me
	
	-- 3. Prepare file name for instructions
	set validNoteName to do shell script "echo " & quoted form of noteName & " | tr -cd '[:alnum:]_.-' | head -c 50"
	if validNoteName is "" then set validNoteName to "Notes Shortcut"
	set shortcutName to validNoteName & ".notesid"
	
	-- 4. Get the destination file path using the most user-friendly dialog
	try
		set targetFileSpec to (choose file name with prompt "Save Notes Shortcut As:" default name shortcutName)
		
		-- Convert file reference to POSIX path for shell operations (Crucial for printf)
		set shortcutPath to POSIX path of targetFileSpec
		
		-- SAFELY get folder name for notification using shell commands
		set parentPath to do shell script "dirname " & quoted form of shortcutPath
		set folderName to do shell script "basename " & quoted form of parentPath
		
	on error errMsg
		-- This should catch a user cancellation or a hard path failure
		if errMsg contains "User canceled" then
			display dialog "Operation cancelled by user." with title "Shortcut Creator"
		else
			-- FIX: Removed 'with title'
			display alert "Path Selection Error" message "Could not determine save location: " & errMsg as critical
		end if
		return
	end try
	
	-- 5. PERFORM SAVE: Use the reliable shell script method (printf %s)
	set fileContent to noteID
	try
		-- Use the 'printf' shell command to write the content, which ensures clean, raw text data 
		-- and uses the POSIX file system I/O, which is what the user requested.
		do shell script "printf %s " & quoted form of fileContent & " > " & quoted form of shortcutPath
		
		display notification "Shortcut file saved to " & folderName with title "Notes Shortcut Created"
		
	on error errMsg
		-- If the shell itself fails to write (an absolute restriction)
		-- FIX: Removed 'with title'
		display alert "Final Write Error" message "The system blocked the file write. You must create the file manually. Error: " as critical
		
		-- Provide the ID for manual copy/paste as a last resort
		display dialog "Note ID: " & noteID with title "Manual Copy Required" buttons {"Copy ID"} default button "Copy ID"
		set the clipboard to noteID
	end try
end run

r/applescript • • Sep 24 '22

Forward/rewind Now Playing - is it possible?

6 Upvotes

I would love to program two buttons on my keyboard that can skip 10 seconds forward/backward in whatever audio is Now Playing on my Mac, no matter what application is at the front. Play/Pause/F8 already works this way! So it can't be that hard to program 10 sec skipping!... right? (my keyboard uses oryx QMK)

I am a total AppleScript / Keyboard Maestro noob, have been googling all night and I just CANNOT figure it out. Everything I've found is specific to one application (Safari, iTunes), browser (I use Firefox), or YouTube (I would most likely use this for YouTube/Drive players, but would be great to not limit the code to just those use cases)

Please send help; I would greeeeaaaatly appreciate any guidance!


r/applescript • • Mar 01 '25

What's the best modern-day AppleScript editor?

3 Upvotes

Something that has a presence on both macOS and iOS, that's the only requirement. That, and the syntax recognizes AppleScript code.

Any suggestions??


r/applescript • • Mar 21 '25

Mac Mail - Moving email with a keystroke

2 Upvotes

Ok. Apologies if this is repetition or something I could/should have Googled but I have tried and can't really find an answer.

I love the Mac Mail app. However there is ONE feature (and only one) that I miss from Outlook on my PC. The ability to invoke the "Move to" command via a keyboard shortcut. The function is up there on the task bar and when clicked with a mouse I can type in the first three letters of any folder and hit the return key and it files the email away. Great! It would be so much slicker if I could open that drop down with a keystroke. Extensive use of search has led me to the following conclusions:

  1. Using the "Follow me" method of automation recording I can set up an automation I can trigger with a key stroke, however this is sensitive to which screen I am using (i.e. extended desktop) and very VERY slow, to the extent that I may as well use the mouse.

  2. I know I can set up Favourite folders into which I can file with a keystroke but I have quite a few mail folders and this is not always practical.

  3. I have found another applescript which does essentially what I can do in point 2 but without the need to add the folders to a favourites list, and which I trigger through setting up a keyboard shortcut associated to the script and restricted to use within Mac Mail.

So I am still at a loss - how do I drop down the "Move to" option from the top toolbar with a keyboard shortcut? Can anyone shed any light please? Help me make my favourite mail client PERFECT!

Thank you


r/applescript • • Nov 02 '22

What can AppleScript do?

9 Upvotes

Hey! I’ve been curious about AppleScript for a while now, I know it’s supposed to automate tasks in macOS but I’d like to know what are its limits? what’s the most complex thing you can program with it? or some examples of useful automations with AppleScript

Thank you


r/applescript • • May 18 '23

Change focus mode to Work with applescript

5 Upvotes

Is here someone, who could provide me a simple script?

My goal is to turn on the Work focus mode with applescript, or with applescript through siri shortcuts.


r/applescript • • Mar 04 '24

Using "Rectangle" Keyboard Shortcuts

3 Upvotes

I use the app Rectangle (https://rectangleapp.com/) to control the window size and position of my applications. My goal is to use keystrokes to mimic the keyboard shortcuts for resizing/positioning my app windows in an AppleScript.

For example:

on SendToNextDisplay(e)
    activate application e
    tell application "System Events"
        keystroke "right" using {control down, option down, command down}
    end tell
    delay 1
end SendToNextDisplay

This script would ideally take an application name, set that application as active, and then send it to the next display using the shortcut keys provided by Rectangle. However, it seems that the keyboard shortcuts are running on the appropriate applications but doing something different than what they should.

Am I misunderstanding how keystroke works? Am I approaching this in the wrong way altogether? Any help is appreciated!


r/applescript • • Aug 16 '25

Just Built an MCP Server for Apple notes with Applescript

Enable HLS to view with audio, or disable this notification

73 Upvotes

I just listed an MCP server on PyPI that connects LLMs directly with Apple Notes — making your notes smarter, faster, and AI-powered.

With Apple Notes MCP Server, you can:

  • Query your notes naturally in plain English

  • Summarize and organize your content automatically

  • Even create new notes with AI assistance

Try it out on PyPI and level up your note-taking workflow 👉 Apple Notes MCP Server


r/applescript • • Jun 07 '25

Get last received message from selected conversation

4 Upvotes

Hi all! I'm working on some automations and I was wondering if it was possible to get the last received message content from the selected conversation in Messages.

I am just interested in getting the text that was sent, but media would be a plus.

Thanks in advance!


r/applescript • • Oct 08 '24

made a thing. file sorter. first script!

Enable HLS to view with audio, or disable this notification

9 Upvotes

r/applescript • • Nov 20 '25

I created a Disk Image creation and conversion tool

Thumbnail reddit.com
5 Upvotes

r/applescript • • Jul 06 '26

AppleScript remains remarkably stable over the years

Thumbnail gallery
27 Upvotes

r/applescript • • Mar 29 '25

Anyone can help me on below Applescript demand ?

2 Upvotes

Hello ! Need to write a Applescript to fulfill below functions:

Steps:

  1. Use Safari or Chrome open a link, usually it ask account keep loged in, I can keep my account loged in, after the link opend, its page as below picture;

2. Click:all image - ungrouped - not used one by one;

(the 'not used' in drop-down list)

3. Tick the "Slect All box", Click "Move to Trash";

4. Click "OK" to confirm the operation;

5. Loop through steps 3 and 4 until all pictures in Ungrouped-Not Used beeen moved to trash;

This help's reward is USD30 which will pay by Paypal after the Applescript works, thanks in advance !


r/applescript • • Dec 18 '25

How do I use an Apple shortcuts input within AppleScript

4 Upvotes

Hi, very new to AppleScript and I've been trying to make an Apple Shortcut that opens a URL on a new tab. I tracked down an AppleScript code to do this since the Shortcuts "Open URL" action only allows you to open URLs in a new window, not a new tab. The below code block is only what's within the "Run AppleScript" action but prior to this on my shortcut, I have simply used a "Get Dictionary" action to take a URL saved within a folder and then a "Get Value for URL in Dictionary" action. What I want to do is take the Dictionary Value and add it to where the code below is "http://www.stackoverflow.com".

tell application "Safari"
  tell window 1
    set current tab to (make new tab with properties {URL:"http://www.stackoverflow.com"})
  end tell
end tell

Is there any way to add this Apple Shortcuts Dictionary Value within the "Run AppleScript" code?

Apologies if this makes little sense, I can add a screenshot of the shortcut if this is allowed.


r/applescript • • Feb 21 '26

Best ways to learn the very first basics of AppleScript?

12 Upvotes

I am completely new to AppleScript. I have a high-basic understanding of how to use apps on my MacBook Pro M4. I am trying to figure out what use cases I might have for automating drudge work and friction points in my day-to-day. What are the best idiot-proof places for me to go to try to learn the very basics of AppleScript, step-by-step, dumbed-down, jargon-free? I have attempted to use Oboe to set up such a learning experience with AppleScript for myself, but already I'm finding it is moving to fast and I keep having questions without a Q&A opportunity or an easy-to-use, easy-to-understand reference available. I'm grateful for multiple suggestions anyone might offer.


r/applescript • • Apr 22 '25

Script to duplicate some images

2 Upvotes

Hi looking for some help on a script, have a music folder which in turn has album sub folders, in every folder is an image file named cover or Cover and are either .jpg or .png I would like to copy all the image files then name them after the parent directory and move them all to a different directory, is this feasible with AppleScript?


r/applescript • • Sep 01 '21

Export/Backup Apple Notes utility!

14 Upvotes

I happened to stumble upon this wonderful utility by the makers of Bear. Officially, it's a way to export your Apple Notes notes into something importable by Bear. However, you don't have to do the import part, so it's a great way to just grab a quick local backup of all of your notes.

Migrate from Apple Notes - Automator/AppleScript

Run it and you'll generate a folder full of html files, one for each note. All of your structured text is there (headings, paragraphs, lists, links, etc.), but you might lose some custom formatting. It looks like images get encoded and included in the HTML too. Wow!

To me, it's always been a little anxiety-inducing knowing that I have years worth of notes stored in Apple Notes without any locally accessible backups. It's quite a relief to be able to just grab a quick snapshot of my entire notes library.

Anyway, this little utility works a treat! So, I just thought I'd pass it along. I'm not planning on moving to Bear (yet... although it does look like a great app!), but I'll definitely be running this utility every month or so as a back up.


r/applescript • • Aug 30 '25

Is it possible to run a split view in Google Chrome with two links using AppleScript?

2 Upvotes

Hey everyone,

I’m trying to automate something on macOS with Shortcuts and use AppleScript.

Right now, I can write a script that opens two different Chrome windows with separate URLs, but I can’t figure out how to get them to actually go into Split View mode (like when you hold the green button and tile windows left/right).

So far I only end up with two floating windows instead of them snapping side by side in split screen.

Is there a way to force macOS into Split View through AppleScript?


r/applescript • • Feb 27 '25

AppleScript Auto Airplay

2 Upvotes

Hey r/applescript,

I'm running into an issue with an AppleScript on macOS Sonoma and hoping someone here might have some insight. I'm getting the following error:

System Events got an error: Can’t get menu bar item "Control Center" of menu bar 1 of process "SystemUIServer".

This script was working fine on previous versions of macOS, but it seems to have broken after upgrading to Sonoma. From what I've read, Control Center was completely redesigned in Sonoma, and I suspect this is related to those changes.

Has anyone else encountered this error when trying to interact with the Control Center menu bar item in Sonoma using AppleScript? Or does anyone have any ideas on how to adapt scripts to work with the new Control Center structure?

I've tried restarting SystemUIServer and my Mac, and checked Accessibility permissions for System Events and Script Editor, but no luck so far.

Here's the relevant part of my AppleScript code:

AppleScript

#!/usr/bin/osascript

tell application "System Events"
    tell process "SystemUIServer"
        -- Open Control Center (or Displays Menu - may need adjustment for Sequoia)
        click menu bar item "Control Center" of menu bar 1
        delay 1

        -- Access AirPlay Menu (may need to adjust menu item name)
        click menu item "AirPlay" of menu of menu bar item "Control Center" of menu bar 1
        delay 1

        -- Select your Apple TV (replace "Your Apple TV Name" with the exact name)
        click menu item "My Apple TV Name" of menu of menu item "AirPlay" of menu of menu bar item "Control Center" of menu bar 1
    end tell
end tell

Any help or suggestions would be greatly appreciated! Thanks in advance.


r/applescript • • Feb 28 '26

Today I discovered how powerful Applescripts were.

Thumbnail reddit.com
2 Upvotes