Questions tagged [applescript]

AppleScript is a proprietary programming language in macOS to control and exchange data with applications.

Filter by
Sorted by
Tagged with
0
votes
0answers
61 views

AppleScript (to start screen recording) takes 6 to 12s to even start running. Why?

I use the following AppleScript (assigned to keystroke Cmd+Ctrl+5) to start screen recordings (adapted from here). If I create an Automator Quick Action and assign the keystroke to it, it takes 6s ...
0
votes
0answers
28 views

How can I get apple mail to keep only the newest email from a daily subscription, and to automatically trash older emails

I only want to keep the latest email from a subscription and I would like apple mail to automatically delete the older ones. Is there an Apple Script or way of setting rules to achieve this task?
-1
votes
1answer
128 views

How to change desktop wallpaper for all desktops/spaces?

I want to write a script to change all my desktops/spaces' wallpaper to one picture every 5 minutes. (In linux, I use feh script to do it.) So how to do it in MacOS Catalina(such as use shell or ...
0
votes
1answer
115 views

How to use script to open an app if it's not the front most app, and hide it when it is the front most app in macos?

I need a script to open an app if it's not the frontmost app and hide(command+h) it when it is the frontmost app. e.g 'Kim.app' how to write this in Applescript or shell script? Here is some info I ...
0
votes
0answers
22 views

AppleScript sequential file process

I cannot work out what I am missing: the script shown is meant to process 1 or many files when file/s added to folder. However, will only process one file at a time. I.e. if 3 files are added it will ...
0
votes
0answers
26 views

AppleScript script for exporting only iCloud contacts

I wrote this AppleScript script, below, which extracts all contacts. How do I extract only the ones from iCloud? set desktopPath to (path to the desktop folder as string) & "contactBackup&...
1
vote
1answer
38 views

Get Value of Variable stops appending on last call & sets result to only that last variable

I have created a simple workflow in Automator to ask questions & send an email. I followed the tutorial at https://macmost.com/create-customizable-text-inserts-using-automator.html. This has ...
0
votes
0answers
18 views

Applescript - calling another script, but property in said script is not updating

I have; script A, that wants to run script B. I want script B to save a file path to a property in that script. When I run script B in Script Editor the property updates as expected... but when I call ...
1
vote
2answers
174 views

Access Application Menu Item with AppleScript

I am trying to create a global hotkey for a function of an app by building an AppleScript in Automator.app and then assign a hotkey to it in Service. But the AppleScript doesn't work. Specifically, I'...
0
votes
1answer
75 views

AppleScripts to create Calendar Events not working in Catalina

I have a number of AppleScripts that are triggered by Mail.app rules. They were working perfectly (and still are) on my old iMac running High Sierra, but I now have a new iMac running Catalina on ...
0
votes
0answers
40 views

How to add button to Safari Toolbar, that invokes AppleScript

ProxyToggle AppleScript: set socksStatus to do shell script "networksetup -getsocksfirewallproxy Wi-fi | grep Enabled" if (offset of "Yes" in socksStatus) = 0 then do shell ...
1
vote
1answer
40 views

Why does my curl command fail when run through applescript but work fine when I run directly in a terminal?

I am trying to write an applescript to control an installed projector using it's built in web interface. I have a curl command that pings the appropriate URL and can controll the projector as needed ...
1
vote
1answer
46 views

Applescript - Lock Finder selection [closed]

I found scripts that lock a file w/ a specific path but none that lets me "lock the selected item/s in the Finder". Could sb give me a hand with this? Much appreciated.
1
vote
1answer
168 views

AppleScript Error Message

I am looking for a way to batch-convert/bulk-convert .doc files into .docx files. I found this TidBITS Talk that references a Redit thread for an AppleScript (AS) and a dead DropBox link for an ...
0
votes
3answers
90 views

Leaving the last 9 characters of a filename in Automator

I have a ton of files to rename where we only need the last 9 characters of the file. The files are currently named as this: FirstName_LastName_000000000.pdf. Essentially, I want to rename the files ...
0
votes
0answers
16 views

AppleScript adding email content to Excel

I'm trying to use the script created by Tim Vaughan and posted on this page. The problem im having is that his format is: Name: XXXX and mine is: Name: XXXX code is --APPLESCRIPT _main() on _main() ...
2
votes
2answers
74 views

Applescript: move all files with a certain extension to the trash

This is very straightforward; it moves myfile.WMA to the trash: tell application "Finder" move POSIX file "/Volumes/DS_30/myfolder/myfile.WMA" to trash end tell But how would ...
0
votes
1answer
68 views

Handling permissions to run a bash script

I'm sending a bash script as a .command file to a friend. This person is not very tech savvy which is why I'm sending it in the first place, the goal is for the .command file to run through the shell ...
0
votes
0answers
29 views

Use AppleScript to move (not copy) GMail message in Apple Mail

How do I get AppleScript to appear to move (but not copy) a Gmail message in Apple Mail? If I use move theMessage to targetFolder the message appears in both folders. (More precisely, the message ...
0
votes
1answer
78 views

Applescript to find and add specific contacts to a group

I tried to re-jig the applescript from these two answers, but no dice. It seems to work if you're creating contacts at the same time, but not when finding existing contacts. tell application "...
1
vote
1answer
29 views

which certificate/identifiers/profilers should be used for python script to be distributed as a pyinstaller build/bundle outside the app store?

My program works as follows In a while loop, it checks for the active window change - AppKit library used from AppKit import NSWorkspace active_window = (NSWorkspace.sharedWorkspace()....
0
votes
0answers
78 views

Script to export all photos and album from Photos on Mac while keeping metadatas

My initial goal was to import "From my Mac" albums to my iPhone and keep them synced. It seems that an album created outside iOS is read only. And if I make a copy of it on my iPhone, it won'...
1
vote
1answer
40 views

Getting AppleScript function to pass string correctly

Someone please help me here and show me how to get this to work. I've checked examples on returning values from functions with this AppleScript, but something I am missing here. I'm trying to get the ...
0
votes
0answers
12 views

Can I temporarily disable keyboard entries on the lock screen?

I'd like to create an apple script that sends the computer to the lock screen and disables the keyboard for 60 seconds. This is what I have so far Lock the keyboard entries with KeyboardCleanTool Go ...
2
votes
1answer
26 views

How do I detect if headphones are connected (via the jack) in bash?

I have a script, and I want it to behave differently if headphones are connected. How can I get this information? I tried using SwitchAudioSource, but its output is the same, whether or not the ...
0
votes
1answer
131 views

How do I activate Mouse Keys with an apple script or the command line?

I have set up mouse keys to activate when clicking option five times. Unfortunately, it appears that I cannot activate mouse keys with this script repeat 5 times tell application "System ...
1
vote
1answer
68 views

How to lock a Mac lock screen without using keystrokes in the script?

I'd like to go to the Mac lock screen with a command line script. Many of the existing answers suggest something like osascript -e 'tell application "Finder" to sleep', but my computer does ...
0
votes
1answer
55 views

Simple AppleScript script terminates early

I have an AppleScript script for Music that processes the selected tracks and modifies the track name. Basically, it works. If I select one item, it works without fail. If I select multiple items, it ...
1
vote
2answers
107 views

Selecting a dropdown menu in Safari

I need to create an Applescript to open a certain website and export it as PDF using the menu "Save as PDF…" under the File menu. Then, I need to save that PDF on a certain location on my ...
0
votes
1answer
93 views

Applescript to output UTC Datetime at cursor without SystemEvents

It would be enormously helpful if I could bind a script that outputs the current UTC timestamp to keybindings and have the output magically appear at my cursor in whichever application I was using. ...
0
votes
1answer
46 views

Can AppleScript create an Open File Alert?

macOS Mojave 10.14.6 I would like to be able to programmatically create repeating calendar events that open a given file when run. I'm using AppleScript within Automator. Creating the repeating ...
1
vote
1answer
48 views

Miniaturise all windows with AppleScript

tell application "System Events" set mywindows to windows of (processes where background only is false) repeat with theItem in windows of (processes where background only is false) ...
0
votes
1answer
92 views

how to create a repeating event in Automator?

I would like to programmatically create a repeating event. I'm using Automator and it seems that Automator can't do this, plus I want to pass variables provided by the user into the event creation ...
1
vote
1answer
63 views

Is there a MacOS automation that can detect pixels on screen?

I need to automate some keyboard and mouses actions depending on what is shown on the screen. But because the applications don't have applescript hooks, there is no way to know of certain events ...
0
votes
1answer
60 views

Can an Automator workflow generate an Application?

I'm building a "Wizard" of sorts that uses Automator and some Appliescript, and at the end I would like it to generate an "Automator Application" that does things when launched, ...
0
votes
2answers
107 views

Calling AppleScript routine using osascript

Given the following AppleScript code on myHandler() display dialog ("I'm your Handler!") end myHandler How do I call myHandler from osascript (using Terminal), plain without parameters, ...
2
votes
2answers
310 views

Automate the repositioning and refreshing of menu bar icons?

Background When menu bar items are rearranged manually using Cmd+drag, macOS writes a new "preferred position" preference to each app that is showing a menu bar icon. (This preference helps, ...
1
vote
1answer
35 views

How can I specify a drive in Applescript without the drive name?

I had a main system drive on my iMac named "Macintosh HD" and wrote my scripts to reference files on that drive. For instance, to get to my library directory, I had "Macintosh HD:Users:...
0
votes
0answers
16 views

How do I organize screenshot based on window in Mac?

I tried to write a custom service in Mac with Automator to organize screenshots based on the window that is screenshot-ed. For example, if I use dictionary app in Mac in a full screen mode, and do ...
1
vote
1answer
65 views

How do I run apple script on a particular instance of Firefox?

I have three instances of Firefox called - Firefox Firefox 2 Firefox 3 They all live in the Applications folder and the difference is that they have different Firefox profiles and cookies. I'd like ...
0
votes
1answer
48 views

Reliable shortcut for non-ASCII text insertion

I occasionally use text strings such as ¯\_(ツ)_/¯ Unfortunately, I don't have a ¯ or a ツ on my keyboard, so using such strings can be a bit of a pain, usually involving a web search and copy and paste....
0
votes
1answer
35 views

How do I record changes to a cell in Numbers via AppleScript?

I'm very new to AppleScript so bear with me. What I am trying to achieve is for every time I run the script, the current value of a cell is copied into a cell, one column to the right of when I last ...
1
vote
1answer
288 views

Add exif creation time with correct timezone (TZD) to filename

Hi i have a problem renaming a lot of photo and images files. I use a shellscript in automator to rename them by EXIF date and time. But the time is given by UTC and im living in europe with +0100 in ...
1
vote
1answer
34 views

AppleScript: Clicking a button in a dmg file

I am trying to figure out what code will send 2 clicks to open a file in an opened .dmg file using AppleScript in Script Editor. I did create the .dmg file I've been searching for ways to create a ...
0
votes
0answers
16 views

Knowledge Request- Automatically Log Out of Google Services Script

TL;DR- is there a way to set Gmail to automatically log itself out? I am in the process of distancing myself from Google's services, and while it is inevitable that one will always interact with ...
1
vote
0answers
53 views

How to convert pdf file to tiff, then tiff to pdf with automator?

I have a lot of pdf files with different type of data in it: text, images, stamps etc. And I need to convert them to look like it's a scanned pdf, i.e. bitmap pdf. I need the same file with the same ...
0
votes
0answers
46 views

How to change text in Xcode document via AppleScript

I'm currently working on an AppleScript to invoke ClangFormat while in Xcode 11.5. Here's the work-in-progress: set fpath to "" set selRange to {} tell application "Xcode" try ...
2
votes
0answers
93 views

How to display Notification from a LaunchDaemon process?

I have a LaunchDaemon process that needs to run as root user. The process internally calls osascript to display some notifications. Notifications display fine when the process is run manually without ...
0
votes
1answer
20 views

In Applescript, how can I correctly obtain values for a process window that is the not the front window?

I currently have an Applescript that takes values from Google Chrome, but it only works if Chrome is the front window. In the case Chrome is behind another window, it no longer works: tell application ...
1
vote
0answers
101 views

I have an automator script that runs a curl request, how can I retrieve and display the progress in the menu bar?

On Automator, I created a service item that uploads a file by executing a BASH script that uses a cURL request. The Applescript code looks like: on run {input, parameters} set pathtofile to (the ...

1 2
3
4 5
57