Automation & Scripting

RSS for tag

Learn about scripting languages and automation frameworks available on the platform to automate repetitive tasks.

Automation & Scripting Documentation

Post

Replies

Boosts

Views

Activity

AppleScript File not open with write permission error
I have an applescript that works perfectly on my local machine. It opens the file and writes to it and then closes. My Applescript is being tested and saved as a .app so it is an application. When I put the application on my server to test out the user experience it never propely opens the file and gives me this error:"File not open with write permission.Finder got an error: File not open with write permission. (-61)"Why would this work on my local machine and not work after being downloaded from my server? I have tested that my path's are correct and like I mentioned everything works perfectly on my local MAC machine. Here is the section of my Applescript code that seems to be throwing the error:set motionFullPath to ("" & pathEffects & "" & effectPlugin & ":" & theFolders & ":" & motionFiles & "") as string set myFile to open for access file motionFullPath with write permission set endOfFile to (get eof myFile) as number if result > 0 then set theText to read myFile set eof myFile to endOfFile write "<!--uuid:" & theURL & "-->" & return & theText to myFile end if close access myFile
2
0
1.9k
Apr ’17
Constant "Your session has expired" (error 1100)
Trying to do a CLI build with XCode (using NativeScript).Was working fine a couple days ago. However, now I cannot get past this error when trying to build:DTDeviceKit: deviceType from 7c64d8a014fd573ca3623ef80b158e57e7aea7c5 was NULL2018-05-07 11:57:54.696 xcodebuild[14808:865317] DVTPortal: Service '<DVTPortalViewDeveloperService: 0x7fe4e17686d0; action='viewDeveloper'>' encountered an unexpected result code from the portal ('1100')2018-05-07 11:57:54.696 xcodebuild[14808:865317] DVTPortal: Error:Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." UserInfo={payload=<CFBasicHash 0x7fe4e242ed70 [0x7fff9115faf0]>Whenever I open XCode and to go preferences->account, my team account already reports "Session has expired". I log in successfully, then close Xcode, then login again, and once again it says the "Session has expired".Enabled two factor authentication hasn't helped. I get the identical error from two separate machines (Mac Mini and MacBook Air). Using latest High Sierra OS and XCode.My developer accounts logs in fine to the developer portal on Apple's Developer site, iTunes connect, etc..
15
0
35k
May ’18
Scripting Zoom App - A Work In Progress
I know that zoom.us is not technically scriptable with Applescript but I have gotten so tired of repeatedly doing the same things when I set up a Zoom session that I started trying to automate the process using System Events and tell process. I was surprised by how much I could automate but then ran into a couple of brick walls. If anyone else is interested in this I'd like to brainstorm on the forum to see how much is possible. Here's some scripting steps I have been playing with. Part of what I decided to do in order to simplify the data entry involved in scheduling a new meeting and sending an email to the client was to run everything from Filemaker. The variables shows as $theMonth, $theDay, etc are being set in FileMaker before the Perform Applescript step so this is not a viable Applescript. You could use three separate Applescript dialog boxes to get the name date and time. The key code 48 is a tab to move between fields on the zoom interface. Key code 76 is the enter key which will OK the automatic entries in the Calendar so that I can quit Calendar and get back to zoom. There seems to be no way to stop zoom from automatically posting a new session in the Calendar. tell application "zoom.us" to activate tell application "System Events" tell process "zoom.us" repeat until window "Schedule Meeting" exists click menu item "Schedule Meeting..." of menu "Zoom.us" of menu bar 1 delay 0.2 end repeat set topicField to text field 1 of "Schedule Meeting" keystroke "Whatever You Want It To Be"" key code 48 keystroke $theMonth as text key code 48 keystroke $theDay as text key code 48 keystroke $theYear as text key code 48 keystroke $theHour as text key code 48 keystroke $theMinute as text key code 48 keystroke $theMonth as text key code 48 keystroke $theDay as text key code 48 keystroke $theYear as text key code 48 keystroke ($theHour + 1) as text key code 48 keystroke $theMinute as text Delay 2 key code 36 key code 76 key code 76 end tell end tell tell application "Calendar" to quit tell application "zoom.us" to activate tell application "System Events" tell process "zoom.us" repeat until window "Schedule Meeting" exists click menu item "Schedule Meeting..." of menu "Zoom.us" of menu bar 1 delay 0.2 end repeat select button ?????? end tell end tell The zoom.us interface for Meetings has what appear to be buttons for each scheduled meeting. I am trying to figure out how to select the right button so that I can then copy the invitation to put in an email. Tabbing does not let me select the button. If anyone has any ideas, I'd love to hear them, and if my further experiments produce any results, I'll post them. Thanks
3
0
2.4k
May ’21
Automating Split Screen View
I would like to automate opening two finder windows in split-screen View (the full screen split view you get by hovering over the green full-screen button and selecting Tile Window, not the windows style maximize) If possible preferably via AppleScript but would be okay with Automator or shortcuts. Any help would be greatly appreciated. Running an M1 Air on Monteray. my current workaround is this AppleScript, however, I would like to be using split-screen so it's in its on mission control workspace. PS New to mac and Applescript. tell application "System Events" to set the autohide of the dock preferences to true tell application "Finder" close windows open ("/Users/arthur/" as POSIX file) set screenBounds to bounds of window of desktop set screenWidth to item 3 of screenBounds set screenHeight to item 4 of screenBounds set the position of the front Finder window to {0, 0} set the bounds of the front Finder window to {0, 0, screenWidth * 0.5, screenHeight * 1} make Finder window set the position of the front Finder window to {screenWidth * 0.5, 0} set the bounds of the front Finder window to {screenWidth * 0.5, 0, screenWidth, screenHeight * 1} set the target of Finder window 1 to ("/Users/arthur/Downloads" as POSIX file) activate end tell
2
0
1.6k
Aug ’21
How to sudo command in xcode cloud ci_post_clone.sh?
I'm installing texturepacker in ci_post_clone.sh script using below command in Xcode Cloud workflow. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null brew install --cask texturepacker But I'm getting sudo warning in log. ==> Downloading https://www.codeandweb.com/download/texturepacker/6.0.2/TexturePacker-6.0.2.dmg ==> Installing Cask texturepacker sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required ==> Purging files for version 6.0.2 of Cask texturepacker Error: Permission denied @ dir_s_mkdir - /usr/local/Caskroom How can i fix this issue? Any idea or suggestions would be appreciated. Thank You
2
6
3.0k
Aug ’22
Extract .iwa files into .xml format
Hi all, I am trying to find a way to export the content of a .pages file into .xml format. That can be done saving the file to '09 version and then unzipping and working on the xml file. But I would like to do it also with .iwa files. I am trying to find a workaround to translate pages file on windows platform without need to pass through word extension, or the '09 format (in order to reduce DTP at its minimum). I am coding on Python... Thank you so much for any suggestion!
1
1
1.1k
Mar ’23
MenuItem scripting
Hi Everyone, I'm new to mac's and AppleScript so I apologise in advance for the level of questioning/quality of code. I've been trying to create an applescript to go through every menuitem and list out the keyboard shortcuts. I've created a script to add keyboard shortcuts, but have only done so as global shortcuts. Some of them don't work in different apps so I'm trying to create a verbose list that has every menuitem for every application so I can populate my script, then eventually have application specific shortcuts for every menuitem that has a shortcut currently. Below I'm trying to generate that list of current shortcuts but I'm stuck on the syntax of getting the properties of attributes of items and displaying them. The below is where I have got to: set allMenus to {} set everything to {} set onlyEnabled to {} tell application "System Events" to tell process appName set allMenus to name of every menu of menu bar 1 end tell global testCounter global currentCounter set testCounter to 14 set currentCounter to 0 repeat with menuName in allMenus set the end of everything to strings of getAppMenuItems(appName, menuName, onlyEnabled) if currentCounter > testCounter then log "EXIT REPEAT!!!!!!!!!!!!!!!" exit repeat end if end repeat on getAppMenuItems(appProcess, appMenus, enabledItems) tell application "System Events" to tell process appProcess # Get all menu items set theItems to every menu item of menu appMenus of menu bar 1 log "BREAKAKKKKKKBREAKKKKKK" set appMenuName to name of menu appMenus of menu bar 1 --log appname repeat with theMenuItem in theItems set currentCounter to currentCounter + 1 if currentCounter > testCounter then exit repeat end if set itemAttrib to get every attribute of theMenuItem repeat with aAttrib in itemAttrib if the name of the aAttrib is "AXMenuItemCmdChar" then set props to get properties of attribute "AXMenuItemCmdChar" of every menu item of menu appMenus of menu bar 1 repeat with aProps in props if the value of aProps as text is not "missing value" then log (appMenuName & "->" & name of theMenuItem as text & "->" & value of aProps as text) end if end repeat log (appMenuName & "->" & name of theMenuItem as text & "BREAKAKKKKKKBREAKKKKKK") end if end repeat end repeat return name of every menu item of menu appMenus of menu bar 1 end tell end getAppMenuItems (* tell application "System Events" get name of menu item 2 of menu 3 of menu bar 1 of process "Finder" --> "New Folder" get every attribute of menu item 2 of menu 3 of menu bar 1 of process "Finder" --> {attribute "AXRole" of menu item "New Finder Window" of menu "File" of menu bar item "File" of menu bar 1 of application process "Finder", [...] get properties of attribute "AXMenuItemCmdChar" of [...] --> {value:"N", class:attribute, settable:false, name:"AXMenuItemCmdChar"} get properties of attribute "AXMenuItemCmdModifiers" of [...] --> {value:1, class:attribute, settable:false, name:"AXMenuItemCmdModifiers"} *) Currently this outputs: Apple->About This Mac->Q Apple->About This Mac->Q Apple->About This MacBREAKAKKKKKKBREAKKKKKK Apple->System Information…->Q Apple->System Information…->Q Apple->System Information…->Q From the output I have surmised that when I'm logging the output (log (appMenuName & "->" & name of theMenuItem as text & "->" & value of aProps as text) The properties aren't actually the properties of theMenuItem attribute, but that it has found 3 AXMenuItemCmdChar in the full Apple menu, and is just putting those 3 against each theMenuItem. I've tried a few ways around this, mainly changing set props to get properties of attribute AXMenuItemCmdChar of every menu item of menu appMenus of menu bar 1 to set props to get properties of itemAttrib or set props to get properties of attribute "AXMenuItemCmdChar" of itemAttrib but can't seem to find the right way of getting it to work. Furthermore, how I would correctly reference the parent within my log() statement (I can see the syntax for referencing the child (e.g. x of y of z) but how do you go the other way? Thanks in advance
3
0
1.6k
Jun ’23
Question about adapting a batch script to automator
I am a recent convert to the Mac ecosystem, I have a windows batch script from when I was using windows that i would like to adapt to an automator script. It is pretty simple. The goal of is about using ffmpeg to convert media files to the proper WAV format for a sampler I have. Essentially what it does is allow you to right click on a file in a folder, and the script looks through all media files in that folder, then creates a new folder in an exports folder, and converts all the files to 44.1 khz wav files and places them in the few folder. An additional wrinkle of my original script that isn't completely necessary is that it queries you about whether you want to use the original folder name or create a new one. I wonder if y'all can provide me some guidance for adapting this to a bash script for automator. I am pretty new to bash scripts and not exactly an A+ programmer. I already have simple bash scripts working, doing things like creating a directory or other simple terminal like commands, but I haven't quite figured out things like setting variables or getting user input from a pop up terminal. Thanks for any help you could provide! @ECHO OFF for %%I in (.) do set CurrDirName=%%~nxI set CurrDir="%CD%" cd C:\Users\warpi\Desktop\Samples\Octatrack Exports set /p name= Use Parent Folder Name? [Y/N]: if %name%==y (set input=%CurrDirName%) else (set /p input= Folder Name: ) mkdir "%input%" echo Directory Created: "%input%" cd %CurrDir% for %%i in (*.*) do ffmpeg -i "%%i" -ar 44100 "C:\Users\warpi\Desktop\Samples\Octatrack Exports\%input%\%%~ni.wav" ::for %%i in (*.wav) do ffmpeg -i "%%i" -ar 44100 "C:\Users\warpi\Desktop\Samples\Octatrack Exports\%input%\%%~ni.wav" PAUSE
2
0
819
Jul ’23
Automation issue XCUItest| Flutter App Date Picker using CupertinoDatePicker library automation issue on iOS
I am currently automating a Flutter app in iOS plateform, and the developer has implemented a CupertinoDatePicker for date selection (screenshot attached). Upon inspecting the element properties, I found the relevant property specifically for the month as well as other selectors. Although I can successfully inspect the element, I encounter an issue when attempting to select a different month using the sendKeys function. I have also attempted to use the JavaScript executor, but unfortunately, it has not resolved the problem. I am currently stuck at this point and seeking assistance. Any suggestions would be greatly appreciated. Thank you in advance. For native apps we were getting type of this datepicker as 'XCUIElementTypePickerWheel' and using send keys we were able to set values. but for flutter iOS app it is not working as well type property we are getting as 'XCUIElementTypeOther' Any suggestions would be greatly appreciated. Thank you in advance. Element Properties: [{“key”:“elementId”,“value”:“54000000-0000-0000-4719-000000000000”,“name”:“elementId”},{“key”:“type”,“value”:“XCUIElementTypeOther”,“name”:“type”},{“key”:“value”,“value”:“7”,“name”:“value”},{“key”:“enabled”,“value”:“true”,“name”:“enabled”},{“key”:“visible”,“value”:“true”,“name”:“visible”},{“key”:“accessible”,“value”:“true”,“name”:“accessible”},{“key”:“x”,“value”:“213”,“name”:“x”},{“key”:“y”,“value”:“553”,“name”:“y”},{“key”:“width”,“value”:“47”,“name”:“width”},{“key”:“height”,“value”:“183”,“name”:“height”},{“key”:“index”,“value”:“3”,“name”:“index”}]
1
1
596
Jul ’23
Xcode Cloude + SonarQube analysis + Code Coverage is working... but...
Hello guys, I was able to get code coverage and sonar-scanner working with Xcode Cloud. First in, in post-clone script I install sonar-scanner tool like this brew install sonar-scanner Then, in post-xcodebuild script, I do three things: (a) get current app version, (b) get app version, (c) run xcodebuild again with forced code coverage reporting, (d) find coverage data and convert it to the format that Sonarqube understands, and finally (e) run sonar-scanner, which uploads results to Sonarqube dashboard. cd $CI_WORKSPACE # declare variables SCHEME=[REMOVED] PRODUCT_NAME=[REMOVED] WORKSPACE_NAME=${PRODUCT_NAME}.xcworkspace APP_VERSION=$(sed -n '/MARKETING_VERSION/{s/MARKETING_VERSION = //;s/;//;s/^[[:space:]]*//;p;q;}' ./${PRODUCT_NAME}.xcodeproj/project.pbxproj) # clean, build and test project xcodebuild \ -workspace ${WORKSPACE_NAME} \ -destination 'platform=iOS Simulator,name=iPad (10th generation),OS=latest' \ -scheme ${SCHEME} \ -derivedDataPath DerivedData/ \ -enableCodeCoverage YES \ -resultBundlePath DerivedData/Logs/Test/ResultBundle.xcresult \ clean build test # find profdata and binary PROFDATA=$(find . -name "Coverage.profdata") BINARY=$(find . -path "*${PRODUCT_NAME}.app/${PRODUCT_NAME}") # check if we have profdata file if [[ -z $PROFDATA ]]; then echo "ERROR: Unable to find Coverage.profdata. Be sure to execute tests before running this script." exit 1 fi # extract coverage data from project using xcode native tool xcrun --run llvm-cov show -instr-profile=${PROFDATA} ${BINARY} > sonarqube-coverage.report # run sonar scanner and upload coverage data with the current app version sonar-scanner \ -Dsonar.projectVersion=${APP_VERSION} It all works fine but my team and I think that this is a workaround that shouldn't work like this, because technically xcodebuild command is executed two times, first by Xcode Cloud, then by my script, which takes a lot of time and feels hacky. Ideally, Xcode Cloud's Build and Test actions should generate code coverage (the option is already enabled in our project) and give us access to profile data in DerivedData folder which I can access with environment variable CI_DERIVED_DATA_PATH. However, there is none. My question is, do I do everything correctly? Is there a way to improve this flow? Do I miss on how to correctly get code coverage data from Xcode Cloud?
3
1
1.8k
Jul ’23
Trouble with automations when triggered | Shortcuts IOS 16.5.1
This is a very long battle trying to solve an issue with an automation I created in the Shortcuts app. I have been facing this issue on my old phone SE2 and now it's the same on my 12. I am running IOS 16.5.1 with the latest security patches/ updates. This issue has also been reported to apple support multiple times with no solution yet. I have tried restoring, deleting all apps., redownloading the Shortcuts app., Deleting the Siri Voices and redownloading them but nothing is helping! I have included Screen and Video recording for this issue for the benefit of the reader I am also explaining the problem/ challenge here in text. NOTE: I am also a VoiceOver user and have a sight impairment Created a personal automation on the Shortcuts app. When any of 2 alarms is topped, get weather, text and speak text. While creating the automation and running it to test, the automation works flawless and the Siri voice used to speak text sounds just like it should. This is covered in the first video link. The challenge: When the automation is triggered, i.e. when the alarm is stopped and the text is to be spoken; the Siri voice is all choppy and inconsistent. This is demonstrated in the second video. P.S. It happens with all English Siri voices irrespective of Language selected in the automation i.e. Australia, India, United Kingdom, United States etc. NOTE: It's the Siri voices I downloaded from: Settings/ accessibility/ Spoken content. Other voices downloaded work fine but they aren't as good and natural as Siri voices. automation how it should be working: https://www.youtube.com/watch?v=-7YxOVRf8WA automation how it works when triggered: https://www.youtube.com/watch?v=rq2rIJQV7cw&amp;list=PL8vG-Fmt9t_lLgPAxlA8qaKVksgc9b3y6&amp;index=2
0
0
677
Jul ’23
[Applescript] FaceTime can not move to second monitor
Recently we tested how to move app using Applescript as below picture and find some interesting phenomenon. The following coordinates are meant for the second screen, but only FaceTime cannot be moved to the second screen. It can only be moved within its own screen, while other apps can be smoothly moved to the second screen. Because the syntax is exactly the same, could you help to guide us what is wrong with the script? Sincerely, Thanks, Bruce
0
0
470
Jul ’23
How do I Select multiple rows in the "Open" dialog window in "Preview"
How would I select multiple rows programmatically (ie not using Keyboard or mouse simulation) in the "Open" dialog window in "Preview". Manual Steps I'd take to do this in OSX Ventura 13.4.1 Open the "Preview" application. From Preview's "File" menu, select "Open" Wait for the dialog box whose title is "Open" to appear Manually Select Row 1,3,5, and 7. Fingers crossed that this is possible. Thanks in advance!
1
0
372
Jul ’23
Mac account detail window [Ventura]
Hello everyone, Up to Monterey, a script we use to make it easier for users to change the password on their local account on the computer has worked very well. But after Monterey, it no longer works. I've searched the web like crazy without finding any solution for Ventura. So I'm giving this form a shot in the hope that someone has a solution or something to help me along the way. The main problem is to go from Users and Groups in System setting to the account detail where you can click the button for changing password. Anyone have any idea? Code looks as follows: use AppleScript version "2.4" -- Yosemite (10.10) or later use framework "Foundation" use framework "AppKit" use scripting additions set userName to short user name of (system info) -- Create a dialog with 3 buttons display dialog "Mac Utility - user: " & userName buttons {"Change Password", "Forget Wi-Fi", "Cancel"} default button 1 with title "User Utilities" with icon caution -- Open Users and Groups if result = {button returned:"Change Password"} then tell application "Finder" to open file "Accounts.prefpane" of (path to system preferences) -- Show account details window -- This is where I'm stuck -- The rest of the script bellow else if.... The earlier code looked as bellow that doesn't work with Ventura. tell application "System Events" tell application process "System Preferences" delay 1 click button -1 of tab group 1 of window 1 end tell end tell Tanks in advance.
3
0
442
Jul ’23
Not being prompted when removing a root CA
We have our own root CA that is installed with our application. For non-MDM installs, the system asks if the user wants to do that, which is all well and good. It also used to ask us when removing that certificate. It doesn't now. So now I am wondering if I dreamed it, except other people say they also got prompted and don't now. It's being installed and removed using the security command, in scripts.
1
0
609
Aug ’23
AppleScript. Tell application "TextEdit" - the syntax of all commands.
Where can I see the entire list of commands for the "TextEdit" program? For example, there is a code: tell application "TextEdit" activate make new document with properties {text:"XDXDXD"} end tell There are two commands in this code: activate make new document with properties {text:"XDXDXD"} Where can I see all the available commands for the "TextEdit" program?
2
0
517
Aug ’23