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
2.0k
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.7k
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.1k
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.2k
Mar ’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
482
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
647
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
603
Aug ’23
AppleScript. Split the string into parts by the separator character.
This code does not make sense, I would just like to get information based on it. set MyData to "MyData1|MyData2" on MyScript(MyData) set MyVar1 to "MyData1" set MyVar2 to "MyData2" return MyVar1 & "|" & MyVar2 end MyScript The text is passed in the code: "MyData1|MyData2". I need to divide it into two parts by the "|" symbol. And write each part into two variables: myVar1 and myVar2. How to do it? P.S. The problem is that only one parameter can be passed to on...end. I need to pass two. I'll pass one, then split it into two.
1
0
1.2k
Aug ’23
AppleScript Language Guide. open for access. The parameter is not specified in the syntax.
Here is the help for the "open for access" command. In the Syntax - Parameters section, the first parameter is not specified, but immediately write something in parentheses. In the "write" command, it is done differently. https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW31
1
0
462
Aug ’23
Remove ‘Fwd: ’ from an forwarded email subject
All works well, except that 'Fwd:' in the subject line, which I'd like to remove when forwarding tell application "Mail" set theMessage to item 1 of (get selection) set forwardedMessage to forward theMessage without opening window tell forwardedMessage make new to recipient at end of to recipients with properties {address:"a@b.com"} set message signature of forwardedMessage to signature "Blank" of application "Mail" set stringLength to (count subject of forwardedMessage) set subject of forwardedMessage to (characters 0 thru stringLength) as string send end tell end tell
0
0
416
Aug ’23
Automated Mouse Moving
I am attempting to automate the movement of my mouse fully through Apple software. I have tried a variety of things, and I am now on the Dev Forums because I've ran out of ideas. Some of the things I have attempted are: Full Keyboard Access, Mouse Keys, Accessibility Keyboard with Panel Editor actions. Please, feel free to share any advice you may have. My goal is to only move the mouse enough for the computer to know it is active. That could be one pixel. Mouse keys works, but I can't get it to automate, I still have to click "u" and "o" to move the mouse. Thanks for any advice y'all may have! Have a blessed day!
0
0
433
Aug ’23
Iterate Window instead of Mass Operation
I'm trying to modify this code to work iteratively: on run {input, parameters} tell application id "com.apple.systemevents" to set the value of attribute "AXMinimized" of every window of every process to false end run Something along the lines of : on run {input, parameters} foreach windows of every process tell application id "com.apple.systemevents" to set the value of attribute "AXMinimized" to false end run Is this possible?
2
0
574
Aug ’23
Speeding Up Code
I'm made a script that iterates through all windows and restores minimized windows. However, the script is quite slow. I'm wondering how to speed it up. I believe part of why the code is so slow is that it's looking at every process instead of every foreground process. Is it possible to do something like "repeat with p in every foreground process" or speed up this script through other means? on run {input, parameters} set windowNames to {} tell application "System Events" repeat with p in every process repeat with w in every window of p if value of attribute "AXMinimized" of w is true then set value of attribute "AXMinimized" of w to false end if end repeat end repeat end tell end run
2
0
559
Aug ’23