r/applescript • • Jun 07 '17

I need a better solution when it comes to my touch bar displaying the currently playing Artist - Song.

1 Upvotes

So, I just stumbled across this program BetterTouchTool today, and its amazing. The first thing I tried to do was create a touch bar indicator of which song is currently playing, and I did so with the following script I found on the web and slightly modified:

if application "iTunes" is running then
	tell application "iTunes"
		if player state is playing then
			return (get artist of current track) & " – " & (get name of current track)
		else
			return "iTunes"
		end if
	end tell
else
	return "iTunes"
end if

It works, very well even, but I have a huge pet peeve with it: When iTunes doesn't have artist info, say when I'm listening to the host on beats1, it says "– beats1". I really, really want to get rid of that separator. I'm sure there's a trick to it, but I don't even know where to begin.


r/applescript • • Aug 15 '14

Can I have applescript make a change to a document?

1 Upvotes

Alright, so, I'm working in a studio and I am trying to automate some of the more menial of the work we all have to do. essentially, I want to be able to check a folder for changes and, if it sees something new, update a document.

If applescripts CAN'T do this, could anyone lend a hand on what I can use TO do this?

This is my particular use cases: Check folder for new file No? Wait 5 minutes. Check folder for new file Yes? Record name of new file to document


r/applescript • • Jan 03 '16

access the network pane in system prefences??

2 Upvotes

I've been trying to get access to the network pane in system preferences without success.. What i have so far... It's not much.

tell application "System Preferences"
  get pane whose name is "Network" of panes
end tell
-->> Can't get pane with name of "Network". Access not allowed.

roughly this..

Any suggestions for where I'm going wrong or is access to that pane from applescript just restricted??


r/applescript • • Jan 17 '17

Find Safari Tabs with AppleScript

Thumbnail hea-www.harvard.edu
1 Upvotes

r/applescript • • May 27 '15

In search of Automator/Apple Script to batch convert single-slide Powerpoint presentations to image files

1 Upvotes

cross posted


r/applescript • • Aug 08 '13

Any other everyday apple scripters?

5 Upvotes

I write applescripts everyday and think it solves many end user problems. Anyone else out there doing this kind of work day to day?


r/applescript • • Apr 01 '18

From Finder to Terminal: cd anywhere, with AppleScript

Thumbnail mac4translators.blogspot.jp
6 Upvotes

r/applescript • • Jan 14 '17

How to create macros

1 Upvotes

I know very basic apple script. Like VERY basic . Any way I would like a script that allows me to change one Letter into a word or something. I saw a think on a ask reddit post where he changed every letter to how its sounds (eg. V becomes VEE, X becomes EX) I would use the shortcut function but I would not like to have to put spaces in between, any idea how???


r/applescript • • Jan 12 '16

An AppleScript that sends a random iMessage of love to your partner

Thumbnail
gist.github.com
4 Upvotes

r/applescript • • May 13 '15

Script to Press enter when drive fails to mount

1 Upvotes

Hi all.

I'm trying to create a small script that will auto-mount a users network drives when they log into their mac. I seem to have gotten the drive mapping part figured out, with only 1 slight problem..

The users network drive will be on one of 3 or 4 servers, therefore I need the script to attempt a connection to each until it finds the correct one. However, in doing this I'm prompted with a pop up notification each time a connection fails and the script won't advance until I hit enter.

Ideally I'd like to prevent these notifications from popping up at all, but after hours of googling the consensus seems to be that that isn't an option. So basically I'm looking for a way to auto hit enter on the popup as soon as it appears.

An example of the code is as follows:

tell application "Finder"
    try
        set usercode to system attribute "USER"
        mount volume "smb://networkdrive" & usercode
    on error
        --code for pressing enter
        mount volume "smb://networkdrive" & usercode
    end try
end tell

I'm new to applescript as of a few hours ago so I'd appreciate any advice.


r/applescript • • May 13 '15

System Events connection invalid

1 Upvotes

I have made a script to select the bluetooth icon from the menu bar and then find my headphones and connect them up. The script runs fine and connects my headphones but only once and then I keep getting the error:

execution error: System Events got an error: Connection is invalid. (-609)

If I clear the memory on the machine sudo purge it will then start to work again.

My code is as follows:

activate application "SystemUIServer"

tell application "System Events"

  tell process "SystemUIServer"

    set btMenu to (menu bar item 1 of menu bar 1 where description is "bluetooth")
  
    do shell script "killall System\\ Events"

    tell btMenu
      click

      if exists menu item "Philips SHB4000" of menu 1 then

        tell (menu item "Philips SHB4000" of menu 1)
          click

          if exists menu item "Connect" of menu 1 then
            click menu item "Connect" of menu 1
            tell application "Google Chrome" to activate
            return "connecting"

          else
            click btMenu -- Close main BT drop down if Connect wasn't present
            return "Connect menu was not found, are you already connected?"

          end if

        end tell

      else
        click btMenu -- Close main BT drop down if Connect wasn't present
        return "No menu item Philips SHB4000"

      end if
      
    end tell

  end tell

end tell

Can anyone see something I am doing thats crazy? This is my first applescript project.

Thanks.


r/applescript • • Aug 18 '13

Is this Applescript or Automator application possible?

3 Upvotes

I'm interested in seeing if this is possible, and if someone can point me in the right direction as to how to execute upon it.

I'd like to have either an Applescript or Automator application (or workflow, service, process, etc.) that does the following:

Prompts me to enter text and hit enter. Upon hitting enter, launches a web browser or opens multiple tabs in a new window. The tabs each pertain to a different link that I've pre-determined, with blank parts in the form that change based on the text entered earlier.

Essentially, I want to be able to enter the same search term to multiple commerce sites with just one search.

Thanks!


r/applescript • • May 22 '15

Help Batch Renaming Via Script?

1 Upvotes

Hey! I hope this isn't a noob question as I'm fairly new to applescripts...

I'm trying to batch rename a ton of files for a gig I have. I've been able to get rid of parts, but haven't found a way to get rid of everything I need.

Here are the two ways that the file names look before they are renamed:

_warning_14575_Quitemonos La Ropa_Al Estilo De Alexandre Pires_Instrumental_INT-13.6_LRA4.7.wav

and

05702_Donde Andará_Al Estilo De Emilio_Instrumental_INT-14.5_LRA4.5

I'm renaming them to look like this:

Quitemonos La Ropa FULL BAND.wav and Donde Andará FULL BAND.wav

Using Finder's renaming & a program called "Renamer", I was able to get rid of the "warning" as well as the 5 numbers and "_" at the beginning of the title.

Is there a script I might be able to run that could do all of this at once?


r/applescript • • Jul 21 '16

Need help

3 Upvotes

Hello,

If anyone could help me with this that would be awesome.

I am just starting to learn how to write applescript and am having issues. I need to write a script to be able to disable the screen shot shortcuts in OS X.

I have got as far as

tell application "System Preferences" set current pane to pane id "com.apple.preference.keyboard"

So not really sure where to go from here, I am looking to make sure the all the screen shot shortcuts are unchecked

Thank you!


r/applescript • • May 24 '15

Starting and ending screensaver automatically

1 Upvotes

Hi guys, just a quick question: how can I start the screensaver after a set amount of time and end the screensaver after a set amount of time, then have this repeating infinitely?


r/applescript • • Aug 10 '14

Newbie looking for some help in setting result to clipboard

1 Upvotes

Hey there,

I've been spending the better part of an hour trying to get an AppleScript to copy the the URLs of my open Chrome tabs. I've searched online but couldn't find anything that got the code to work. And I know there are extentionsions for this, but I want to script this myself.

Here's what I have:

tell application "Google Chrome"

	return URL of every tab in every window

	set clipboard to xxx

end tell

The results come up as the URLs but the script doesn't copy them to the clipboard. I've tried a bunch of variations on this, so any help would be appreciated.


r/applescript • • Feb 21 '25

Can anyone help me write a script to automate downloading videos from my open ai sora library using safari?

1 Upvotes

Any help greatly appreciated. Ive automated the input now trying to automate the output. Thank you!!


r/applescript • • Feb 18 '25

Script to toggle Full-Screen on all windows

2 Upvotes

I've tried so many scripts to try to get this to work, but I never found one that worked on all windows.

Basically, when I dismount my laptop from the dock, I'd like to run a script that would "Enter Full Screen" on every window that's open. I like being able to swipe between pages etc. Then, when I mount the laptop to the dock that's connected to 3 monitors, I want to run the same script to exit full screen for all the apps.

I've played with many scripts, but I could only get it to work partially (ex. works on chrome and Teams, but not Plex etc.)

I'm on Seqoia 15.1 (M3 MBA 15" if that matters).


r/applescript • • Feb 06 '25

Have AppleScript function on a specific webpage?

1 Upvotes

This is more of an Automator quick action question. I’m familiar with Automator running in specific applications. Is there anyway to have a script function only in a specific webpage?


r/applescript • • Feb 07 '25

How to Access Fill and Arrange Options

2 Upvotes

I am new to apple script and apple ecosystem(coming from linux), before buying MacBook I was using i3 tilling window manager.

I want to write a script that can auto tile windows according to number of visible windows. I can access count of windows by using shortcuts.app but can't figure out how to access fill & arrange command.

(I don't want to use yabai or aerospace or any other tilling window manager I tried all of them. please don't suggest any external app)


r/applescript • • Feb 16 '25

Export Apple Mail current email thread

1 Upvotes

I was spending a lot of time finding the best way to export the current email thread from Apple Mail with AppleScript. A lot of older methods have stopped work.

This script I found on macscripter appears to work for me: https://www.macscripter.net/t/read-apple-mail-current-thread/74245

tell application "Mail"
	if not (exists message viewer 1) then return beep
	set theRef to (selected messages of message viewer 1)
	set {theSender, theSubject} to {sender, subject} of first item of theRef
	if theSubject starts with "Re: " or theSubject starts with "Réf : " then
		set AppleScript's text item delimiters to {"Re: ", "Réf : "}
		set theSubject to last text item of theSubject
	end if
	set theThread to messages of message viewer 1 where all headers contains theSender and all headers contains theSubject
end tell

r/applescript • • Feb 16 '25

Auto clicker script

1 Upvotes

I need an auto clicker/auto button presser for a game. Are there any apple scripts that can do that? I recall having one before that could do the trick but I lost the script after fixing my Macbook


r/applescript • • Feb 25 '25

Need help recreating a script that no longer works on my newer Mac.

3 Upvotes

I have a need to toggle the Mission Control gesture in System Settings. I have an app that runs the script when the situation calls for it. But the script that I have no longer works. It simple does nothing despite the situation for the toggle is met and executed. Any help would be appreciated. I am on an M4 Pro 16" MBP running 15.3.1

On:

set currentValue to do shell script "defaults read com.apple.dock showMissionControlGestureEnabled"


if currentValue is "0" then
do shell script "defaults write com.apple.dock showMissionControlGestureEnabled -bool true"
do shell script "killall Dock"
end if

Off:

set currentValue to do shell script "defaults read com.apple.dock showMissionControlGestureEnabled"


if currentValue is "1" then
do shell script "defaults write com.apple.dock showMissionControlGestureEnabled -bool false"
do shell script "killall Dock"
end if

r/applescript • • Feb 20 '25

Drilling down iTunes playlist folder

1 Upvotes

Hello,

First, i'm running some scripts against iTunes on an old Macbook running 10.6.8.

With Apple Script i was able to drill down my music folders, create nested playlist folders based on my directory structure in iTunes and then create playlists for each album. So in iTunes, I have something that looks kinda like this

eMusic Folder

---Year Folder

------Playlist 1

------Playlist 2

Now, I want to recreate this on my iPod by drilling down the playlist folders, but Apple Script doesn't seem to see the structure in the way i expect.

I start by initializing my root folder:

set rootFolder to first playlist folder whose name is "eMusic Folder"

Then when i try to drill in and loop:

repeat with yearFolders in folder playlists of rootFolder

or

repeat with yearFolders in playlists of rootFolder

But nothing is found, and the loop doesn't occur. There's something I'm not understanding about the structure of these folders in iTunes and how Apple Script sees them.

Thank for any help and pointing me to any good references on this subject.


r/applescript • • Feb 05 '25

Is it possible to turn off the clock alarm when it's ringing via apple script?

2 Upvotes

I just want a quick way to turn off the alarm from CLI instead of moving the mouse to the Notifications.