Questions tagged [applescript]

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

2
votes
1answer
14 views

Is it possible to query the current user's Apple ID from the command line?

Is it possible to query the current user's Apple ID from the command line? I want to create an AppleScript (run-only) app that will run only for a specific user (or at least for a user signed in with ...
0
votes
1answer
21 views

Keyboard shortcut for a service stopped working

I have made a custom keyboard shortcut for Finder that runs a script that copies the full file path to the clipboard. The shortcut is Control + Alt + Command + C. It has always worked, but today it ...
0
votes
2answers
34 views

How do I get Automator to move a folder to Appname.app/Contents/etc

I'm trying to create an Automator Quick Action to move a selected folder into the Resources folder of an app, accessed by clicking Show package contents in the Applications folder. There doesn't seem ...
2
votes
1answer
21 views

Automator and/or AppleScript to automatically Command-F2 to enter Target Display Mode

I'm trying to use Automator with AppleScript to automatically hit Command + F2 to enter Target Display Mode. The script runs but I just get a beep/tone with no action. I don't know if there's an error ...
0
votes
1answer
49 views

How to script file for a Mac with several Terminal commands

I have few Terminal commands which i'm using so frequently,So i though to automate it to reduce the effort of copy-pasting the commands one by one in terminal and time. I created a .command file for ...
1
vote
1answer
32 views

MacBook Pro: Can't change the screen brightness

On my MacBook Pro 2012, I can't change the screen brightness. When I click on the brightness keyboard controls, nothing happens. Under System Preferences → Displays, the Brightness slider is missing: ...
0
votes
0answers
31 views

Distribute bash script 'silently' to multiple macos machines

We want to deploy a script 'silently' across all mac machines in organization. We have created a bash script that will run using launchd agent. We need to deploy the launchd agent and script on all ...
0
votes
1answer
21 views

error with automator applescript “do shell script” call (file not found) yet command line with same command works

I have a simple automator app that runs a simple script. It uses ssh to open a file on the local machine, MachineA, with an app on the remote machine, MachineB, and logs the ssh call. on run {input, ...
2
votes
1answer
79 views

Automatically open a terminal window and run a command, robustly

I am looking for a way to automatically open a new window of Terminal.app and run a command in it. I used to do this with AppleScript, in a way similar to this: tell application "Terminal" do ...
0
votes
0answers
14 views

how to open file type with app on remote machine via apple script app as default app for file type

I would like to set the default file association for a file type (PDF) to an Apple Script app. The Apple Script app will open the file type on a remote machine (using remote Apple events) with a ...
1
vote
1answer
27 views

How to make the items in a variable a single item

Lets say I have a variable Q set to {"a", "b", "c"} how can I make it so that AppleScript takes the items of Q and turns it into a single item so that Q is now set to {"abc"}?
2
votes
0answers
20 views

AppleScript to clean spam in Messages

I get a lot of spam in my iMessage, such gamble, sex etc. On my iPhone, it can be filtered into a separate column. But on my Mac, there is no way to filter messages from unknown senders, which is ...
0
votes
1answer
44 views

Prevent Terminal from overwriting preferences on exit

When a user loads my C++ program, I want Terminal to look a certain way. I solved this by wrapping my program in an AppleScript .app which overwrites ~/Library/Preferences/com.apple.Terminal.plist (...
1
vote
1answer
45 views

Copy file from Terminal and paste in Mail

I would like to copy a file to the clipboard in terminal (as a reference like Finder does it) and then when writing an email, paste it into Mail as an attachment (CMD + V). I posted an example ...
1
vote
1answer
25 views

Dictation workflows don't activate keypress

I'm unable to get Dictation to run the keypress portion of a workflow. I've tried recording a keystroke in Automator, and manually writing an AppleScript (with both key code and keystroke commands); ...
1
vote
2answers
47 views

Script that checks for apps with open window asks 'Where is Electron" in Electron apps

I have a script that prints the bundle ids for all apps with open windows. When an Electron app is open (for example VSCode) the script asks "Where is Electron" and it shows all apps in the ...
0
votes
1answer
17 views

AppleScript for Excel to select/copy all cells?

Applescript can tell Excel to select a specific range of cells, e.g. select (range "A1:B20") and you can copy cells: copy (range "A1:B20") However, how can you tell Excel to select all the cells ...
0
votes
0answers
17 views

How to receive URI requests in applescript

I want to open a link like testApp://test And for that to open the AppleScript that will receive the "test". Is this possible and if so, how would I go about doing it? So far, I made this in the ...
0
votes
0answers
38 views

It is possible to open links with AppleScript?

I want to create an AppleScript that will open once I click a link in a browser. For example, on Mac App Store links, you can click a button that will open the App Store on your computer. How would ...
2
votes
0answers
34 views

Refactoring Inelegant AppleScript to Use Recursion

I've written an AppleScript to iterate through an app's menu choices, doing something with each item (e.g., get its keyboard shortcut). It works, though (being AppleScript) it's very slow, but I'm ...
1
vote
1answer
22 views

Return status of SleepDisabled in Applescript

I'm trying to do an Applescript to enable or not SleepDisabled (using pmset) depending on the state of SleepDisabled. Something like : set SuperSleep to do shell script "return status of ...
1
vote
0answers
26 views

How to execute a PKG file using a custom universal keyboard shortcut?

It may sound strange but I need to run a specific PKG installer whenever I trigger a specific custom keyboard shortcut. On Sierra 12.6 I've assigned a custom keyboard shortcut to sleep/lock-screen the ...
5
votes
1answer
66 views

How to set a variable to all the numbers located in a list?

Lets say I have a variable set to this: set myVar to {"asdf", "qwerty24", "23", "22", "21abc" "20"} How can I set a variable to the numbers in myVar, including those with text inside of the item--...
0
votes
0answers
29 views

Adding hyperlink within message content of new email using AppleScript

I've been searching the internet but am having trouble finding a way to attach a URL hyperlink to a new email using applescript. The most helpful link I've found is from 2008, and I believe the ...
4
votes
2answers
63 views

Toggle caps lock programmatically using applescript

I'm looking to toogle capslock programmatically using applescript. Here is something I tried to make it work. It seems to work for all other keys except capslock. tell application "System Events" ...
0
votes
1answer
20 views

Apple Script Time interval

I used a great script from CJK with no issue , but not sure what happen, recently I noticed some invalid result : startDate = "2019-05-31" (US Format) Then converted to "31-05-2019" MyDate (now) = ...
0
votes
1answer
39 views

Applescript to get MS Word current word count?

Is there an AppleScript command which will grab the word count of the currently open Microsoft Word® document?
0
votes
0answers
15 views

Unable to save applescripts-created email in drafts folder in Outlook version 16

So I've been using applescript with Outlook version 16 to automate some tasks. I want to create an email and then save it in the drafts folder but i've been unsuccessful. I've tried several ...
1
vote
1answer
25 views

Count pages in a folder full of .doc files

I recently found this very helpful link to count the pages in a large folder full of PDF files: Count pages in PDF (for non-technical, mac using person). It worked like a dream. Now, however, I need ...
1
vote
2answers
55 views

Make AppleScript turn a variable into the items between two specified items

set theList to {"1", "", "", "apple", "acda", "", "3454", "ImportantStuff", "important1", "important2", "important3", "NotImportantStuff", "2", "", "efrg"} set theImportant to items between "...
0
votes
1answer
16 views

Adding column to multiple identically formatted tables in Numbers

I have a document in Number that contains many tables with the same format/columns but different content. I'd like to modify the format for all, adding a new, empty column in the same place with the ...
2
votes
2answers
40 views

Apple Remote Desktop Shutdown

I am relatively new to Macs and their osascript syntax. I have a mac mini set up as a server and I am trying to use Apple Remote Desktop to send a command to one of the iMac workstations. When I send ...
0
votes
0answers
27 views

AppleScript: Wait for Firefox Page to load

https://apple.stackexchange.com/a/320105/319746 I was trying to find a Firefox equivalent to the script in the link above under the line "Safari's Reload button", which monitors particular properties ...
3
votes
0answers
36 views

Is there any way to create an iTunes smart playlist with a user defined text field as the condition?

I'm using iTunes 12.8 with Yate by 2manyrobots (https://2manyrobots.com/yate/) to manage metadata for a library of approx 50k AIFF tracks. Yate has the ability to retrieve data from Discogs and ...
2
votes
1answer
61 views

Make AppleScript delay a random number between x and y?

set DelayTime1 to {18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58} set DelayTime2 to ...
1
vote
1answer
42 views

How to make AppleScript read the items of a variable that are numbers

set theList to {"123", "124", "abc", "125", "efgh", "126"} set theNumbers to numbers of theList return theNumbers How can I get AppleScript to recognize which items of theList are numbers and assign ...
0
votes
2answers
42 views

AppleScript sum of a list

I'm trying to get the sum from a list. The list newTotal: {"30.00", "30.00"} repeat with each from 1 to count of items of newTotal set myFinalTotal to myFinalTotal + each end repeat But the ...
0
votes
1answer
32 views

Applescript to filter the clipboard

Let say I have this in my clipboard : ************TH4F fsdfssdggg0878 Ex.US Unknown 0 $100.00 05/24/17 04:40 No Bonus ************TH4F fsdfssdggg0878 Un.UK Unknown 0 $50.00 05/...
0
votes
1answer
33 views

AppleScript quicktime to record iPhone screen

I am looking for a an Apple Script to tell Quicktime Player to start a new recording of the attached iPhone (so record an app doing its thing) and with the specified audio input. Is this even ...
2
votes
1answer
55 views

Automate moving and renaming files

I have files nested within multiple sub-folders. I want to move these files, one folder up the folder structure and rename the files as per its new parent folder. I will need this to be automated with ...
0
votes
1answer
49 views

Batch edit ID3 music tags using custom algorithm

I like to keep my iTunes library organised and all files well-tagged, so I often spend enjoyable yet unreasonably long amounts of time editing all the ID3 tags manually. Call it OCD or perfectionism, ...
0
votes
1answer
35 views

List all Outlook folder and subfolder with Applescript

I want to merge an Exchange account in IMAP. I moving all folder manualy in IMAP account but some emails are corrupted and all corrupted mail beging with Content-type: multipart/mixed; ...
1
vote
0answers
37 views

Replace font in incoming mail [mail.app]

I'm trying to write an Applescript (my first) to change the font of incoming emails using a rule in Mail.App. In particular, some tasteless individuals use Comic Sans, and I want to change their ...
0
votes
1answer
40 views

AppleScript : separating number from text in variable

I have a script which calculate the timeframe between date and return the result in days or month or years. For exemple, given myResult = "6 Days" How can I separate the number from the text ? I ...
0
votes
1answer
66 views

if external disk found by terminal applescript

Hey so MacBooks have this nasty habit of not mounting external disks when plugged in before... reference link the solution is quite simple with terminal eject the disk and the manually unplug replug ...
0
votes
0answers
19 views

Smart Folder from arbitrary script output?

This is a long shot, but is it possible to create a Smart Folder which, instead of building its search using the Search Criteria UI, but instead use the properly formatted output of necessary for a ...
1
vote
1answer
33 views

How to use lock screen events as a trigger for a script?

My Magic Mouse 2 died today and I thought it would be cool if I could use the locking of the screen as a trigger to send a push notification to my iPhone to remind me to plug my mouse in to charge. I ...
1
vote
0answers
24 views

Help with Apple Script for dealing with duplicates in Numbers

I had a script that I used to find duplicates in a numbers document and to highlight the duplicate in red. Well I now have a file where there are multiples of the descriptor in column B that are ...
3
votes
2answers
38 views

How can I make two applications activate from an AppleScript app?

So I am playing around with AppleScript and am quite new to it. How do I make the script quit both apps if: app1 and app2 are running or if app1 or app2 is running and run them if they are not ...
0
votes
0answers
30 views

AppleScript to window in another Space?

I'm trying to adapt an AppleScript that is using System Events, based on calling the front window of the application I want to control. The script is working okay if the application is in the same ...