Scripting

RSS for tag

Scripting allows you to automate complex, repetitive, and time-consuming tasks by writing scripts that interact with apps, processes, and the operating system.

Posts under Scripting tag

95 Posts

Post

Replies

Boosts

Views

Activity

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&list=PL8vG-Fmt9t_lLgPAxlA8qaKVksgc9b3y6&index=2
0
0
927
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
2
3.4k
Jul ’23
Sandbox entitlement to script Music/iTunes's AirPlay devices
I'm writing a Cocoa app that scripts various functions of the Music app. I'm successfully scripting a number of operations (create playlist, play tracks), but all AirPlay ops (get devices, set device volume) are failing with a permissions error: "-[Music airplayDevices_]: Music got an error: A privilege violation occurred. (error -10004)"Details:I'm using the AppleScriptObjC framework from Swifttargeting Catalina/Music, but have the same failures in Mojave/iTunescode succeeds when not sandboxed - only fails in the sandboxThe entitlements file includes the following: <key>com.apple.security.scripting-targets</key> <dict> <key>com.apple.Music</key> <array> <string>com.apple.Music.device</string> <string>com.apple.Music.user-interface</string> <string>com.apple.Music.playback</string> <string>com.apple.Music.playerInfo</string> <string>com.apple.Music.library.read</string> <string>com.apple.Music.library.read-write</string> <string>com.apple.Music.podcast</string> </array> </dict>i.e. all access-groups I could find using "sdef /System/Applications/Music.app". According to the sdef, AirPlay access is controlled by com.apple.Music.playback, which is included above.I assume I need some other entitlement as well, but I can't for the life of me find out what it is.
1
1
1.5k
Jun ’23
Script editor is not able to access popover UI element in macOs version - Big Sur
AppleScript code: tell process "EdgeMonitor" tell menu bar 2 UI elements end tell end tell When trying to access UI elements for a given application, we are getting different results on macOS Ventura and macOS Big Sur for the same app and same script. We are specifically trying to access the popover UI element which is accessible in Ventura but not in Big Sur. Can someone please help here to check why this might be happening? Thank you UI elements in macOS Ventura: menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", pop over 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events" UI elements in macOS Big Sur: menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", menu bar item 2 of menu bar 2 of application process "EdgeMonitor" of application "System Events"
0
1
767
Jun ’23
Grep can't handle my file.
I have an app on my mac that generates an html file. There are different versions of this file. When the file is generated, Folder Actions triggers a bash script that uploads the file to my web site. This version of the file is wacked. I need to identify this file so I can upload a replacement instead. This version can be identified by the presence of the word JazzKnob. Grep can't find this text. Sed doesn't work either. Neither does awk. How can I successfully identify this file? nowplaying.html
4
0
869
Jun ’23
Sending a new iMessage fails with "Expected class name but found identifier"
Using the highly-rated answer from StackOverflow How to send an imessage text with applescript, only in provided service?: on run {targetBuddyPhone, targetMessage} tell application "Messages" set targetService to 1st service whose service type = iMessage set targetBuddy to buddy targetBuddyPhone of targetService send targetMessage to targetBuddy end tell end run On Ventura, this errors at save with "Expected class name but found identifier." and highlights the first instance of "service". How should the script be corrected? Is there a difference in grammar between releases? This code works on Big Sur.
1
0
988
Jun ’23
Error in Apple script for saving password-protected PDF
Can anyone please help me find a solution for the error I'm getting? MacOS is Monterrey and this script used to work in Big Sur. It seems it is unable to find splitter group 3 (which would the page style). And the same happens when it tries to find "PDF" splitter and save as PDF. I would appreciate any help/suggestions you can provide. -- Don't change this set FixedPassword to "somePW" --Change the following for each Review accordingly set exam to "2" set session to "5" set VarPassword to "anotherPW" set outpath to "/Users/user/Dropbox/Physics" & " - " & "Current/2023-1-Spring/UF/2." & " " & "Chapter" & " " & "Reviews/" & ¬ "Exam" & " " & exam & " " & "Session" & " " & session & "/E" & exam & "S" & session & ".pdf" set SaveFolder to "/Users/user/Dropbox/Physics" & " - " & "Current/2023-1-Spring/UF/2." & " " & "Chapter" & " " & "Reviews/" & ¬ "Exam" & " " & exam & " " & "Session" & " " & session set FileName to "E" & exam & "S" & session & " " & "(Password" & " - " & VarPassword & ").pdf" --Saving PDF with password protection tell application "Preview" activate open outpath end tell activate application "Preview" tell application "System Events" tell process "Preview" keystroke "p" using command down delay 0.5 tell front window repeat until exists sheet 1 delay 1 end repeat tell sheet 1 tell splitter group 3 click pop up button 3 click menu item "Review 216 by 279 mm" of menu 1 of pop up button 3 end tell tell splitter group 3 click menu button "PDF" repeat until exists menu 1 of menu button "PDF" delay 3 end repeat click menu item "Save as PDF" of menu 1 of menu button "PDF" end tell end tell end tell -- Make sure the save dialog is visible repeat until exists sheet 1 of sheet 1 of front window delay 5 end repeat tell sheet 1 of sheet 1 of front window click button "Security Options..." end tell tell window "PDF Security Options" set selected to true set focused to true (* click the checkbox to on *) -- NOTE: for some reason there is a delay of about 6 seconds here, I do not know why tell checkbox "Require password to open document" click end tell (* add the password and confirm *) keystroke VarPassword keystroke (ASCII character 9) keystroke VarPassword tell its checkbox "Require password to copy text, images and other content" click end tell (* add the password and confirm *) keystroke FixedPassword keystroke (ASCII character 9) keystroke FixedPassword click button "OK" end tell repeat until exists sheet 1 of sheet 1 of front window delay 0.2 end repeat -- Press command+shift+g to show the "Go" drop down sheet keystroke "g" using {command down, shift down} repeat until exists sheet of sheet 1 of sheet 1 of front window delay 0.2 end repeat delay 0.5 keystroke SaveFolder delay 0.5 click button "Go" of sheet of sheet 1 of sheet 1 of front window -- Now that we are in our desired folder, set the file name and save set value of text field 1 of sheet 1 of sheet 1 of front window to FileName click button "Save" of sheet 1 of sheet 1 of front window end tell end tell But it gives the following error:
1
1
1.1k
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
the file document.pdf couldn't be opened because you don't have permission to view it
I am the developer of a 4D app that runs on MacOS 13.2 Ventura, that monitors an SFTP upload folder, and processes the uploaded documents, including printing them using an OSAScript from within the 4D app. This app was working correctly for years on earlier MacOS versions. Upon launching the pdf with OSAScript the MacOS shows an error message: 4D Server has been set to Full Disk Access, and so has Preview. 4D Server has been added to the list of apps in the Allow applications to use developer tools. If I double click the PDF document, preview opens it. Launching the PDF from within 4D Server shows the error. The SFTP uploads are done in a different User account than the 4D Server is running in. Copying the uploaded PDFs make the copied file owner the 4D Server user account, but OSAScript still won't launch the copied PDF. How do I fix this?
2
0
1.1k
Feb ’23
AppleScript - how to copy a file from one drive folder to local folder in hard disk?
Hi All, I'm modifying a document and saving those changes to one drive folder. now i want to create a copy of that document into local folder. I want to get it done using AppleScript. I use finder app for creating copy from one folder to another folder if document exists in local folder. tell application "Finder" to duplicate sourcefile to destinationfolder with replacing here the document exists in one-drive folder and i want to create a temporary copy into local folder. Is there anyway to do it via finder app or shell scripts?
4
0
2.1k
Feb ’23
How can I do some trivial AppleScript from a Swift app?
I've got a Swift app that looks at a timeline of occurences. I'd like to be able pop up the Calendar.app, focused on the date a user has selected within the app.Nothing fancy -- no data comes back from Calendar...Using ScriptingBridge, I could imagine just running [on the CalendarApplication that is returned from let calendarApp = SBApplication(url: url)]the method:- (void) viewCalendarAtDate:(NSDate *)at;or perhaps passing a string to the following script:on showDateInCalendar(s as string) tell application "Calendar" view calendar at date s end tellend showDateInCalendarThere seem to be lebenty different ways to approach this problem, but they all seem documented in the style of you-have-to-have-understood-this-once-before-you-can-understand-it-again.Any suggestions, or am I doomed to the command line and Python scripts?Richard
7
0
9k
Feb ’23
(null) is not allowed to open documents in Terminal
My application contains a binary which calls a shell script located in the "Resources" folder through the command: open -b com.apple.terminal '../Resources/myScript.sh' which opens the script in a Terminal window. This works on a M1 computer and on Intel macOS prior to Ventura. On an Intel Mac upgraded to Ventura 13.2 I get the error message: "myscript.sh" can’t be opened because (null) is not allowed to open documents in Terminal. Adding the entitlement <com.apple.security.automation.apple-events> had no effect. Since this works on macOS other than Ventura for Intel I don't see which hardening key or whatsoever is missing. What can I do to get rid of that error ? All the best
4
1
3.1k
Jan ’23
Mac M1 Paython - RuntimeError: can't start new thread
Hello all! I am not a programmer and my knowledge is very poor on this topic. My task is to upload historical data from Yahoo Finance. For this I use Python and specifically the yf.download library The code is correct, since everything works for my teacher, BUT! he uses a Windows PC, I have a MacBook Pro (M1 2020 8 GB RAM). It is necessary to upload data on 4933 stocks, and when it comes to about 2000, the process stops and does not go any further. RuntimeError: can't start new thread occurs I think that the problem is in the computer (it is logical to assume). If anyone knows how to get around this (without changing the computer), please write. I'll be very grateful. code below: nasdaq_stocks = yf.download(tickers = nasdaq_tickers, period = 'max', interval = '1d', group_by = 'ticker') result: [ 0% ] 13 of 4933 completed RuntimeError Traceback (most recent call last) Input In [25], in <cell line: 1>() ----> 1 nasdaq_stocks = yf.download(tickers = nasdaq_tickers, period = 'max', interval = '1d', group_by = 'ticker') File ~/opt/anaconda3/lib/python3.8/site-packages/yfinance/multi.py:105, in download(tickers, start, end, actions, threads, group_by, auto_adjust, back_adjust, progress, period, show_errors, interval, prepost, proxy, rounding, timeout, **kwargs) 103 _multitasking.set_max_threads(threads) 104 for i, ticker in enumerate(tickers): --> 105 _download_one_threaded(ticker, period=period, interval=interval, 106 start=start, end=end, prepost=prepost, 107 actions=actions, auto_adjust=auto_adjust, 108 back_adjust=back_adjust, 109 progress=(progress and i > 0), proxy=proxy, 110 rounding=rounding, timeout=timeout) 111 while len(shared._DFS) < len(tickers): 112 _time.sleep(0.01) File ~/opt/anaconda3/lib/python3.8/site-packages/multitasking/init.py:119, in task..async_method(*args, **kwargs) 116 single = config["POOLS"][config["POOL_NAME"]]['engine']( 117 target=_run_via_pool, args=args, kwargs=kwargs) 118 config["TASKS"].append(single) --> 119 single.start() 120 return single File ~/opt/anaconda3/lib/python3.8/threading.py:852, in Thread.start(self) 850 _limbo[self] = self 851 try: --> 852 _start_new_thread(self._bootstrap, ()) 853 except Exception: 854 with _active_limbo_lock: RuntimeError: can't start new thread [****************** 41% ] 2033 of 4933 completed**
1
0
1.7k
Jan ’23
orderWindows not reliable/changed in Ventura
My application can be controlled by scripts using AppleScript, python (through scripting bridge), or my own internal scripting language in a script thread. I just noticed that scripts that need to know the current front window have stopped working in Ventura. I find the front window as the first relevant window in [NSApp orderedWindows] (in Objective C). I found the problem with Ventura by adding some debugging output as follows: Run a script thread to control my application When a new window is needed, this thread uses performSelectorOnMainThread to create a window and waits for it to appear and to get added to the document. Before returning from main thread selector, the ordered windows are checked and they are correct (the new window is an AncestorController). DEBUG: check window order after creating an AncestorController DEBUG: frontGEDCOMController windows are: ...1 of 2 <NSWindow: 0x123691e20> <AncestorController: 0x600001fc50e0> ...2 of 2 <NSWindow: 0x123641ad0> <IndexController: 0x6000019c0c40> ...current front window is AncestorController Immediately on return to script thread, however, another performSelectorOnMainThread is called to check the order of the windows again and it has changed in an instant to the wrong order (wrong because the AncestorController is still in front). DEBUG: recheck window order after 0.000000 seconds DEBUG: frontGEDCOMController windows are: ...1 of 2 <NSWindow: 0x123641ad0> <IndexController: 0x6000019c0c40> ...2 of 2 <NSWindow: 0x123691e20> <AncestorController: 0x600001fc50e0> ...front window type is IndexController But, if I sleep the thread, the order changes back to correct order in <= 1/30 second DEBUG: recheck window order after 0.033333 seconds DEBUG: frontGEDCOMController windows are: ...1 of 2 <NSWindow: 0x123691e20> <AncestorController: 0x600001fc50e0> ...2 of 2 <NSWindow: 0x123641ad0> <IndexController: 0x6000019c0c40> ... front window type is AncestorController This issue is new to Ventura. For some reason Ventura adds a window to the list in the correct position. It then movies to the wrong possible for a short amount of time before then returning to the correct position. That did not happen in MacOS 12.x or earlier. Now maybe I can find all the places my scripts that need to pause for Ventura to get things right, but it would be better to know why it has happened and then know where I need to insert Ventura hacks? Or is there another way that can reliably get ordered windows in Ventura? Curiously this problem does not occur when scripting by AppleScript. Maybe that is just so slow that pauses happen all the time anyway. I did find an alternative method to get ordered windows introduced in 10.12: enumerateWindowsWithOptions:usingBlock: with option NSWindowListOrderedFrontToBack but it is identical to using orderedWindows (i.e., gets the order wrong for a while).
0
0
1.1k
Dec ’22
Download Xcode from command line
Hi everyone, I am trying to download Xcode from command line the following way: wget --certificate=certificate.pem --private-key=private-key.pem --server-response https://download.developer.apple.com/Developer_Tools/Xcode_13.3.1/Xcode_13.3.1.xip --no-check-certificate --load-cookies=cookies.txt I am getting the following error: HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://developer.apple.com/unauthorized/ I have the certificate and private key from developer.apple.com and I am using them for authentication(correct me if I am wrong and they cannot be used for authentication). From several forums I found that the error regarding authorization could also be from cookies, so I got the cookies. Still the same error. I need the download of Xcode to be done from command line so that I can then automate the procedure using ansible playbooks (basically for the purpose of downloading and installing it on multiple mac machines.) Please, if the approach is entirely wrong, provide me with the right guide how to download Xcode from developer.apple.com site.
4
0
4.1k
Dec ’22
XCUITest vs. UIAutomation in Instruments
Hi, Want to get your opinion on using XCUITest via XCode 7 or would you continue to use the Automation instrument in Instruments. With Instruments, I could run both Automation scripts as well as other Instruments such as allocation, leaks etc. Please share your thoughts on your choice.
Replies
5
Boosts
0
Views
9.3k
Activity
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
Replies
0
Boosts
0
Views
927
Activity
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?
Replies
3
Boosts
2
Views
3.4k
Activity
Jul ’23
Sandbox entitlement to script Music/iTunes's AirPlay devices
I'm writing a Cocoa app that scripts various functions of the Music app. I'm successfully scripting a number of operations (create playlist, play tracks), but all AirPlay ops (get devices, set device volume) are failing with a permissions error: "-[Music airplayDevices_]: Music got an error: A privilege violation occurred. (error -10004)"Details:I'm using the AppleScriptObjC framework from Swifttargeting Catalina/Music, but have the same failures in Mojave/iTunescode succeeds when not sandboxed - only fails in the sandboxThe entitlements file includes the following: &lt;key&gt;com.apple.security.scripting-targets&lt;/key&gt; &lt;dict&gt; &lt;key&gt;com.apple.Music&lt;/key&gt; &lt;array&gt; &lt;string&gt;com.apple.Music.device&lt;/string&gt; &lt;string&gt;com.apple.Music.user-interface&lt;/string&gt; &lt;string&gt;com.apple.Music.playback&lt;/string&gt; &lt;string&gt;com.apple.Music.playerInfo&lt;/string&gt; &lt;string&gt;com.apple.Music.library.read&lt;/string&gt; &lt;string&gt;com.apple.Music.library.read-write&lt;/string&gt; &lt;string&gt;com.apple.Music.podcast&lt;/string&gt; &lt;/array&gt; &lt;/dict&gt;i.e. all access-groups I could find using "sdef /System/Applications/Music.app". According to the sdef, AirPlay access is controlled by com.apple.Music.playback, which is included above.I assume I need some other entitlement as well, but I can't for the life of me find out what it is.
Replies
1
Boosts
1
Views
1.5k
Activity
Jun ’23
Script editor is not able to access popover UI element in macOs version - Big Sur
AppleScript code: tell process "EdgeMonitor" tell menu bar 2 UI elements end tell end tell When trying to access UI elements for a given application, we are getting different results on macOS Ventura and macOS Big Sur for the same app and same script. We are specifically trying to access the popover UI element which is accessible in Ventura but not in Big Sur. Can someone please help here to check why this might be happening? Thank you UI elements in macOS Ventura: menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", pop over 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events" UI elements in macOS Big Sur: menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", menu bar item 2 of menu bar 2 of application process "EdgeMonitor" of application "System Events"
Replies
0
Boosts
1
Views
767
Activity
Jun ’23
Grep can't handle my file.
I have an app on my mac that generates an html file. There are different versions of this file. When the file is generated, Folder Actions triggers a bash script that uploads the file to my web site. This version of the file is wacked. I need to identify this file so I can upload a replacement instead. This version can be identified by the presence of the word JazzKnob. Grep can't find this text. Sed doesn't work either. Neither does awk. How can I successfully identify this file? nowplaying.html
Replies
4
Boosts
0
Views
869
Activity
Jun ’23
Sending a new iMessage fails with "Expected class name but found identifier"
Using the highly-rated answer from StackOverflow How to send an imessage text with applescript, only in provided service?: on run {targetBuddyPhone, targetMessage} tell application "Messages" set targetService to 1st service whose service type = iMessage set targetBuddy to buddy targetBuddyPhone of targetService send targetMessage to targetBuddy end tell end run On Ventura, this errors at save with "Expected class name but found identifier." and highlights the first instance of "service". How should the script be corrected? Is there a difference in grammar between releases? This code works on Big Sur.
Replies
1
Boosts
0
Views
988
Activity
Jun ’23
cfgutil, vpp
Hello, while I can install VPP app on idevice with Apple Configurator, I can not find a way to do the same thing via cfgutil. Apple configurator registers device's serial number and installs app. While cfgutil only installs app and do not registers serial number. Does cfgutil support installing VPP apps?
Replies
0
Boosts
0
Views
871
Activity
May ’23
Post-Xcodebuild script not found at ci_scripts/ci_post_xcodebuild.sh
Good day, I'm trying to setup uploading dSyms to Firebase via Xcode Cloud using ci_post_xcodebuild.sh But I constantly encounter an error Post-Xcodebuild script not found at ci_scripts/ci_post_xcodebuild.sh
Replies
3
Boosts
0
Views
2.2k
Activity
Apr ’23
Error in Apple script for saving password-protected PDF
Can anyone please help me find a solution for the error I'm getting? MacOS is Monterrey and this script used to work in Big Sur. It seems it is unable to find splitter group 3 (which would the page style). And the same happens when it tries to find "PDF" splitter and save as PDF. I would appreciate any help/suggestions you can provide. -- Don't change this set FixedPassword to "somePW" --Change the following for each Review accordingly set exam to "2" set session to "5" set VarPassword to "anotherPW" set outpath to "/Users/user/Dropbox/Physics" & " - " & "Current/2023-1-Spring/UF/2." & " " & "Chapter" & " " & "Reviews/" & ¬ "Exam" & " " & exam & " " & "Session" & " " & session & "/E" & exam & "S" & session & ".pdf" set SaveFolder to "/Users/user/Dropbox/Physics" & " - " & "Current/2023-1-Spring/UF/2." & " " & "Chapter" & " " & "Reviews/" & ¬ "Exam" & " " & exam & " " & "Session" & " " & session set FileName to "E" & exam & "S" & session & " " & "(Password" & " - " & VarPassword & ").pdf" --Saving PDF with password protection tell application "Preview" activate open outpath end tell activate application "Preview" tell application "System Events" tell process "Preview" keystroke "p" using command down delay 0.5 tell front window repeat until exists sheet 1 delay 1 end repeat tell sheet 1 tell splitter group 3 click pop up button 3 click menu item "Review 216 by 279 mm" of menu 1 of pop up button 3 end tell tell splitter group 3 click menu button "PDF" repeat until exists menu 1 of menu button "PDF" delay 3 end repeat click menu item "Save as PDF" of menu 1 of menu button "PDF" end tell end tell end tell -- Make sure the save dialog is visible repeat until exists sheet 1 of sheet 1 of front window delay 5 end repeat tell sheet 1 of sheet 1 of front window click button "Security Options..." end tell tell window "PDF Security Options" set selected to true set focused to true (* click the checkbox to on *) -- NOTE: for some reason there is a delay of about 6 seconds here, I do not know why tell checkbox "Require password to open document" click end tell (* add the password and confirm *) keystroke VarPassword keystroke (ASCII character 9) keystroke VarPassword tell its checkbox "Require password to copy text, images and other content" click end tell (* add the password and confirm *) keystroke FixedPassword keystroke (ASCII character 9) keystroke FixedPassword click button "OK" end tell repeat until exists sheet 1 of sheet 1 of front window delay 0.2 end repeat -- Press command+shift+g to show the "Go" drop down sheet keystroke "g" using {command down, shift down} repeat until exists sheet of sheet 1 of sheet 1 of front window delay 0.2 end repeat delay 0.5 keystroke SaveFolder delay 0.5 click button "Go" of sheet of sheet 1 of sheet 1 of front window -- Now that we are in our desired folder, set the file name and save set value of text field 1 of sheet 1 of sheet 1 of front window to FileName click button "Save" of sheet 1 of sheet 1 of front window end tell end tell But it gives the following error:
Replies
1
Boosts
1
Views
1.1k
Activity
Mar ’23
Where to find some commonly used AppleScript examples to automate basic MacOS tasks?
Where to find some commonly used AppleScript examples to automate basic MacOS tasks? Any link, website, tutorials, guides, etc. Any other well know AppleScript forum than this one. Thanks!
Replies
2
Boosts
0
Views
1.4k
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
the file document.pdf couldn't be opened because you don't have permission to view it
I am the developer of a 4D app that runs on MacOS 13.2 Ventura, that monitors an SFTP upload folder, and processes the uploaded documents, including printing them using an OSAScript from within the 4D app. This app was working correctly for years on earlier MacOS versions. Upon launching the pdf with OSAScript the MacOS shows an error message: 4D Server has been set to Full Disk Access, and so has Preview. 4D Server has been added to the list of apps in the Allow applications to use developer tools. If I double click the PDF document, preview opens it. Launching the PDF from within 4D Server shows the error. The SFTP uploads are done in a different User account than the 4D Server is running in. Copying the uploaded PDFs make the copied file owner the 4D Server user account, but OSAScript still won't launch the copied PDF. How do I fix this?
Replies
2
Boosts
0
Views
1.1k
Activity
Feb ’23
AppleScript - how to copy a file from one drive folder to local folder in hard disk?
Hi All, I'm modifying a document and saving those changes to one drive folder. now i want to create a copy of that document into local folder. I want to get it done using AppleScript. I use finder app for creating copy from one folder to another folder if document exists in local folder. tell application "Finder" to duplicate sourcefile to destinationfolder with replacing here the document exists in one-drive folder and i want to create a temporary copy into local folder. Is there anyway to do it via finder app or shell scripts?
Replies
4
Boosts
0
Views
2.1k
Activity
Feb ’23
How can I do some trivial AppleScript from a Swift app?
I've got a Swift app that looks at a timeline of occurences. I'd like to be able pop up the Calendar.app, focused on the date a user has selected within the app.Nothing fancy -- no data comes back from Calendar...Using ScriptingBridge, I could imagine just running [on the CalendarApplication that is returned from let calendarApp = SBApplication(url: url)]the method:- (void) viewCalendarAtDate:(NSDate *)at;or perhaps passing a string to the following script:on showDateInCalendar(s as string) tell application "Calendar" view calendar at date s end tellend showDateInCalendarThere seem to be lebenty different ways to approach this problem, but they all seem documented in the style of you-have-to-have-understood-this-once-before-you-can-understand-it-again.Any suggestions, or am I doomed to the command line and Python scripts?Richard
Replies
7
Boosts
0
Views
9k
Activity
Feb ’23
Not able to run scripts in PyCharm on Macbook Air M2
Hi, I have been trying to run python scripts on PyCharm but haven't been able to. I have tried different versions of python and a lot of package managers. I haven't been able to run the scripts and haven't been able to pip install tensorflow either.
Replies
0
Boosts
0
Views
1.2k
Activity
Jan ’23
(null) is not allowed to open documents in Terminal
My application contains a binary which calls a shell script located in the "Resources" folder through the command: open -b com.apple.terminal '../Resources/myScript.sh' which opens the script in a Terminal window. This works on a M1 computer and on Intel macOS prior to Ventura. On an Intel Mac upgraded to Ventura 13.2 I get the error message: "myscript.sh" can’t be opened because (null) is not allowed to open documents in Terminal. Adding the entitlement &lt;com.apple.security.automation.apple-events&gt; had no effect. Since this works on macOS other than Ventura for Intel I don't see which hardening key or whatsoever is missing. What can I do to get rid of that error ? All the best
Replies
4
Boosts
1
Views
3.1k
Activity
Jan ’23
Mac M1 Paython - RuntimeError: can't start new thread
Hello all! I am not a programmer and my knowledge is very poor on this topic. My task is to upload historical data from Yahoo Finance. For this I use Python and specifically the yf.download library The code is correct, since everything works for my teacher, BUT! he uses a Windows PC, I have a MacBook Pro (M1 2020 8 GB RAM). It is necessary to upload data on 4933 stocks, and when it comes to about 2000, the process stops and does not go any further. RuntimeError: can't start new thread occurs I think that the problem is in the computer (it is logical to assume). If anyone knows how to get around this (without changing the computer), please write. I'll be very grateful. code below: nasdaq_stocks = yf.download(tickers = nasdaq_tickers, period = 'max', interval = '1d', group_by = 'ticker') result: [ 0% ] 13 of 4933 completed RuntimeError Traceback (most recent call last) Input In [25], in &lt;cell line: 1&gt;() ----&gt; 1 nasdaq_stocks = yf.download(tickers = nasdaq_tickers, period = 'max', interval = '1d', group_by = 'ticker') File ~/opt/anaconda3/lib/python3.8/site-packages/yfinance/multi.py:105, in download(tickers, start, end, actions, threads, group_by, auto_adjust, back_adjust, progress, period, show_errors, interval, prepost, proxy, rounding, timeout, **kwargs) 103 _multitasking.set_max_threads(threads) 104 for i, ticker in enumerate(tickers): --&gt; 105 _download_one_threaded(ticker, period=period, interval=interval, 106 start=start, end=end, prepost=prepost, 107 actions=actions, auto_adjust=auto_adjust, 108 back_adjust=back_adjust, 109 progress=(progress and i &gt; 0), proxy=proxy, 110 rounding=rounding, timeout=timeout) 111 while len(shared._DFS) &lt; len(tickers): 112 _time.sleep(0.01) File ~/opt/anaconda3/lib/python3.8/site-packages/multitasking/init.py:119, in task..async_method(*args, **kwargs) 116 single = config["POOLS"][config["POOL_NAME"]]['engine']( 117 target=_run_via_pool, args=args, kwargs=kwargs) 118 config["TASKS"].append(single) --&gt; 119 single.start() 120 return single File ~/opt/anaconda3/lib/python3.8/threading.py:852, in Thread.start(self) 850 _limbo[self] = self 851 try: --&gt; 852 _start_new_thread(self._bootstrap, ()) 853 except Exception: 854 with _active_limbo_lock: RuntimeError: can't start new thread [****************** 41% ] 2033 of 4933 completed**
Replies
1
Boosts
0
Views
1.7k
Activity
Jan ’23
orderWindows not reliable/changed in Ventura
My application can be controlled by scripts using AppleScript, python (through scripting bridge), or my own internal scripting language in a script thread. I just noticed that scripts that need to know the current front window have stopped working in Ventura. I find the front window as the first relevant window in [NSApp orderedWindows] (in Objective C). I found the problem with Ventura by adding some debugging output as follows: Run a script thread to control my application When a new window is needed, this thread uses performSelectorOnMainThread to create a window and waits for it to appear and to get added to the document. Before returning from main thread selector, the ordered windows are checked and they are correct (the new window is an AncestorController). DEBUG: check window order after creating an AncestorController DEBUG: frontGEDCOMController windows are: ...1 of 2 <NSWindow: 0x123691e20> <AncestorController: 0x600001fc50e0> ...2 of 2 <NSWindow: 0x123641ad0> <IndexController: 0x6000019c0c40> ...current front window is AncestorController Immediately on return to script thread, however, another performSelectorOnMainThread is called to check the order of the windows again and it has changed in an instant to the wrong order (wrong because the AncestorController is still in front). DEBUG: recheck window order after 0.000000 seconds DEBUG: frontGEDCOMController windows are: ...1 of 2 <NSWindow: 0x123641ad0> <IndexController: 0x6000019c0c40> ...2 of 2 <NSWindow: 0x123691e20> <AncestorController: 0x600001fc50e0> ...front window type is IndexController But, if I sleep the thread, the order changes back to correct order in <= 1/30 second DEBUG: recheck window order after 0.033333 seconds DEBUG: frontGEDCOMController windows are: ...1 of 2 <NSWindow: 0x123691e20> <AncestorController: 0x600001fc50e0> ...2 of 2 <NSWindow: 0x123641ad0> <IndexController: 0x6000019c0c40> ... front window type is AncestorController This issue is new to Ventura. For some reason Ventura adds a window to the list in the correct position. It then movies to the wrong possible for a short amount of time before then returning to the correct position. That did not happen in MacOS 12.x or earlier. Now maybe I can find all the places my scripts that need to pause for Ventura to get things right, but it would be better to know why it has happened and then know where I need to insert Ventura hacks? Or is there another way that can reliably get ordered windows in Ventura? Curiously this problem does not occur when scripting by AppleScript. Maybe that is just so slow that pauses happen all the time anyway. I did find an alternative method to get ordered windows introduced in 10.12: enumerateWindowsWithOptions:usingBlock: with option NSWindowListOrderedFrontToBack but it is identical to using orderedWindows (i.e., gets the order wrong for a while).
Replies
0
Boosts
0
Views
1.1k
Activity
Dec ’22
Download Xcode from command line
Hi everyone, I am trying to download Xcode from command line the following way: wget --certificate=certificate.pem --private-key=private-key.pem --server-response https://download.developer.apple.com/Developer_Tools/Xcode_13.3.1/Xcode_13.3.1.xip --no-check-certificate --load-cookies=cookies.txt I am getting the following error: HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://developer.apple.com/unauthorized/ I have the certificate and private key from developer.apple.com and I am using them for authentication(correct me if I am wrong and they cannot be used for authentication). From several forums I found that the error regarding authorization could also be from cookies, so I got the cookies. Still the same error. I need the download of Xcode to be done from command line so that I can then automate the procedure using ansible playbooks (basically for the purpose of downloading and installing it on multiple mac machines.) Please, if the approach is entirely wrong, provide me with the right guide how to download Xcode from developer.apple.com site.
Replies
4
Boosts
0
Views
4.1k
Activity
Dec ’22