Sample Header Ad - 728x90

Ask Different (Apple)

Q&A for power users of Apple hardware and software

Latest Questions

0 votes
1 answers
105 views
Duplicate calendar events in Outlook 2011
Does someone have a script to merge or delete Outlook 2011 duplicate calendar entries?
Does someone have a script to merge or delete Outlook 2011 duplicate calendar entries?
pideja (1 rep)
Jan 27, 2016, 03:25 PM • Last activity: Jul 30, 2025, 07:31 AM
0 votes
2 answers
1765 views
How can I have a key pressed at a specific time?
I want to press a certain key (e.g. 'p') in a certain time (e.g. at 00:00), how can I accomplish this? I'm aware of https://apple.stackexchange.com/questions/63897/can-a-mac-be-programmed-to-simulate-pressing-a-key-at-a-certain-rate-via-softwar but this doesn't include a timer of any kind. P.S. I'm...
I want to press a certain key (e.g. 'p') in a certain time (e.g. at 00:00), how can I accomplish this? I'm aware of https://apple.stackexchange.com/questions/63897/can-a-mac-be-programmed-to-simulate-pressing-a-key-at-a-certain-rate-via-softwar but this doesn't include a timer of any kind. P.S. I'm running at macOS 10.13 High Seirra
Krist Dave Ferrer (19 rep)
Jan 29, 2021, 04:01 PM • Last activity: Jul 30, 2025, 05:04 AM
6 votes
4 answers
3661 views
How can I see how long my computer has been active (as in not idle)
I've seen a variety of solutions to check how long my machine has been idle, and I know I can check how long since last reboot with `uptime`, but I'm curious if there's a way to see how long since my computer was last idle. Maybe since the last time the power save settings kicked in, or last time si...
I've seen a variety of solutions to check how long my machine has been idle, and I know I can check how long since last reboot with uptime, but I'm curious if there's a way to see how long since my computer was last idle. Maybe since the last time the power save settings kicked in, or last time since the screensaver turned on / monitor turned off, etc? I'm fine using an applescript or shell command to determine this, if those are the best solutions.
hookedonwinter (161 rep)
Jul 18, 2012, 02:52 PM • Last activity: Jul 24, 2025, 01:06 PM
1 votes
1 answers
133 views
My automated "click" Applescript has just stopped working
Right up until a week ago, my simple Applescript that had to simply click on a specific coordinate on screen just stopped working. Here is the Applescript: tell application "System Events" click at {693, 619} end tell And I automate it's trigger at a specific time of day with the help of osascript (...
Right up until a week ago, my simple Applescript that had to simply click on a specific coordinate on screen just stopped working. Here is the Applescript: tell application "System Events" click at {693, 619} end tell And I automate it's trigger at a specific time of day with the help of osascript (recommended for Applescripts) using the following plist file. Label com.mouseclick.plist ProgramArguments /usr/bin/osascript /Users/mugenvoid/Downloads/mouseclick.scpt StartCalendarInterval Hour 6 Minute 10 I've added this plist file to the LaunchDaemons folder of my core Library folder. This will ensure it's a global daemon, so it should have the highest chance of always triggering correctly. Beyond that, I've given all the relevant access and permissions (Accessibility, Automation, disk access etc) for this setup to work correctly. To ensure the job is loaded correctly and functional, I use an application called Launchcontrol 2. Over there, it is always loaded in correctly and the status shows as OK. Despite all these checks and balances, the script just doesn't click on the specific coordinate no more. It was always working perfectly fine up until a week ago and I haven't made any changes whatsoever to this whole setup. The Launchcontrol 2 application has some launchd(8) logs of the job trigger event at the designated time that I would like to share. Perhaps it will help with the debugging. Here it is: 2024-10-22 06:10:03.808584 internal event: WILL_SPAWN, code = 0 2024-10-22 06:10:03.808688 service state: spawn scheduled 2024-10-22 06:10:03.808692 service state: spawning 2024-10-22 06:10:03.808727 launching: xpc event 2024-10-22 06:10:03.810543 xpcproxy spawned with pid 28683 2024-10-22 06:10:03.810593 internal event: SPAWNED, code = 0 2024-10-22 06:10:03.810599 service state: xpcproxy 2024-10-22 06:10:03.810718 internal event: SOURCE_ATTACH, code = 0 2024-10-22 06:10:03.827675 service state: running 2024-10-22 06:10:03.827703 internal event: INIT, code = 0 2024-10-22 06:10:03.827709 job state = running 2024-10-22 06:10:03.827726 Successfully spawned osascript because xpc event 2024-10-22 06:10:10.104597 exited due to exit(0), ran for 6293ms 2024-10-22 06:10:10.104617 service state: exited 2024-10-22 06:10:10.104630 internal event: EXITED, code = 0 2024-10-22 06:10:10.104633 job state = exited 2024-10-22 06:10:10.104665 service inactive: com.mouseclick.plist 2024-10-22 06:10:10.104681 service state: not running To the best of my knowledge, I've checked everything possible from my end and am still faced with this roadblock. I'd really appreciate your support here! Condensed view of what I've tried so far: - Under the Privacy & Security settings section, I enabled Accessibility for osascript, launchcontrol and the script editors I've used for the Applescript and the plist file. See image attached below. Accessibility Settings - Under the Privacy & Security settings section, under Automation, the requisite access has been given to Osascript and relevant applications. See image attached below. Automation Settings - Ensured the job is loaded correctly with no errors and that it is loaded in as a global daemon (by adding the plist file to the LaunchDaemons foler in my core Library folder). See image attached below. Launchcontrol 2 job view - Verified the script file and plist file and found no syntax errors (code used for both has been shared above). - Ran the script file from the Script Editor itself to confirm if it's working fine and got the following results. See image attached below. Script run results
Anshu Chang (21 rep)
Oct 22, 2024, 07:41 AM • Last activity: Jul 21, 2025, 03:02 AM
1 votes
1 answers
106 views
Launch DMG drive script failing after restart
I have an automation (screenshots of it here: https://www.icloud.com/iclouddrive/0bB-1AiIWdJc1jmkfdjRbsAVA#Launch_Plex_Media_Automation_ )saved as an app in Automator with the following AppleScripts to mount an encrypted DMG file, enter the password in security agent pop up and click OK. macOS is Ca...
I have an automation (screenshots of it here: https://www.icloud.com/iclouddrive/0bB-1AiIWdJc1jmkfdjRbsAVA#Launch_Plex_Media_Automation_ )saved as an app in Automator with the following AppleScripts to mount an encrypted DMG file, enter the password in security agent pop up and click OK. macOS is Catalina. It worked wonderfully for two years. Then it stopped working. After several attempts to fix the script, I went into Time Machine and retrieved the script from a time I knew it was working. It worked great for a bit but now it works a few times then stops entering the password. If I run just the script from Script Editor, it works great. Same if run from Automator. It will continue working in the automation until I shut my MBP down, then it's back to waiting for me to manually enter the password again. The automation has full disk access. Suggestions to fix this please?
tell application "MountDMG"
	activate
end tell

delay 5

tell application "System Events"
	set value of text field 1 of window 1 of process "SecurityAgent" to "Password"
	click button 2 of window 1 of process "SecurityAgent"
	--> button "OK" of window 1 of application process "SecurityAgent"
end tell
Gregg Potocnik (61 rep)
Jun 25, 2021, 10:45 PM • Last activity: Jul 10, 2025, 05:08 PM
0 votes
0 answers
19 views
fast user switch: is there a way to speed up the animation between changing users?
When using CTRL-Cmd-Q or clicking a user from the fast user switcher dropdown menu, is there a way to speed up or eliminate the animation the occurs (it's a rotating box) as the action complete to the password prompt? I saw [this][1] post on speeding up animation for spaces, however it doesn't cover...
When using CTRL-Cmd-Q or clicking a user from the fast user switcher dropdown menu, is there a way to speed up or eliminate the animation the occurs (it's a rotating box) as the action complete to the password prompt? I saw this post on speeding up animation for spaces, however it doesn't cover the fast user switch.
atod (77 rep)
Jul 5, 2025, 04:34 PM
0 votes
1 answers
200 views
Batch modify metadata for local music files in the macOS Apple Music app using regex
I would like to batch modify metadata for local music files (mainly AAC in m4a, with some mp3) in my local music library from the macOS Apple Music app using regex. Specifically, I'd like to retitle tracks using matching groups from a regex on the existing title. Can this be done via any Apple scrip...
I would like to batch modify metadata for local music files (mainly AAC in m4a, with some mp3) in my local music library from the macOS Apple Music app using regex. Specifically, I'd like to retitle tracks using matching groups from a regex on the existing title. Can this be done via any Apple scripting facilities, like the Shortcuts app, the Automator app, or any other Apple-provided scripting? In Shortcuts, I tried to pass the output from a "Find Music" action to a "Run JavaScript for Mac Automation" action, but I keep getting errors (like The operation couldn’t be completed. (WFMacHelperErrorDomain error 1.) even when I don't modify the run function at all) no matter what I do. If not, do any third-party scripting facilities work with the Apple Music API such that the files get modified through Apple Music, instead of directly modifying the files, then having Apple Music scan the file system for changes? If nothing works with the Apple Music API, what third-party tools/libraries offer batch regex music metadata parsing & modification? For third-party scripting, I'd prefer JavaScript/zsh/Java/Kotlin/etc.
XDR (664 rep)
Sep 4, 2024, 09:44 AM • Last activity: Jun 29, 2025, 06:04 PM
1 votes
2 answers
905 views
AppleScript App to start a Slideshow in Finder
I want to write an AppleScript App that starts a full screen slideshow with all pictures in the currently active folder in Finder (on Big Sur/Apple M1). Manually, in Finder I would have to open a folder, press command ⌘ + A to select all pictures (or files) inside, then press option ⌥ + spacebar to...
I want to write an AppleScript App that starts a full screen slideshow with all pictures in the currently active folder in Finder (on Big Sur/Apple M1). Manually, in Finder I would have to open a folder, press command ⌘+ A to select all pictures (or files) inside, then press option ⌥+ spacebar to start the slideshow. I want to write a Script-App, that does all that for me (and which I then can put in Finder's toolbar). I am a newbie to this all, so please explain it for the dummy I am!
user406773 (41 rep)
Feb 15, 2021, 04:39 PM • Last activity: Jun 27, 2025, 07:10 PM
3 votes
1 answers
163 views
Bulk copy/export name, Modification & Creation Date from multiple files in a folder
I have a bunch of files inside a folder that I want to get the Date Modified and Created from and copy it into a text document or some kind of tab delimited document. I have no idea how to do this. Opening each one and manually copy/pasting the Creation Date is not an option, as this is hundreds of...
I have a bunch of files inside a folder that I want to get the Date Modified and Created from and copy it into a text document or some kind of tab delimited document. I have no idea how to do this. Opening each one and manually copy/pasting the Creation Date is not an option, as this is hundreds of files. Can this operation be automated or scripted? EDIT: I found that using the following will give me all the various date formats and puts them in a txt file, and all dates preserved: (stat -f "%N%tAccess:%t%Sa%tModify:%t%Sm%tChange:%t%Sc%tBirth:%t%SB" *)>creation.txt However, when I then try to copy that information into an excel sheet, even though it keeps the days and times, all the years are changed to 2023. txt file: > EXAMPLE.mp3 Access: Dec 9 11:48:21 > 2023 Modify: May 19 21:37:55 2020 Change: Dec 7 19:03:24 > 2023 Birth: Nov 26 06:07:58 2014 Pasted into excel spreadsheet: > EXAMPLE.mp3 Access: Saturday, > December 9, 2023 Modify: Friday, May 19, 2023 Change: Thursday, > December 7, 2023 Birth: Sunday, November 26, 2023
GodzFire (61 rep)
Dec 4, 2023, 01:29 AM • Last activity: Jun 2, 2025, 12:03 PM
6 votes
4 answers
3935 views
How to increase cursor size programmatically?
How do I increase the cursor size programmatically? I know [how to do it manually][1]. Is there a script that can do it from the command line rather than an AppleScript that does it from the GUI. ## Why? I do a lot of customizations to my Mac, but I also create new users all the time. To save time,...
How do I increase the cursor size programmatically? I know how to do it manually . Is there a script that can do it from the command line rather than an AppleScript that does it from the GUI. ## Why? I do a lot of customizations to my Mac, but I also create new users all the time. To save time, I would like to programmatically achieve certain customizations.
abbood (2853 rep)
Sep 15, 2017, 07:03 AM • Last activity: May 21, 2025, 10:44 PM
2 votes
2 answers
668 views
macOS: Double click on a file and display the output from a CLI command on the file?
There is a file type called "netCDF". My goal is to be able to double click on a netCDF file on Finder and see the text output from a CLI command to which the filename is given. Specifics: There is a command-line command that displays the table of contents of a netCDF file: ```` $ ncdump -h yourfile...
There is a file type called "netCDF". My goal is to be able to double click on a netCDF file on Finder and see the text output from a CLI command to which the filename is given. Specifics: There is a command-line command that displays the table of contents of a netCDF file:
`
$ ncdump -h yourfile.nc
` This command shows the table of contents of the netCDF file to the current terminal. **How can I see the same output when I double click on the file on Finder?** **Edit: The following is a description of a failed approach.** I have made some progress toward a solution. Following this thread https://apple.stackexchange.com/questions/224394/how-to-make-a-mac-os-x-app-with-a-shell-script I've been able to create a macOS "app" which is actually a shell script:
`sh
#!/bin/sh
/usr/local/bin/ncdump -h "$@"
` So far, I've been able to verify that I can invoke this "app" from Finder and that the above shell script is actually run. But, I found that the shell script doesn't get the filename as a command line argument. (You can see what's going on by modifying the line to /usr/local/bin/ncdump -h "$@" > $HOME/tmp/logfile.txt 2>&1) So, I have two specific questions 1. How can a shell script (as app) get the filename when invoked from Finder? 2. To which GUI app should it send its stdout and how?
Ryo (161 rep)
Sep 2, 2022, 04:23 AM • Last activity: May 5, 2025, 03:08 AM
3 votes
2 answers
3176 views
Apple Script: 'activate' an application in fullscreen
Im trying to run `tell application "X" to activate` on an application that is running in fullscreen, but its not working. Any ideas on how I can work around this and give focus to a running app in fullscreen?
Im trying to run tell application "X" to activate on an application that is running in fullscreen, but its not working. Any ideas on how I can work around this and give focus to a running app in fullscreen?
defmc (81 rep)
Sep 18, 2019, 11:21 AM • Last activity: Apr 17, 2025, 09:00 AM
24 votes
2 answers
6104 views
Replace password prompt with Touch ID to read Keychain password
I'm using the following command to fetch a password from the Keychain in a shell script: `security find-generic-password -w -s "MyServiceName"` It works, but it's showing a popup window asking me for the login keychain password: > `security` wants to use your confidential information stored in > "My...
I'm using the following command to fetch a password from the Keychain in a shell script: security find-generic-password -w -s "MyServiceName" It works, but it's showing a popup window asking me for the login keychain password: > security wants to use your confidential information stored in > "MyServiceName" in your keychain. To allow this, enter the "login" > keychain password. > > With the options to Deny, Allow or Always Allow But I don't want to enter my keychain password every time, so I can't use "Allow" and I'd rather not "Always Allow" in order to keep some level of security here. Ideally I'd like to get a Touch ID prompt instead. Is there any way to do this ?
Coyotwill (359 rep)
Jan 5, 2018, 10:19 PM • Last activity: Mar 10, 2025, 02:27 PM
0 votes
2 answers
257 views
Using "screencapture" sometimes only takes screenshot of wallpaper
I have a working Python script that take screenshots of my single macOS display every minute using `screencapture`. The script essentially loops `os.system(f'screencapture {output}.png')`. Every once in a while, the screenshots suddenly start only showing my wallpaper. I know this isn't a screen rec...
I have a working Python script that take screenshots of my single macOS display every minute using screencapture. The script essentially loops os.system(f'screencapture {output}.png'). Every once in a while, the screenshots suddenly start only showing my wallpaper. I know this isn't a screen recording permissions issue for Python, since the script works 99% of the time. Furthermore, once the buggy behavior starts, taking screenshots with screencapture myself on Terminal.app does the same thing. The bug never goes away by itself. The only fix I've found so far is to frustratingly restart my computer. Is there any documentation or fix for this behavior? Edit: To clarify, I am still able to take non-glitched screenshots with keyboard shortcuts like Shift + Command + 3.
antoine (103 rep)
Jul 13, 2024, 11:55 PM • Last activity: Mar 3, 2025, 05:01 PM
4 votes
2 answers
2024 views
How to remotely & automatically switch a Mac's audio output device
I have a Mac (running Catalina) dedicated as a media server, running Plex and Spotify. I'd like to be able, from my Mac laptop, to simply click something and switch the remote Mac's audio output setting from its internal speakers to 'Bat Cave', my gen 4 Apple TV. Any thoughts about how to accomplish...
I have a Mac (running Catalina) dedicated as a media server, running Plex and Spotify. I'd like to be able, from my Mac laptop, to simply click something and switch the remote Mac's audio output setting from its internal speakers to 'Bat Cave', my gen 4 Apple TV. Any thoughts about how to accomplish this? I'm more at home with Unix shell scripting than with AppleScript or Automator, but any solution, including hybrid, would be great.
Chap (1316 rep)
Apr 13, 2022, 03:49 PM • Last activity: Feb 20, 2025, 03:33 PM
0 votes
0 answers
33 views
launchctl: Run script when network interface is added/comes up?
I'm looking to run a script when 'bridge100' interface is added with an IP. How is this accomplished? I see [this post][1] to add the following, however I'm not sure how one can understand that 'bridge100' was the interface added and also has an IP just by looking at these files change timestamps: L...
I'm looking to run a script when 'bridge100' interface is added with an IP. How is this accomplished? I see this post to add the following, however I'm not sure how one can understand that 'bridge100' was the interface added and also has an IP just by looking at these files change timestamps: Label ifup.ddns LowPriorityIO ProgramArguments /Users/Shared/bin/ddns-update.sh WatchPaths /etc/resolv.conf /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist RunAtLoad or a watch on: /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
atod (77 rep)
Feb 8, 2025, 03:53 PM • Last activity: Feb 9, 2025, 04:20 AM
0 votes
1 answers
172 views
Running shell script with Touch ID authentication
Leveraging AppleScript, we can run a shell command that requires `sudo` by asking for elevated permissions, which in turn shows a prompt to the user. For example: do shell script "/usr/bin/say example" with administrator privileges Prior to Sonoma, this used to show a Touch ID prompt (on supported M...
Leveraging AppleScript, we can run a shell command that requires sudo by asking for elevated permissions, which in turn shows a prompt to the user. For example: do shell script "/usr/bin/say example" with administrator privileges Prior to Sonoma, this used to show a Touch ID prompt (on supported Macs) or a password prompt (on Macs without Touch ID). But then it stopped working and it now always shows a password prompt. Is there a way to get the behaviour back? The requirement is simple: I want to run a script with elevated permissions and show a Touch ID (or password prompt when on an unsupported Mac) to ask for the authentication. The full thing should still return the script's exit code as that is important for error detection. I'm not married to AppleScript, I'm open to something in Swift which has to be compiled. But it does still need to run an external script.
user137369 (1666 rep)
Feb 1, 2025, 05:54 PM • Last activity: Feb 1, 2025, 09:34 PM
1 votes
0 answers
71 views
MacOS: How to prevent DHCP server sending traffic to interfaces?
How can I prevent the Mac v13.7.3 DHCP server from sending traffic to network interfaces? I.e. how can I manage this? I'm trying to invoke `dnsmasq` and another application is using port 67 socket. I also notice the VirtualBox clients are getting DHCP addresses on the "HostOnly" network. I see this...
How can I prevent the Mac v13.7.3 DHCP server from sending traffic to network interfaces? I.e. how can I manage this? I'm trying to invoke dnsmasq and another application is using port 67 socket. I also notice the VirtualBox clients are getting DHCP addresses on the "HostOnly" network. I see this launchd is using the port: sudo lsof -i :67 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME launchd 1 root 29u IPv4 0x60ac5cc81221ae9f 0t0 UDP *:67 launchd 1 root 39u IPv4 0x60ac5cc81221ae9f 0t0 UDP *:67 From this question and answer I put together that launchd may be invoking the DHCP server. I tried to edit /private/etc/bootpd.plist in the section to disable the dhcp server: dhcp_enabled and reload as follows, however I get errors: $ sudo /bin/launchctl unload system/bootpd.plist Unload failed: 5: Input/output error I try the following suggestion, however the port is still being used: $ sudo launchctl unload -w /System/Library/LaunchDaemons/bootps.plist $ sudo launchctl load -w /System/Library/LaunchDaemons/bootps.plist $ sudo lsof -nP -i:67 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME launchd 1 root 39u IPv4 0x60ac5cc8052e1e9f 0t0 UDP *:67 launchd 1 root 41u IPv4 0x60ac5cc8052e1e9f 0t0 UDP *:67 $ sudo launchctl stop -w /System/Library/LaunchDaemons/bootps.plist Exit status: 3 I didn't expect VBox clients to be receiving DHCP datagrams because nothing is checked in the GUI and the VBoxManage command line tool doesn't show any DHCP server active. I'm running VirtualBox with HostOnly networks. I think this is what creates the bridge. bridge0: flags=8863 mtu 1500 options=63 ether 82:00:0b:4b:e4:00 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x0 member: en2 flags=3 ifmaxaddr 0 port 8 priority 0 path cost 0 member: en3 flags=3 ifmaxaddr 0 port 9 priority 0 path cost 0 nd6 options=201 media: status: inactive
atod (77 rep)
Jan 28, 2025, 12:39 PM • Last activity: Jan 29, 2025, 12:26 AM
0 votes
0 answers
19 views
Keyboard Scripts: Use F1, F2,etc. keys as standard function keys, is there a quicker way to change this?
Can changing this value be scripted in the shell? I'm find myself using VirtualBox frequently and I need these to be function keys at times. Under Preferences->Accessibility->Keyboard->Keyboard Shortcuts->Function Keys. [![enter image description here][1]][1] ref: my copyright [1]: https://i.sstatic...
Can changing this value be scripted in the shell? I'm find myself using VirtualBox frequently and I need these to be function keys at times. Under Preferences->Accessibility->Keyboard->Keyboard Shortcuts->Function Keys. enter image description here ref: my copyright
atod (77 rep)
Jan 28, 2025, 10:37 PM
0 votes
0 answers
49 views
Update /etc/resolv.conf without removing old entries? Upon network connection?
Is there a script hook that's invoked when connecting to a network after or during /etc/resolv.conf being updated (usually with DNS entries from DHCP server)? I'm running a `bind` name server on localhost so I can serve DNS to my VirtualBox HostOnly network. I want to update `/etc/resolv.conf`, howe...
Is there a script hook that's invoked when connecting to a network after or during /etc/resolv.conf being updated (usually with DNS entries from DHCP server)? I'm running a bind name server on localhost so I can serve DNS to my VirtualBox HostOnly network. I want to update /etc/resolv.conf, however if the network connection changes to a different WIFI network, I want to ensure /etc/resolv.conf has correct entries in it. For instance, when bind starts update /etc/resolv.conf and also when the network service changes update it as well. I have the following script so far: $ cat bind-start.sh #!/bin/bash # TODO # Which interface to choose? # More subnets? networksetup -setdnsservers $( networksetup -getdnsservers Wi-Fi | sed '/127.0.0.1/d' | tr '\n' ' ' ) "127.0.0.1" networksetup -setsearchdomains $( networksetup -getsearchdomains Wi-Fi | sed '/p0.mac/d' | tr '\n' ' ' ) "p0.mac" $ cat bind-stop.sh #!/bin/bash # TODO # Which interface to choose? # More subnets? networksetup -setdnsservers $( networksetup -getdnsservers Wi-Fi | sed '/127.0.0.1/d' | tr '\n' ' ' ) networksetup -setsearchdomains $( networksetup -getsearchdomains Wi-Fi | sed '/p0.mac/d' | tr '\n' ' ' )
atod (77 rep)
Jan 28, 2025, 02:52 AM • Last activity: Jan 28, 2025, 03:36 AM
Showing page 1 of 20 total questions