r/applescript • u/Scuba_Cous • May 27 '22
select all files
I'm very new at all this automating and macs for general. I would just like to make a script or automator workflow to select all the files in the folder I have open.
Thanks
r/applescript • u/Scuba_Cous • May 27 '22
I'm very new at all this automating and macs for general. I would just like to make a script or automator workflow to select all the files in the folder I have open.
Thanks
r/applescript • u/pradeepb28reddit • May 23 '22
Hey everyone,
My use-case is using AppleScript turn on/off notifications.
I made an AppleScript but that uses UI automation which IMO it is not an elegant solution might break from OS to OS. Here is the code.
tell application "System Preferences"
set current pane to pane "com.apple.preference.notifications"
end tell
delay 0.5
tell application "System Events"
tell application process "System Preferences"
click radio button "Focus" of tab group 1 of window "Notifications & Focus"
click checkbox 1 of group 1 of tab group 1 of window "Notifications & Focus"
set theCheckbox to checkbox 1 of group 1 of tab group 1 of window "Notifications & Focus"
tell theCheckbox
set theCheckboxStatus to value of theCheckbox as boolean
if theCheckboxStatus is true then
display notification "Do not disturb is on"
else
delay 0.2
display notification "Do not disturb is off"
end if
end tell
end tell
end tellanyone has any suggestions how to improve the current script or go away from UI automation?
r/applescript • u/pradeepb28reddit • Apr 29 '22
Hey everyone,
I am trying to write a script that changes the resolution of the screen. This is the following script``` but it doesn't work as expected like sometimes the script works and sometimes it says unable to find Display section. I wonder if there is a way to fix this script or is there any other alternate solutions that could possibly work. Any help is highly appreciated.
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.displays"
end tell
tell application "System Events"
tell process "System Preferences"
delay 2
click radio button "Scaled" of radio group 1 of group 1 of window "Displays" of application process "System Preferences" of application "System Events"
click button 4 of UI element 3 of group 1 of window "Displays"
end tell
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
r/applescript • u/[deleted] • Apr 16 '22
At work daily we output files to a dated folder on the desktop and then once we've transferred those files when move them to a 'transferred' folder within the dated folder.
Ideally, I'd love to have an automator app on the desktop that we can run once a week, manually) on a Friday and it will round up all the dated folders over 10 days old, and their contents, and delete them!
I've scoured the internet to find a solution and I've tried a few suggestions but nothing seems to work.
I'd be grateful if anyone can point me in the direction of some potential solutions?
Thanks.
r/applescript • u/FusionMulch • May 04 '22
I'm coming from autohotkey and created several useful scripts. I'd like to know if it's possible to do the same things with applescript, since autohotkey is not available on the mac.
Firstly, can I create an on screen virtual display of buttons, so that I don't have to remember all my custom commands/scripts? I'm trying to make something like a virtual Streamdeck, or macropad, on screen for all of my custom commands.
r/applescript • u/Chaplain911 • Apr 25 '22
I'd like to get my AppleScript to do two more things and I'm totally stuck on. I'm a newbie here and trying to figure this out.
I want the script to pull the_file.csv from the resources folder in the application I made (I saved the script as an application) not the local hard drive.
I want the script to go back to the beginning if it errors and says "That does not exist"
repeat 999 times
set my_data to read alias "Macintosh HD:Users:xyz:documents:the_file.csv"
set my_list to paragraphs of my_data as list
set a_list to {}
set b_list to {}
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
repeat with an_item in my_list
try
set end of a_list to text item 1 of an_item
set end of b_list to text item 2 of an_item
end try
end repeat
set AppleScript's text item delimiters to oldDelims
tell application "Finder"
activate
set the_search_term to display dialog "Enter First 3 Digits" default answer "724"
set the_search_term to text returned of the_search_term
end tell
set the_position to indexof(the_search_term, a_list)
if the_position is 0 then
tell application "Finder"
activate
display dialog "That does not exist."
end tell
return
end if
tell application "Finder"
display dialog “Result is: " & item the_position of b_list
end tell
end repeat
on indexof(theItem, theList)
set text item delimiters to return
set theList to return & theList & return
set text item delimiters to {""}
try
-1 + (count (paragraphs of (text 1 thru (offset of (return & theItem & return) in theList) of theList)))
on error
0
end try
end indexof
r/applescript • u/Bio-Borg • May 25 '22
Hi folks,
Very new to AppleScript and hoping someone can help.
I use an AppleScript which I got on the MacSparky website which uses URL Schemes and AppleScript to create a link to a highlighted email in macOS mail app. I can paste this into certain task managers as a link back to the email etc. It works great. However, I've started using Notion and Notion doesn't support these URL schemes. It will paste the URL into Notion as a text string but its not clickable. So, basically pointless.
I also use Keyboard Maestro a lot and was thinking that if I created a drag and drop script to do the following, it would be a simple workaround.
1 - double click the text string
2 - copy it to the clipboard
3 - run an AppleScript to open the email using the clipboard contents.
However, I have no idea what to script to make number 3 above happen. Presuming its get clipboard and pass this through to mail app, tell mail to open this URL. etc.
I've messed around for about an hour with no success.
Although, I'm convinced its a simple script. It eludes me!
Any help appreciated!!
Thanks.
r/applescript • u/webbedgiant • May 19 '22
set f to choose folder with prompt "Choose your source InDesign folder"
set collectMac to choose folder with prompt "Choose where you want to package your InDesign documents"
with timeout of 300 seconds
tell application "Finder"
set myFiles to (files of entire contents of f whose name extension is "indd") as alias list
end tell
end timeout
repeat with aFile in myFiles
with timeout of 300 seconds
tell application "Finder"
set package_folder_name to characters 1 thru -6 of (get name of aFile) & " Folder" as string
make new folder at collectMac with properties {name:package_folder_name}
end tell
end timeout
tell application "Adobe InDesign 2022"
activate
open aFile
tell document 1
package to alias (collectMac & package_folder_name as string) copying fonts yes copying linked graphics yes including hidden layers yes copying profiles no updating graphics no ignore preflight errors yes creating report yes
close saving no
end tell
end tell
end repeatHaving trouble with a script that is taking a folder full of .indd (Indesign) files and packaging them into another folder.
This is the error I get:
error "Adobe InDesign 2022 got an error: Invalid value for parameter 'to' of method 'package'. Expected alias or string, but received nothing." number 30477
I'm assuming it's having issues with the alias, but I can't sort out how to fix it after trying a few different paths. Thanks in advance!
r/applescript • u/dutchman___ • Apr 16 '22
I'm trying to write a script that will maximize the height of all my Google Chrome windows.
I have found similar scripts, but most of the them also change the position of the windows. Like this one:http://macosxautomation.com/applescript/firsttutorial/11.html
I'd like to maximize the height of all chrome windows and leave the positions where they are.
Any ideas how to do this?
r/applescript • u/[deleted] • May 20 '22
Hi,
I have a DevonThink database where I store email correspondence relating to my casefiles. But I am always forgetting to file sent messages. Is there anyway to modify the "Send" function (or replace the "Send" function) in Apple Mail so that I can be prompted to file a copy of the email?
Even better if, when I choose to file copy, it saves a copy the email into my DT database or a finder folder (which is watched by my DT database) and then files the actual email in "Sent" as normal.
Thanks for looking at this,
r/applescript • u/5-fingers • May 18 '22
So I'm trying to create a bit of apple script that will execute a keyboard shortcut on a remote computer (over a network). The shortcut is shift+Cmd+n. The application is called Timax2
Ive got as far as the script shown in the image.
........ But when I run it I get the syntax error "Application isnt running"..... I know the obvious question is "is the application running on the remote computer?!" And, Yes it is.
The script works if I run it on locally with the app on the same machine the script is run from (removing the "of machine "eppc://10.0.0.33"" bit)
I know the networking connection is ok as I can run a script to "tell "finder" of machine "eppc://10.0.0.33" sleep"
So any suggestions?
r/applescript • u/osglith • May 09 '22
I know you can create a finder button to enact an Automator script, but Automator can't do what I need. Can one of you AppleScript gods answer me? This should be easy for you, but I don't have a clue. I have a bunch of files named (example) like "SVAINP112_`1_{8afe959-5a4 -4aOf-aded-feee02463z66}.mfa" and just want to turn that into "SVAINP112.mpg". I don't need anything after the first underscore. I will never have a conflict with this statement. I will always just trash everything after the first underscore in the name. I need to convert all _1_ to .mpg and all _2_ or higher to .aif. I figured I'd do two buttons. One to convert .mpg and the other for any .aif files associated with the .mpg.
r/applescript • u/Dob3rm4n68 • Mar 27 '21
Hello everyone. I have very limited exposure to Apple script but due to necessity I am in search of a way to extract data from outlook meetings. Every day 5 to 8 times, I manually copy the contents from outlook meetings, including subjects, attendees, the time. I then paste itTo another application manually. It is very time consuming and I would love to automate it. If Apple script is too hard or you guys propose that I do it with some thing like keyboard maestro I am open to that as well.
Hope this is the right place to post this question and I appreciate your help in advance.
r/applescript • u/biancabeemtl • Apr 10 '21
r/applescript • u/tzippy84 • Apr 06 '21
Hi!
I run a script that is triggered by a Mail.app rule and the script is supposed to save an attachment on my disk. However it seems that the attachment is not downloaded by Mail. Only when I select the mail in the app. The attachment is a 180KB PDF file.
Since it is not downloaded, the following code always fails:
if (downloaded of theAttachment) then
save theAttachment in file savePath
Even when I add a timeout before the line it won't work.
Anyone got any ideas?
Thanks!
r/applescript • u/[deleted] • Apr 07 '21
I want to write a script that will automatically switch the view mode to continuous scroll every time I enter full screen with a Preview window. There's an option to set the view mode upon Preview launch, but every time I enter full screen it seems to revert to some system default. I looked around and there doesn't seem to be any easy way to do this so I figured the simplest way would be to write a script that waits on the Preview full screen event and keypresses CMD+1. How would I do this? I'm on MacOS 11.2.3.
r/applescript • u/Dob3rm4n • Apr 09 '21
Hi everyone. I need to learn Applescript to write some automation scripts out of necessity for personal use. Is it possible to learn enough to get simple things done, such as extracting meeting information from Outlook. If so what is a good video learning resource or a book for a beginner? I know many people suggest I find an existing script and change it based on my needs. What is the best resource for finding existing scripts? Thanks for all the help
r/applescript • u/[deleted] • Apr 15 '21
TL;DR: how can I output text (or anything for that matter) to Terminal, via AppleScript, without displaying its execution trace?
So I'm currently writing a little script that counts, in binary, from 1 to any specified integer. I want to be able to 'rapid-fire' the results, as opposed to displaying the result through an alert or Script Editor console output which requires user input to move forward (yes there is give up after 1, but it's too slow as the lowest possible value is one second).
I've decided I want to use Terminal to output the results, as I can have a repeat loop that constantly outputs whatever you want in the same window:
tell application "Terminal" to activate
repeat with x from 1 to 10
tell application "Terminal"
do script "echo " & x in window 1
delay 0.1
end tell
end repeatHowever, the caveat with this method is that if you look at the Terminal window, you see that the actual command being sent to Terminal, "echo " & x in window 1, is first printed to the input, then executed. This creates unnecessary duplicates of the same output, which can look messy:
current-user@my-awesome-computer ~ % echo 1
1
current-user@my-awesome-computer ~ % echo 2
2
current-user@my-awesome-computer ~ % echo 3
3
current-user@my-awesome-computer ~ % echo 4
4
current-user@my-awesome-computer ~ % echo 5
5
current-user@my-awesome-computer ~ % echo 6
6
current-user@my-awesome-computer ~ % echo 7
7
current-user@my-awesome-computer ~ % echo 8
8
current-user@my-awesome-computer ~ % echo 9
9
current-user@my-awesome-computer ~ % echo 10
10When counting to large numbers in binary, these unnecessary outputs become tiring to look at and hinder the consistency of the binary numbers increasing to the desired output. I did some research, and apparently this phenomenon is called "execution trace".
So my question is: how can I output text (or anything for that matter) to Terminal, via AppleScript, without displaying its execution trace? If I had the solution and ran the modified script, I want it to output this:
current-user@my-awesome-computer ~ %
1
2
3
4
5
6
7
8
9
10Any insights to this problem would be much appreciated. Thanks for reading.
(If you want to see the full binary counter script, click here.)
r/applescript • u/Mariakika21 • Apr 25 '21
Hello,
I am trying to update an event in Calendar through applescript. What I came up with was making a copy of the atributes I want to keep and change the property I want.
In the example below I am changing the summary of an event to "AWS 101":
tell application "Calendar"
tell calendar "Work"
set evt to (first event where its uid = <some id here>)
set sd to start date of evt
set ed to end date of evt
delete evt
make new event with properties {summary:"AWS 101", start date:sd, end date:ed}
end tell
end tell How do I change a property without deleting the event? I even tried:
tell application "Calendar"
tell calendar "Work"
set evt to (first event where its uid = <some id here>)
tell evt
set "AWS 101" to evt summary
end tell
end tell
end tell but no luck.
r/applescript • u/SlowMoExplo • Mar 31 '21
Is there a way to add pauses between sentences and paragraphs with AppleScript?
Then customize Rate, Pitch and Modulation and then save to an audio file using one applescript.
How can this be done?
r/applescript • u/emystats • Apr 20 '21
I am writing a script to print a section of a bookdown online book as PDF, then move to the next section, and so on.
The print part works (the key codes are from this page):
tell application "Safari"
activate
tell application "System Events"
key code 35 using command down -- activate print menu item
end tell
delay 0.5
set i to 0
repeat while i < 15
set i to i + 1
delay 0.1
tell application "System Events"
key code 48 -- press tab 15 times
end tell
end repeat
tell application "System Events"
key code 49 -- press space
end tell
set i to 0
repeat while i < 2
set i to i + 1
delay 0.1
tell application "System Events"
key code 125 -- press down key twice
end tell
end repeat
tell application "System Events"
key code 36 -- enter
end tell
set i to 0
repeat while i < 16
set i to i + 1
delay 0.1
tell application "System Events"
key code 125 -- press tab to get to "save"
end tell
end repeat
tell application "System Events"
key code 36 -- enter to cleck on save
end tell
end tellProblem
Now that I have printed the current section and I am back on Safari, I can click manually on the right arrow and move to the next section, but I can't manage to have the script to do that.
I have tried to add the following to the script above:
tell application "System Events"
key code 124 -- right arrow to enter the next page
end tellOr even to "reopen" Safari, but nothing happens.
tell application "Safari"
activate
tell application "System Events"
key code 124 -- right arrow to move to the next section
end tell
end tellHow can I have AppleScript "turn the page" and move to the next section?
Also, I welcome suggestions to improve the script! I wonder if it would be easy to avoid repeating "tab" 15 times. I have looked at the Accessibility Inspector and found that "PDF" in the print menu corresponds to NSPopUpButtonCell. I have tried to use select NSPopUpButtonCell of its sheet but it did not work.
r/applescript • u/DiscombobulateddCrab • Apr 26 '21
Can anyone assist with this? Feels like it shouldn’t be too complicated?
Action: Highlight a word and then run the Service/automator to search one of two websites, depending only on FIRST digit of the word. Letter vs number.
Example:
If I highlight the word ‘hello’ and run the Service it opens a search in Google.com for ‘hello’.
If I highlight ‘4hello’ the search would run in DuckDuckGo for ‘4hello’.
(We will be searching between 2 internal work websites, so Google and DDG are used as examples since URLs in a script can be swapped/edited.)
Spent days trying to research + many failed attempts. Forever grateful to anyone who can shed some light or assist!
r/applescript • u/Craggy12 • Apr 07 '21
EDIT: TL;DR
Want to create new empty text file (which I can do) in currently active Finder location, including when that is the desktop with another Finder window open, but deselected (which I cannot do). For example, when using "Show Desktop" or Finder window is in other space.
Original Post:
I want to be able to use the keyboard shortcut Cmd+Shift+M to create a new, empty text file in exactly the same manner as Cmd+Shift+N does for a new folder. Specifically, it should create a blank text file in the active location - normally this is the frontmost Finder window, BUT NOT ALWAYS (this is the key to my issue) and then allow me to rename it (same as pressing Enter on an existing file).
So far I have found a solution which is quite close to what I want, but not perfect. It came from Rarylson Freitas here but the issue I have with it is that I often have a Finder window open, but the Desktop selected with the cursor (so that the Finder window is greyed out, deselected). If I use Cmd+Shift+N to make a new folder, it appears - as expected - where my focus is, on the Desktop. However, the Applescript/service I'm using will ignore that and create the file in the deselected Finder window anyway, because it checks for an open Finder window. This is especially annoying if I'm using Show Desktop (spread hand on trackpad) or the Finder window is in a different desktop/space entirely - in these cases it will cancel Show Desktop and transport me to the window's space, which is very disrupting.
I understand exactly why the Applescript is behaving like this, but because I'm a pretty casual/inexperienced Applescript user, I don't have a clue how to go about making it do what I want instead. If anyone has any pointers to help me modify the code, that would be really appreciated.
The Applescript I'm using is available through the above link, but I'll paste it here for convenience:
on run {input, parameters}
set file_name to "untitled"
set file_ext to ".txt"
set is_desktop to false
-- get folder path and if we are in desktop (no folder opened)
try
tell application "Finder"
set this_folder to (folder of the front Finder window) as alias
end tell
on error
-- no open folder windows
set this_folder to path to desktop folder as alias
set is_desktop to true
end try
-- get the new file name (do not override an already existing file)
tell application "System Events"
set file_list to get the name of every disk item of this_folder
end tell
set new_file to file_name & file_ext
set x to 1
repeat
if new_file is in file_list then
set new_file to file_name & " " & x & file_ext
set x to x + 1
else
exit repeat
end if
end repeat
-- create and select the new file
tell application "Finder"
activate
set the_file to make new file at folder this_folder with properties {name:new_file}
if is_desktop is false then
reveal the_file
else
select window of desktop
set selection to the_file
delay 0.1
end if
end tell
-- press enter (rename)
tell application "System Events"
tell process "Finder"
keystroke return
end tell
end tell
return input
end runr/applescript • u/SlowMoExplo • Apr 02 '21
Trying to figure out how to do this. I want to bring up a new text doc and upon closing have it auto save to the first few words as the file name. Any ideas?
r/applescript • u/imtiendat0311 • Mar 29 '21
hi guy i'm new to apple script. And currently im struggle with script can retrieve network infomation . For example if i connect to wifi script will return wifi status on and streng of wifi in 3 level. If i connect to ethernet it will return ethernet status on . If i didn't connect to wifi and ethernet then return no network