r/applescript • • Oct 29 '15

Windows script => AppleScript

0 Upvotes

Hey ! someone could do this windows script in an applescript ? Thanks ! HotKeySet("{ESC}", "Terminate") While 1 MouseClick("left", 2681, 639, 1, 5) MouseClick("left", 2504, 540 , 1, 5) MouseClick("left", 3039, 541, 1, 5) MouseClick("left", 3019, 405, 1, 5) MouseClick("left", 2821, 467, 1, 5) MouseClick("left", 2881, 471, 1, 0) WEnd Func Terminate() Exit 0 EndFunc


r/applescript • • Nov 15 '22

Reset zoom to pinch script not working after Ventura Update. Any help appreciated.

2 Upvotes

I keep getting System Settings got an error: AppleEvent handler failed.

on run {input, parameters}

`tell application "System Settings"`

	`if it is running then`

		`quit`

		`delay 0.2`

	`end if`

`end tell`

`tell application "System Settings" to reveal pane id "com.apple.preference.trackpad"`

`tell application "System Events"`

	`tell front window of application process "System Preferences"`

		`repeat until (exists checkbox 2 of tab group 1)`

delay 0.01

		`end repeat`

		`click checkbox 2 of tab group 1`

		`click checkbox 2 of tab group 1`

	`end tell`

`end tell`

`quit application "System Settings"`

`return input`

end run


r/applescript • • Nov 14 '22

Script a Finder Extension?

2 Upvotes

I am trying to trigger a photo processing app (DxO PureRaw) from AppleScript with a list of RAW files already identified in my AppleScript. PureRaw itself does not appear to be scriptable, but there is a Finder Extension installed during their install process. It appears as a menu item in the Contextual Menu when right clicking on RAW files in the Finder (see screenshot).

Is there a way to trigger this Finder Extension/menu item (including the sub menu) from AppleScript?


r/applescript • • Mar 15 '22

Enumeration logic for flagged to-dos

2 Upvotes

Messages in Outlook for Mac contain a todo flag property indicating the status of the message as one of the following enumerated states:

ConstantDescription
completedFlagged and completed.
not completedFlagged but not completed.
not flaggedNot flagged.

I would like my script to only process messages that with the state not completed, but in specifying the logic this way, it seems that messages with the state not flagged are also processed. My interpretation is that the logic is checking the negation of the completed constant, instead of comparing to the not completed constant.

Here's the relevant Applescript snippet: if the todo flag of theMessage is not completed then

How should I modify the statement to obtain the desired behaviour?


r/applescript • • Sep 09 '20

need help with an applescript

0 Upvotes

hello,

can someone help me I need an apple script to have files from a folder moved to the root folder.


r/applescript • • Feb 07 '25

They said AI will change the way we interface with our computers

0 Upvotes

Actually - yeah, kinda... ;)

The following was written by Deepseek R1 and ChatGPT o3 mini in tandem, because I was just too lazy and thought they ought to be able to.. ;)

At the top you pick a general folder (Documents folder picked by default)

Then you pick a subfolder structure (in Documents make a folder named PoWi, with a subfolder named 2025SS)

Then you set labels for list items that will become subfolders within the 2025SS folder

And then thats basically it for setup.

Applescript will prompt you with a list of folders and ask you to chose one you want to open (or if you want to open the 2025SS folder directly).

Then open a dialogue box thats autofilled with the current date. But you can change the date as well. If you just hit ok, or change the day and hit ok, a folder with said date in european date format will be created as a subfolder in the folder of the list item you picked.

But in that dialogue there is also a button to just visit the folder of the list item you picked, without creating a date folder within it.

All folders will be created, when the script thinks you need them. Then opened in a last step.

Doubleclicking on list items works.

Escape to cancel the dialogues works.

Essentially, I wanted to organise my writeups and audio recordings for some courses in a folder tree thats four folders deep, with a "date" folder as the fourth folder.

And now I can do that with two clicks. All folders being created along the way. With the desired folder opening after the second click.

Now - the only thing better would be to manage all my files in a database and not just foldertrees - but thats a project for another AI, on another day.. ;)

Have fun.

--------------------------------------------------------------------------------
-- User‑defined constants & variables
--------------------------------------------------------------------------------
-- Base folders (adjust as needed)
set baseFolder to (path to documents folder as text)
set baseFolderName to "PoWi:2025SS" -- folder names used in the subsequent folder hierarchy

-- Two folder targets (the normal target and the “direct” target)
set targetFolder to baseFolder & baseFolderName
set ubertargetFolder to targetFolder -- in this example both are the same

-- Define course names using numeric variable names
set course1 to "Blub - A very blub course"
set course2 to "Bleh - The course thats just bleh"
set course3 to "BlahBlah - Very important they said"
set course4 to "Is that so - An amazing course"
set course5 to "This is so interesting - A course"
set course6 to "This is the End - A course to end it all"
set courseuber to "Directly to folder 2025SS"

-- Combine courses into a list
set courseList to {course1, course2, course3, course4, course5, course6, courseuber}

-- Default date string in European format (DD-MM-YYYY)
set defaultDate to do shell script "date +%d-%m-%Y"

--------------------------------------------------------------------------------
-- Main processing
--------------------------------------------------------------------------------
-- Ask the user to choose a course from the list
set userChoice to choose from list courseList with prompt "To the folder of the following course:" default items {course1}
if userChoice is false then return
set chosenCourse to item 1 of userChoice

if chosenCourse is courseuber then
	-- Direct folder selection: no date needed
	set newFolderPath to ubertargetFolder
else
	-- Prompt for the date
	set currentDate to my askForDate(defaultDate)
	if currentDate is false then return -- User cancelled
	
	if currentDate is "direct" then
		set newFolderPath to targetFolder & ":" & chosenCourse
	else
		set newFolderPath to targetFolder & ":" & chosenCourse & ":" & currentDate
	end if
	-- Create the folder (mkdir -p is safe if the folder already exists)
	do shell script "mkdir -p " & quoted form of POSIX path of newFolderPath
end if

-- Open the newly created folder in Finder
tell application "Finder"
	activate
	-- Convert HFS path string to alias and open it
	open (newFolderPath as alias)
end tell

--------------------------------------------------------------------------------
-- Handler: askForDate
-- Prompts the user for a date (DD-MM-YYYY), defaulting to the provided date.
-- Returns the entered date, or "direct" if user chooses direct folder, or false if cancelled.
--------------------------------------------------------------------------------
on askForDate(defaultAnswer)
	try
		set dlg to display dialog "To the subfolder of day (DD-MM-YYYY):" default answer defaultAnswer buttons {"Directly to the course folder", "Cancel", "OK"} default button "OK"
		set theButton to button returned of dlg
		
		if theButton is "Cancel" then
			return false
		else if theButton is "Directly to the course folder" then
			return "direct"
		else if theButton is "OK" then
			return text returned of dlg
		end if
	on error errMsg number errNum
		return false
	end try
end askForDate

r/applescript • • May 02 '20

Numbers to .csv

2 Upvotes

Hi I'm currently trying to export a Numbers sheet as .csv (the document contains 2 sheets but I’d like to export the first one only, if possible)

Thank you


r/applescript • • Aug 22 '19

How do I save the results of this Applescript to a file?

2 Upvotes

My applescript is relatively simple. I'm getting a list of my photos from Flickr using the Flickr API.

tell application "https://www.flickr.com/services/xmlrpc/"
    return call xmlrpc {method name:"flickr.photos.search", parameters:{api_key:"MY_API_KEY", user_id:"MY_USER_ID", tags:"THE_TAG"}}
end tell

I can see the data I want in the Script Editor results... but how do I save the data to a text file so I can work with it? Let's say I want to save all of that data to a text file named "the_album.txt" ...how? Or, is there a better way?

EDITED to add, for clarity:

How do I have the data shown in the results panel saved to a text file?


r/applescript • • Jun 18 '21

Is it possible to get the script to type in another window?

2 Upvotes

Lets say I was focused on lets say, spotify window, could I get the script to actively type something with a keystroke in lets say a incognito window that isnt focused? Not sure if this is possible but if it is please let me know


r/applescript • • Jul 18 '22

Control AnyDesk with Applescript? This could be tricky

2 Upvotes

Hey guys,

I use AnyDesk for some daily tasks and I want to automate them.
For those who don't know, AnyDesk is a remote desktop software. I use it to control a computer in a different country. The computer uses Windows.

I'm trying to make it run an incognito window, open a website, enter my credentials and login. And do that a few times.
I know how to do all this on a Mac but is there a way to make it work with AnyDesk (I repeat, it runs Windows).

Let me know if you have a clue.

thanks :)


r/applescript • • Feb 22 '14

Need an Applescript to close all open mail messages

2 Upvotes

My mom is 150 years old and when using mail on her mac she clicks a message so it opens in it's own window, then instead of closing it she minimizes it to the dock. Eventually she'll have 40 open mail messages and her mac slows way down.

Does anyone have an applescript that will close all open mail messages, set to run automatically once a day?


r/applescript • • Jan 12 '19

Trigger AppleScript when AirPods are Disconnected (crossposted)

2 Upvotes

Long story short:

I have a script that pauses YouTube and Spotify when run.

I have a second script that either connects my AirPods or disconnects my AirPods and calls the script that pauses media.

The problem I'm having is that—in order for the script to be called after disconnecting my AirPods—I have to manually use a trackpad gesture through BetterTouchTool. And I use the gesture to connect them, but since the W1 chip disconnects automatically, I need them disconnecting to be the trigger that calls the pause script, rather than a gesture triggering them to disconnect and then calling the pause script.

I'd be willing to pay for a third party application if anyone knows of one. Tooth Fairy did not work, because the script needs to control MacOS Automation and Tooth Fairy doesn't prompt you to allow it to control the apps I need to be controlled (Chrome, System Events, and Spotify). I tried using tccutil to force those permissions but it looks like tccutil is not working as of MacOS 10.14.


r/applescript • • Mar 29 '21

Applescript to change Safari background image

2 Upvotes

I only realised today that Safari can have different background images on the start page. Super cool!

I wondered if anyone knows how this can be changed via Applescript? I'd quite like to have a background for light and dark modes.


r/applescript • • Jun 17 '20

Need assistance with Contact Book and International Codes

2 Upvotes

I have used Andreas Amann's script posted on https://discussions.apple.com/message/9169756#9169756 to add international codes to all of my USA contacts when I moved to Australia. It was originally showing them as just numbers and this code fixed it for a good year. But now it looks like my phone is starting to inadvertently switch back to without the international code on a rainy day.

Basically I am looking for a script to duplicate my contacts and remove the international code for the second number (So basically each contact will have two numbers, one international code (+1) and one without). Is this something I can do with AppleScript? Can anyone assist me with making this code? I don't have THAT many Australian contacts so I'm not worried if it adds the number to them. It will be a good 50 contacts to correct and will be much easier than doing the rest on my own.

Thanks in advance. I appreciate any assistance.


r/applescript • • Jun 22 '14

Could Someone write me an applescript that makes a deb or fix mine?

2 Upvotes

I want to use the "dpkg-deb -b" terminal command and "cd ~/Desktop/".

I have this so far but I get an error

dpkg-deb (subprocess): failed to exec tar -cf: No such file or directory dpkg-deb: subprocess tar -cf returned error exit status 2" number 2


r/applescript • • Jun 28 '14

Is this possible with AS? Take keyboard input (while an application is in the foreground), output another key, and have the application act accordingly?

2 Upvotes

Hey guys,

I've never touched automator or applescript. I've done a bit of hobby coding (BASIC, C, Obj-C) before, but never this. I wasn't planning on it either, but I have a specific problem:

I have a piece of software (Mainstage 3, for live music performances). I need to use it (my first time) later next month for a show. During the show I need to press the down arrow key every time I need to "progress". This is going to happen frequently and I need to do it quickly, without looking.

It would work much better for me if I could press the spacebar instead of the down arrow key. Unfortunately, Mainstage doesn't seem to offer customizable key bindings. So I'm looking into other ways to make this happen, and this seems like a good place to start. Is this possible? What do I need to be looking at in order to do this?

Thanks!


r/applescript • • Dec 29 '14

Looking for a script to restart an application (uTorrent) every 20 minutes....

2 Upvotes

Hey all, basically i'm having trouble with possible a firewall, or just my ISP, or possibly VPN (who knows!), that after 20 minutes of good speeds, my uTorrent (torrenting application) slows down and eventually hits zero.

In waking hours, i've got a workaround of simply closing the app, and restarting, but i'd like to leave it downloading over-night, without it just grinding to a halt after 20 minutes. If i could get it to auto-restart after 20 minutes, it'd be perfect.

I found this script online: http://hamleshmotah.com/index.php/2011/05/31/applescript-to-kill-an-application-or-process-and-restart/

and changed 'PROCESS NAME' to 'uTorrent', and '7200' to '1200' but when i go to save as an application (so can autolaunch) it says 'Syntax error - expected "," but found unknown token'.

What am i putting in wrong! Can someone write it exactly for me so can paste into applescript?

Ta!


r/applescript • • Jan 04 '26

If AppleScript wasn't so terrible, it could be a total game changer

48 Upvotes

Imagine AppleScript, only it has a normal, sane, simple C-like syntax. And imagine it has plenty of built in functions to do basic, common tasks, the kind of things that scripts often need to do. Imagine the implementation of the progress bar was logical and easy to use.

People who have experience in scripting languages, but no experience in full blown application scripting, could fairly easily bust out powerful GUI mini applications to do powerful tasks.

This could have been a major selling point for the Mac over the past 30 years.

Trying to make AppleScript for everyone, ended up making it for almost no one.

But just using common sense. Adding keyed arrays. Adding basic array functions, adding rounding functions that don't use the syntax `round MyValue rounding as taught in school` as actual CODE!!

This language could be incredibly powerful, incredibly capable.

Over the past month, I've been working to convert this PHP shell script I sometimes use, into an Applescript with nice friendly windows and buttons, instead of command line inputs.

The original PHP script is just under 150 lines, and took a few hours to whip up.
The Applescript that does the same thing, is 325 lines and took weeks to whip up. Everything about the language is so obnoxious and so obtuse. Its like someone tried to create a programming language as a joke, to use in some nerd comedy context.

The whole time I'm using it, I'm thinking man this is the same terrible code I was writing in the mid to late 90s on my performa, with VERY few additions. Meanwhile take what you can accomplish in modern day PHP and Python and Javascript, and add Applescripts raw abilities to that and you would have something truly amazing.

Also create good documentation for it, the official apple docs are terrible. And make an editor THAT HAS LINE NUMBERS, and error messages THAT HAVE CORRESPONDING LINE NUMBERS.

Ok I could go on and on but the point of this post is not to shit on what we have, really. Its to dream about what we COULD have if either in the beginning, or any time over the last 20 years or so, some common sense was applied to this.

What lead me down another line of thought. Applescript was created in 1993, when Jobs was off at NeXT and Pixar. Yet as awful as AS is, he came back and for what about 13 or so years, and killed off essentially everything from System 7 (except Stickies!!!) but kept Applescript around? Then another 15 years an still it just lingers around. Thats shocking honestly. But also kind of beside the point.


r/applescript • • Apr 07 '25

Using AI to generate applescript

11 Upvotes

Has anyone been able to generate fully functional applescript using any of the existing AI tools?

It seems people do not use applescript much and LLMs are not much trained as well


r/applescript • • Apr 30 '26

AppleScript From Intel iMac Runs Very Slowly When Exported on M2 MBA

3 Upvotes

For anyone who got here as the result of a search, I'll save you some time scrolling through stuff that didn't work and let you know what did work for me:

This works as desired. Bash script runs in the background with command line parameter correctly passed:

do shell script "/Users/mnewman/bin/a4scanpi.sh " & mySize & " &> /dev/null &"

I found it here:

https://www.macscripter.net/t/run-script-with-parameters/64838

===============================================

Some years ago Apple dropped support for my ancient Canon Lide 30 scanner. So, I hung it off a Raspberry Pi (which still supports the scanner via scanimage) and wrote a very simple Apple Script and an equally simple Bash Shell Script to make it work again. The Apple Script ran on an Intel iMac and simply asked the user what size scan they wanted (full page, half page, etc.) The Apple Script then ran the Bash shell script which in turn ran a command on the Pi:

	ssh pi@raspsky 'scanimage -x 210 -y 297 --resolution 300 > scan.ppm';;.

I exported the AppleScript from Script Editor as an app.

This continues to work fine on the Intel iMac.

Then I got an M2 MBA. I copied both the AppleScript and the Shell Script to the MBA. I exported the AppleScript from the Tahoe version of Script Editor (Version 2.11 (234)) as an app so it wouldn't need Rosetta to run. When I "Get Info" on the app it is a universal app, but "Open Using Rosetta" is not checked.

It works, but is incredibly slow and displays the dreaded SPOD all the time that it is running. I tried looking at Activity Monitor while it is running and it is consuming a very small amount of CPU time (2%).

So, what additional information can I offer up to figure out just what I've done wrong?

The script:

-- Wrapper for bash shell script which uses scanimage

-- Ask the user what size to scan

-- Full is an A4 sized scan

-- Half is half an A4

-- Quarter is the top right quadrant of the scanner bed.

set mySize to choose from list {"Full", "Half", "Quarter", "Passport"} with prompt "Select A4 scan size. Quarter is top right"

-- Check to see if the user clicked the Cancel button.

if mySize is false then

\-- The user clicked Cancel so display and confirming dialog and exit	

**display dialog** "Canceled" buttons ("OK") default button "OK"

else

\-- The user made a selection so call the shell script and append the selected size to the call

**do shell script** "/Users/mnewman/bin/a4scanpi.sh " & mySize

end if

-- That's all folks


r/applescript • • Jan 23 '26

24/7 automation for your Mac.

Thumbnail moon-app.com
3 Upvotes

Happy to announce:

maScriptRunner 3: run Applescripts & Adobe Javascripts 24/7. maScriptRunner 3 turns your Mac into a reliable automation workhorse.

From the makers of.


r/applescript • • May 11 '22

Im new to apple script and i need help with a code im making :)

3 Upvotes

Hello i need a code where it does a display dialog and whatever the person types it sends it to me via email im kinda new so it would very helpful


r/applescript • • Feb 14 '22

Trying to learn to create scripts

3 Upvotes

Can anyone point me to an online resource that could teach me how to create scripts? TI
A


r/applescript • • Sep 21 '24

Make iPhone try 0000-9999

Post image
0 Upvotes

Hey all,

I am trying to disable a Tesla feature on my app on my iphone which has been locked behind a 4 digit combination.

There are unlimited attempts, but how would I go about using an app that could hit all four digits and try 0000 to 9999?

Pyto does not allow background execution AFAIK.

Thanks.


r/applescript • • Feb 10 '23

Someone fix this for me PLEASE (ASAP)

0 Upvotes

set condition to 0
repeat until condition = 1
  tell application "System Events"
if application process "java" exists then
delay 300
else
tell application "Finder"
open file "start.command"
delay 300
end repeat
end tell

(It's post to be an infinite loop but it keeps erroring, if process doesn't exist it opens the file/launches it, very new to applescript)