AppleScript

RSS for tag

AppleScript allows users to directly control scriptable Macintosh applications as well as parts of macOS itself.

Posts under AppleScript tag

200 Posts

Post

Replies

Boosts

Views

Activity

Looking for help with writing a script
Hello, I'm currently trying to write a script using AppleScript, but I'm having trouble figuring out how to do it. Basically, I'm trying to write a script that will hold down the "a" and "w" keys at the same time, and will continue to do so until I manually terminate the program. However, I'm not sure how to do this, and I don't even know if this is actually possible in AppleScript. Does anyone know how to code this, and if it's even possible to begin with? I'd greatly appreciate any help.
1
0
708
Mar ’23
How to pause Now Playing.
Hello, I'm looking for a way to pause a video that's playing on another player or browser. I need to pause the video because my app launches when users take a screenshot while watching a video, and it would be more convenient for them if they could pause the video at that moment. I know it's not easy to pause a video playing in another app, but I'm exploring the option of using Control Center > Now Playing to see if I can pause it that way. However, I can't seem to find a way to control Now Playing through shortcuts or Applescript, so I'm posting this message to see if anyone has any ideas or solutions. If you have any good ideas or solutions, please let me know. Thank you.
0
0
1.2k
Feb ’23
Click Drag function. Need Help with this Script I get Syntax Errors.
tell application "System Events"     set theF24Down to false     set theF23Down to false     set startMouseCoordinate to {}     on key down theKey         if theKey is "F24" then             set theF24Down to true             set startMouseCoordinate to get mouse location             set xCoordinate to (startMouseCoordinate's x)             set yCoordinate to (startMouseCoordinate's y)             set endTime to (current date) + (350 * milliseconds)             mouse down at {xCoordinate, yCoordinate}             repeat                 set mouseCoordinate to get mouse location                 if mouseCoordinate is not {xCoordinate, yCoordinate} then                     set endTime to (current date) + (350 * milliseconds)                     set xCoordinate to (mouseCoordinate's x)                     set yCoordinate to (mouseCoordinate's y)                 end if                 if (current date) > endTime then                     exit repeat                 end if             end repeat             mouse up at {xCoordinate, yCoordinate}             mouse move {xCoordinate, yCoordinate + 10}             set mouse position to startMouseCoordinate         else if theKey is "F23" then             set theF23Down to true             set startMouseCoordinate to get mouse location             set xCoordinate to (startMouseCoordinate's x)             set yCoordinate to (startMouseCoordinate's y)             set endTime to (current date) + (350 * milliseconds)             mouse down at {xCoordinate, yCoordinate}             repeat                 set mouseCoordinate to get mouse location                 if mouseCoordinate is not {xCoordinate, yCoordinate} then                     set endTime to (current date) + (350 * milliseconds)                     set xCoordinate to (mouseCoordinate's x)                     set yCoordinate to (mouseCoordinate's y)                 end if                 if (current date) > endTime then                     exit repeat                 end if             end repeat             mouse up at {xCoordinate, yCoordinate}             mouse move {xCoordinate, yCoordinate - 10}             set mouse position to startMouseCoordinate         end if     end key down end tell Hello I wanted to remap an F23/F24 keys to do an action when I press them. All I want is similar to a Click and Drag function.
1
0
620
Feb ’23
Add songs to Library in Music?
I've been searching for this for a few days now and haven't been able to find an answer. I use BetterTouchTool to customize my touchbar, and I've added an action that will love a song in Apple Music like so: if is_app_running "Music" then tell application "Music" try if current track is loved then return "loved" else return "love" end if on error return "" end try end tell else return "" end if end tell This works, but I realized that having a Smart Playlist of Loved songs means nothing if the songs aren't also in your Library. So, I tried figuring out how to also add songs to my Library when they're loved. I tried this: try duplicate current track to playlist "Library" on error duplicate current track to source "Library" end try end tell And it worked sometimes. I had to have the two versions in there for playlist and source because I found one worked for the auto-generated playlists Apple Music makes (like the "New For You" weekly playlist) versus songs from albums or your radio playlist. This is very unreliable. Sometimes it works, sometimes it doesn't. Honestly, most times it doesn't. It's hard to find any real documentation on how to work with Apple Music with AppleScript. I've gone through the Window -> Library view in the Script Editor and can see the list of possible actions and objects, but there's no direction on how they interact. For example, I would think you could simple do add current track to library playlist but that doesn't work at all. Any time I've tried using add with a track, I get an error that the track "doesn't understand the 'add' message". Is there a simple, consistent way to add songs to my Library through AppleScript? Maybe bonus points if it's an add instead of a duplicate? If I manually click and add a song to my Library, it's simple added – but with this AppleScript, I have to duplicate it instead of simply adding. Any help would be appreciated!
8
0
4.0k
Jan ’23
Need help to set up path to my icloud drive to automatically save my screencapture to it. Thanks!!
set dFolder to "/Library/Mobile"Documents/comapple~CloudDocs/" do shell script ("mkdir -p " & dFolder) set leftX to 2160 as integer #use SHIFT + CMD + 4 to get coordinates set leftY to 3840 as integer set rightX to -1080 as integer set rightY to -1920 as integer #set numberOfpages to 7 as integer #how pany pages? #set i to 0 #repeat numberOfpages times start 7:34am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" delay 240 7:38am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" delay 1620 8:05am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" #tell application "System Events" #option 1: keyboard click key code 124 #arrow right click on keyboard #end tell #tell application "System Events" #option 2: mouse click click at {123, 456} #mouse click at location #end tell delay 3600 #set i to i + 1 9:05am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" delay 10800 12:05pm set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" #end repeat delay 6900 2:00pm set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png"
0
0
947
Jan ’23
Deleting app(.app extension) after the execution complete is not working in Mac OS
I am working on the Project and i'm facing technical issue. It is a exported app from applescript and i'm performing self delete means after the execution is complete it destroys from that location. I'm using the below shell script in applescript to invoke deletion **do shell script "sleep 5 && rm -rf " The .app path posix location" &"** When i run locally it is working perfectly but after codesign it is not working. Also when we copy the file to other location then it is working. I'm little confused and not able to identify the issue. Please help me out and really appreciate your help. Thanks & Regards, Rajkumar V
0
1
865
Jan ’23
Contacts does not allow apple Events
On both Ventura 13 and beta 13.1 this failed but in Monterey it works fine. I tried tccutil reset Contacts and I got tccutil: Failed to reset Contacts I tried tccutil reset AppleEvents and it was successful. I restarted and tried again. I executed count of groups again and I was asked to allow Contacts to be controlled. I answered yes and then I got Not allowed as in the attached screen shot Thanks for your help
2
0
984
Nov ’22
Ventura – Applescript applets no longer hide ?
Ventura 12.3 seems to have broken part of my Applescript applet – it no longer hides reliably. Previously pressing command-h or choosing the app menu=>Hide [applet] would cause the applet to hide. This has been working for over 5 years. Now, sometimes, the applet does not hide – instead it just loses the focus. Then, clicking on the applet does not give it the focus – but clicking on the titlebar does. But, often, the applet hides normally. I can't find a pattern except it might make a difference if hiding the applet would shift focus to Finder. If this is due to an announced change in Ventura can someone point me to the documentation ? Otherwise, what could be going on ? Thanks.
4
0
1.5k
Nov ’22
In Applescript, how can I set the format of a range of cells in a Numbers table to a numeric format with a specified number of decimals?
The Numbers library for Applescript supports setting the format of a range to several types, including "number", but there does not seem to be a way to set the number of decimals, or the format for negative numbers, or the thousands separator. Can someone help me with a way to do this, perhaps using System Events if there is no better way?
3
0
2.1k
Nov ’22
AppleScript for Mail Attachments fails to run under 12.4
I used this script to automatically save attachments of some incoming messages in apple mail. Sine Monterey, this doesn't work anymore. Syntax check gives no errors, but in my mail rules the script doesn't run at all. I did a lot of research to find a solution, with no success. Any help is appreciated. Marcus This is the code … using terms from application "Mail" on perform mail action with messages theMessages for rule theRule -- set up the attachment folder path tell application "Finder" set folderName to "WebApp-Beiträge Mail" set attachmentsFolder to ("Volumes:Daten HD:Workspace:Universität_Saarland:projekte_Universität_Saarland:2070_uni_2101_WebDev_WebApp:struktur_text_navigation_2070:Beiträge:" & folderName) as text end tell tell application "Mail" repeat with eachMessage in theMessages --set the sub folder for the attachments to the senders mail address. -- All future attachments from this sender will the be put here. set subFolder to (extract address from reply to of eachMessage) -- set up the folder name for this mail message's attachments. We use the time stamp of the  date received time stamp set {year:y, month:m, day:d, hours:h, minutes:min} to eachMessage's date received --set timeStamp to (y & "-" & my pad(d) & "-" & my pad(m as integer) & "_" & my pad(h) & "-" & my pad(min)) as string -- month as number set timeStamp to (y & "-" & my pad(m as integer) & "-" & my pad(d) & "_" & my pad(h) & "-" & my pad(min)) as string -- month as number yyy-mm-dd --set timeStamp to (y & "_" & my pad(d) & "-" & m & "_" & my pad(h) & "-" & my pad(min)) as string set attachCount to count of (mail attachments of eachMessage) if attachCount is not equal to 0 then -- use the unix /bin/test command to test if the timeStamp folder  exists. if not then create it and any intermediate directories as required if (do shell script "/bin/test -e " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder & "/" & timeStamp) & " ; echo $?") is "1" then -- 1 is false do shell script "/bin/mkdir -p " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder & "/" & timeStamp) end if try -- Save the attachment repeat with theAttachment in eachMessage's mail attachments set originalName to name of theAttachment set savePath to attachmentsFolder & ":" & subFolder & ":" & timeStamp & ":" & originalName try save theAttachment in file (savePath) end try end repeat --on error msg --display dialog msg end try end if end repeat end tell end perform mail action with messages end using terms from on pad(n) return text -2 thru -1 of ("0" & n) end pad
1
0
2.1k
Nov ’22
Automate live text copy from Mac preview in image
I have bunch of images in a folder where I'm trying to copy live text from each image and paste it in text file I am trying to use AppleScript to open image in Preview->Text selection-> Command + a but its not selecting live text its just selecting image. I am open to using any swift script to suggest me how to process my images to get live text. Thanks. Apple script tell application "Finder" set fl to files of folder POSIX file "/Users/Data" as alias list end tell repeat with f in fl tell application "Preview" activate open f tell application "System Events" tell its process "Preview" click menu item "Text Selection" of menu "Tools" of menu bar 1 end tell end tell delay 5 tell application "System Events" tell application process "Preview" click at {100, 200} delay 2 keystroke "a" using command down delay 1 end tell end tell delay 30 repeat until (count of windows) > 0 delay 2.0 end repeat close front document end tell end repeat
0
0
1.5k
Nov ’22
Apple Script: File Renaming
I have a folder with several subfolders. Each subfolder contains several images. I want to rename the images in each subfolder to folder_name & "_" & file_name, meaning I want to add the folder name to the image file name. Subsequently I want to move all images from the subfolders to the main folder and delete the subfolders. I have the image of my script attached. It returns the attached error message. Who can help me ?
2
0
691
Nov ’22
curl not working properly under Monterey (12.3.1)
We have a problem with curl. Under Big Sur, the command curl 'ftp://ftp.myserver/myPath/my File' -u 'myusername':'mypassword' properly downloads the file. Under Monterey, the same command throws an error: curl: (3) URL using bad/illegal format or missing URL Any advice, workaround etc. is highly appreciated. The behaviour is the same, whether the command is issued in Terminal, or as a shell script in a Applescript application created in XCode.
4
0
3.1k
Nov ’22
applescript script stopped working after 12.0.1 (Monterey) upgrade
I have simple script to turn down the brightness of my MacBook Pro via an AppleScript. This worked fine in BigSur, but has stopped working after I upgraded to Monterey 12.0.1. The script is as follows: tell application "System Preferences" reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays" end tell tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display" set value of value indicator 1 of slider 1 of tab group 1 to 0.0 end tell ..error is as follows in script editor: error "System Events got an error: Can’t set window \"Built-in Retina Display\" of process \"System Preferences\" to 0.0." number -10006 from window "Built-in Retina Display" of process "System Preferences" Any suggestions on what to modify to get it working again?
7
0
5.6k
Oct ’22
Is there a simple applescript to renew the DHCP Lease...
of the currently configured network?
Replies
3
Boosts
0
Views
784
Activity
Mar ’23
Looking for help with writing a script
Hello, I'm currently trying to write a script using AppleScript, but I'm having trouble figuring out how to do it. Basically, I'm trying to write a script that will hold down the "a" and "w" keys at the same time, and will continue to do so until I manually terminate the program. However, I'm not sure how to do this, and I don't even know if this is actually possible in AppleScript. Does anyone know how to code this, and if it's even possible to begin with? I'd greatly appreciate any help.
Replies
1
Boosts
0
Views
708
Activity
Mar ’23
How to pause Now Playing.
Hello, I'm looking for a way to pause a video that's playing on another player or browser. I need to pause the video because my app launches when users take a screenshot while watching a video, and it would be more convenient for them if they could pause the video at that moment. I know it's not easy to pause a video playing in another app, but I'm exploring the option of using Control Center > Now Playing to see if I can pause it that way. However, I can't seem to find a way to control Now Playing through shortcuts or Applescript, so I'm posting this message to see if anyone has any ideas or solutions. If you have any good ideas or solutions, please let me know. Thank you.
Replies
0
Boosts
0
Views
1.2k
Activity
Feb ’23
AppleScript Photos
It is not possible to open a different Library with AppleScript. It always open the last opened library. tell application "Photos" open "/home/benutzer/Pictures/Testlibrary.photoslibrary" activate end tell
Replies
1
Boosts
0
Views
816
Activity
Feb ’23
NSAppleScript run Error
I just run a very simple NSAppleScript: "do shell script \"echo command\" with administrator privileges" However, I got error as below: NSAppleScriptErrorNumber = "-2147450879"; But it works fine on my friend‘s mac, anybody know how to solve this problem.
Replies
5
Boosts
0
Views
2.6k
Activity
Feb ’23
Click Drag function. Need Help with this Script I get Syntax Errors.
tell application "System Events"     set theF24Down to false     set theF23Down to false     set startMouseCoordinate to {}     on key down theKey         if theKey is "F24" then             set theF24Down to true             set startMouseCoordinate to get mouse location             set xCoordinate to (startMouseCoordinate's x)             set yCoordinate to (startMouseCoordinate's y)             set endTime to (current date) + (350 * milliseconds)             mouse down at {xCoordinate, yCoordinate}             repeat                 set mouseCoordinate to get mouse location                 if mouseCoordinate is not {xCoordinate, yCoordinate} then                     set endTime to (current date) + (350 * milliseconds)                     set xCoordinate to (mouseCoordinate's x)                     set yCoordinate to (mouseCoordinate's y)                 end if                 if (current date) > endTime then                     exit repeat                 end if             end repeat             mouse up at {xCoordinate, yCoordinate}             mouse move {xCoordinate, yCoordinate + 10}             set mouse position to startMouseCoordinate         else if theKey is "F23" then             set theF23Down to true             set startMouseCoordinate to get mouse location             set xCoordinate to (startMouseCoordinate's x)             set yCoordinate to (startMouseCoordinate's y)             set endTime to (current date) + (350 * milliseconds)             mouse down at {xCoordinate, yCoordinate}             repeat                 set mouseCoordinate to get mouse location                 if mouseCoordinate is not {xCoordinate, yCoordinate} then                     set endTime to (current date) + (350 * milliseconds)                     set xCoordinate to (mouseCoordinate's x)                     set yCoordinate to (mouseCoordinate's y)                 end if                 if (current date) > endTime then                     exit repeat                 end if             end repeat             mouse up at {xCoordinate, yCoordinate}             mouse move {xCoordinate, yCoordinate - 10}             set mouse position to startMouseCoordinate         end if     end key down end tell Hello I wanted to remap an F23/F24 keys to do an action when I press them. All I want is similar to a Click and Drag function.
Replies
1
Boosts
0
Views
620
Activity
Feb ’23
Add songs to Library in Music?
I've been searching for this for a few days now and haven't been able to find an answer. I use BetterTouchTool to customize my touchbar, and I've added an action that will love a song in Apple Music like so: if is_app_running "Music" then tell application "Music" try if current track is loved then return "loved" else return "love" end if on error return "" end try end tell else return "" end if end tell This works, but I realized that having a Smart Playlist of Loved songs means nothing if the songs aren't also in your Library. So, I tried figuring out how to also add songs to my Library when they're loved. I tried this: try duplicate current track to playlist "Library" on error duplicate current track to source "Library" end try end tell And it worked sometimes. I had to have the two versions in there for playlist and source because I found one worked for the auto-generated playlists Apple Music makes (like the "New For You" weekly playlist) versus songs from albums or your radio playlist. This is very unreliable. Sometimes it works, sometimes it doesn't. Honestly, most times it doesn't. It's hard to find any real documentation on how to work with Apple Music with AppleScript. I've gone through the Window -> Library view in the Script Editor and can see the list of possible actions and objects, but there's no direction on how they interact. For example, I would think you could simple do add current track to library playlist but that doesn't work at all. Any time I've tried using add with a track, I get an error that the track "doesn't understand the 'add' message". Is there a simple, consistent way to add songs to my Library through AppleScript? Maybe bonus points if it's an add instead of a duplicate? If I manually click and add a song to my Library, it's simple added – but with this AppleScript, I have to duplicate it instead of simply adding. Any help would be appreciated!
Replies
8
Boosts
0
Views
4.0k
Activity
Jan ’23
Missing Applescript
Just purchased a Mac Mini, and the Applescript folder is empty. Any ideas what happened/where it might be?
Replies
3
Boosts
0
Views
761
Activity
Jan ’23
Need help to set up path to my icloud drive to automatically save my screencapture to it. Thanks!!
set dFolder to "/Library/Mobile"Documents/comapple~CloudDocs/" do shell script ("mkdir -p " & dFolder) set leftX to 2160 as integer #use SHIFT + CMD + 4 to get coordinates set leftY to 3840 as integer set rightX to -1080 as integer set rightY to -1920 as integer #set numberOfpages to 7 as integer #how pany pages? #set i to 0 #repeat numberOfpages times start 7:34am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" delay 240 7:38am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" delay 1620 8:05am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" #tell application "System Events" #option 1: keyboard click key code 124 #arrow right click on keyboard #end tell #tell application "System Events" #option 2: mouse click click at {123, 456} #mouse click at location #end tell delay 3600 #set i to i + 1 9:05am set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" delay 10800 12:05pm set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png" #end repeat delay 6900 2:00pm set formattedDate to (do shell script "date +'%Y-%m-%d__%H.%M'") do shell script "screencapture -x -R" & leftX & "," & leftY & "," & rightX - leftX & "," & rightY - leftY & " " & dFolder & formattedDate & ".png"
Replies
0
Boosts
0
Views
947
Activity
Jan ’23
How would I Activate a window using its Window index on applescript?
I open two windows of vscode , now I want to activate vscode with specific index or name . I don't know how to write the script . tell application "Google Chrome" to set index of window 2 to 2 delay 0.05 do shell script "open -a Google\\ Chrome" it work with chrome ,but dont work with visual studio code .
Replies
1
Boosts
0
Views
1.7k
Activity
Jan ’23
Deleting app(.app extension) after the execution complete is not working in Mac OS
I am working on the Project and i'm facing technical issue. It is a exported app from applescript and i'm performing self delete means after the execution is complete it destroys from that location. I'm using the below shell script in applescript to invoke deletion **do shell script "sleep 5 && rm -rf " The .app path posix location" &"** When i run locally it is working perfectly but after codesign it is not working. Also when we copy the file to other location then it is working. I'm little confused and not able to identify the issue. Please help me out and really appreciate your help. Thanks & Regards, Rajkumar V
Replies
0
Boosts
1
Views
865
Activity
Jan ’23
Contacts does not allow apple Events
On both Ventura 13 and beta 13.1 this failed but in Monterey it works fine. I tried tccutil reset Contacts and I got tccutil: Failed to reset Contacts I tried tccutil reset AppleEvents and it was successful. I restarted and tried again. I executed count of groups again and I was asked to allow Contacts to be controlled. I answered yes and then I got Not allowed as in the attached screen shot Thanks for your help
Replies
2
Boosts
0
Views
984
Activity
Nov ’22
Ventura – Applescript applets no longer hide ?
Ventura 12.3 seems to have broken part of my Applescript applet – it no longer hides reliably. Previously pressing command-h or choosing the app menu=>Hide [applet] would cause the applet to hide. This has been working for over 5 years. Now, sometimes, the applet does not hide – instead it just loses the focus. Then, clicking on the applet does not give it the focus – but clicking on the titlebar does. But, often, the applet hides normally. I can't find a pattern except it might make a difference if hiding the applet would shift focus to Finder. If this is due to an announced change in Ventura can someone point me to the documentation ? Otherwise, what could be going on ? Thanks.
Replies
4
Boosts
0
Views
1.5k
Activity
Nov ’22
In Applescript, how can I set the format of a range of cells in a Numbers table to a numeric format with a specified number of decimals?
The Numbers library for Applescript supports setting the format of a range to several types, including "number", but there does not seem to be a way to set the number of decimals, or the format for negative numbers, or the thousands separator. Can someone help me with a way to do this, perhaps using System Events if there is no better way?
Replies
3
Boosts
0
Views
2.1k
Activity
Nov ’22
AppleScript for Mail Attachments fails to run under 12.4
I used this script to automatically save attachments of some incoming messages in apple mail. Sine Monterey, this doesn't work anymore. Syntax check gives no errors, but in my mail rules the script doesn't run at all. I did a lot of research to find a solution, with no success. Any help is appreciated. Marcus This is the code … using terms from application "Mail" on perform mail action with messages theMessages for rule theRule -- set up the attachment folder path tell application "Finder" set folderName to "WebApp-Beiträge Mail" set attachmentsFolder to ("Volumes:Daten HD:Workspace:Universität_Saarland:projekte_Universität_Saarland:2070_uni_2101_WebDev_WebApp:struktur_text_navigation_2070:Beiträge:" & folderName) as text end tell tell application "Mail" repeat with eachMessage in theMessages --set the sub folder for the attachments to the senders mail address. -- All future attachments from this sender will the be put here. set subFolder to (extract address from reply to of eachMessage) -- set up the folder name for this mail message's attachments. We use the time stamp of the  date received time stamp set {year:y, month:m, day:d, hours:h, minutes:min} to eachMessage's date received --set timeStamp to (y & "-" & my pad(d) & "-" & my pad(m as integer) & "_" & my pad(h) & "-" & my pad(min)) as string -- month as number set timeStamp to (y & "-" & my pad(m as integer) & "-" & my pad(d) & "_" & my pad(h) & "-" & my pad(min)) as string -- month as number yyy-mm-dd --set timeStamp to (y & "_" & my pad(d) & "-" & m & "_" & my pad(h) & "-" & my pad(min)) as string set attachCount to count of (mail attachments of eachMessage) if attachCount is not equal to 0 then -- use the unix /bin/test command to test if the timeStamp folder  exists. if not then create it and any intermediate directories as required if (do shell script "/bin/test -e " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder & "/" & timeStamp) & " ; echo $?") is "1" then -- 1 is false do shell script "/bin/mkdir -p " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder & "/" & timeStamp) end if try -- Save the attachment repeat with theAttachment in eachMessage's mail attachments set originalName to name of theAttachment set savePath to attachmentsFolder & ":" & subFolder & ":" & timeStamp & ":" & originalName try save theAttachment in file (savePath) end try end repeat --on error msg --display dialog msg end try end if end repeat end tell end perform mail action with messages end using terms from on pad(n) return text -2 thru -1 of ("0" & n) end pad
Replies
1
Boosts
0
Views
2.1k
Activity
Nov ’22
Automate live text copy from Mac preview in image
I have bunch of images in a folder where I'm trying to copy live text from each image and paste it in text file I am trying to use AppleScript to open image in Preview->Text selection-> Command + a but its not selecting live text its just selecting image. I am open to using any swift script to suggest me how to process my images to get live text. Thanks. Apple script tell application "Finder" set fl to files of folder POSIX file "/Users/Data" as alias list end tell repeat with f in fl tell application "Preview" activate open f tell application "System Events" tell its process "Preview" click menu item "Text Selection" of menu "Tools" of menu bar 1 end tell end tell delay 5 tell application "System Events" tell application process "Preview" click at {100, 200} delay 2 keystroke "a" using command down delay 1 end tell end tell delay 30 repeat until (count of windows) > 0 delay 2.0 end repeat close front document end tell end repeat
Replies
0
Boosts
0
Views
1.5k
Activity
Nov ’22
Apple Script: File Renaming
I have a folder with several subfolders. Each subfolder contains several images. I want to rename the images in each subfolder to folder_name & "_" & file_name, meaning I want to add the folder name to the image file name. Subsequently I want to move all images from the subfolders to the main folder and delete the subfolders. I have the image of my script attached. It returns the attached error message. Who can help me ?
Replies
2
Boosts
0
Views
691
Activity
Nov ’22
Applescript to get title from Keynote slide
I am trying to get the title of the slides.  But it is not working with apple script, can anyone please help me with this? This is the code I have written in AppleScript. tell application "Keynote" activate tell the first slide set slideone to first slide of document 1 set mytitlename to title of slideone end tell end tell
Replies
1
Boosts
0
Views
1.7k
Activity
Nov ’22
curl not working properly under Monterey (12.3.1)
We have a problem with curl. Under Big Sur, the command curl 'ftp://ftp.myserver/myPath/my File' -u 'myusername':'mypassword' properly downloads the file. Under Monterey, the same command throws an error: curl: (3) URL using bad/illegal format or missing URL Any advice, workaround etc. is highly appreciated. The behaviour is the same, whether the command is issued in Terminal, or as a shell script in a Applescript application created in XCode.
Replies
4
Boosts
0
Views
3.1k
Activity
Nov ’22
applescript script stopped working after 12.0.1 (Monterey) upgrade
I have simple script to turn down the brightness of my MacBook Pro via an AppleScript. This worked fine in BigSur, but has stopped working after I upgraded to Monterey 12.0.1. The script is as follows: tell application "System Preferences" reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays" end tell tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display" set value of value indicator 1 of slider 1 of tab group 1 to 0.0 end tell ..error is as follows in script editor: error "System Events got an error: Can’t set window \"Built-in Retina Display\" of process \"System Preferences\" to 0.0." number -10006 from window "Built-in Retina Display" of process "System Preferences" Any suggestions on what to modify to get it working again?
Replies
7
Boosts
0
Views
5.6k
Activity
Oct ’22