New answers tagged

0

I'm trying to resize a Quicktime Movie Recording Window--only after it's active. Is this possible? The below script does work––if I hardcode the delay time. Preamble/disclaimer: ▸ "active" is a vague term that has more than one meaning: I interpreted first to mean "focussed", then to mean "frontmost", and then to mean "exists"; but running your script up ...


0

Here's another attempt, tested on macOS High Sierra. Alas, this is only works when the given window is on the current desktop! The AppleScript API to control windows seems to be incomplete, making this impossible. Substitute "Safari" and "WhatsApp" for your use case. tell application "System Events" tell process "Safari" try set ...


1

"Is there a workaround?" I'd call it the "right" way. Use the script editor. save the script as an application. Thus, the script becomes a full fledged application. Give the app assertive capabilities. should you want to start the app from the terminal, open your-app. What to worry about: "Effective defenses against malware and other threats" by John ...


0

Or you can also make it more readable by doing something like this... set props to {target:"Safari", slideNo:2} & ¬ {propsUrl:"https://docs.google.com/presentation/d/slideId/preview"} & ¬ {rewardsUrl:"https://docs.google.com/presentation/d/slideId/preview"} & ¬ {coords:{posX:937, posY:497, sizeX:149, sizeY:262}}


0

If you want it more readable, then use property and separate the list you have into individual properties, e.g.: property target : "Safari" property slideNo : 2 property propsUrl : "https://docs.google.com/presentation/d/slideId/preview" property rewardsUrl : "https://docs.google.com/presentation/d/slideId/preview" property coords : {posX:937, posY:497, ...


0

I would recommend SwiftDefaultApps which is described as "Replacement for RCDefaultApps, written in Swift". (Longtime Mac users will remember RCDefaultApps as a preference pane which could be used to set default apps for certain types of files.) What makes SwiftDefaultApps the better solution, IMO, is that most of the other suggestions seem very ...


0

You can check out my answer here to a similar question. The salient, script-portion of it is a JavaScript For Automation (JXA) script that can change the default application for all files of a specified uniform type identifier. It can be run in Script Editor by changing the language option in the navigation bar at the top of the window from "AppleScript" → ...


1

For reasons of which I cannot explain, this following code was unreliable and only worked about 50% of the time. tell application "Finder" set finderWindowID to (make new Finder window) set current view of finderWindowID to icon view set arrangement of icon view options of finderWindowID to arranged by name end tell After trying ...


0

There is a command line application that can do this for you, it is called Duti and it is availible at https://github.com/moretension/duti . I compiled a version of Duti using Macports, and then dropped that utility in the Resources folder inside a script application wrapper, and call it using a "do shell script". I have tried it on multiple machines at ...


0

The problem is with updating it switched back to Australia language instead US english. So "minimized" is spelled "minimised" in the script. Also an updated script with error checking is below but change to minimised for UK or Australian English: tell application "System Events" tell process "Dock" tell list 1 try set ...


1

I usually avoid GUI scripting like it's the plague, but for this project I had to resort to GUI scripting in the second half of the code. Save this following AppleScript code as an application. Double-clicking this app's icon in Finder will do nothing. In short, any file you want to change its default application for, of those file types, just drag and drop ...


1

An application registers the types of items that it can handle by putting entries into its Info.plist. The CFBundleDocumentTypes key is an array of dictionary entries describing the document types (name, icon, role, etc - see the Information Property List Key Reference). For example, an application I use to provide a couple of custom document icons has ...


1

here is a working script, you just need customise it by changing the target_network value, which is the network you wish it to Enable AutoUpdates. And for all other wifi networks it will disable updates. #/bin/bash # Get WiFi network name wifi_network=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep '\sSSID:' | ...


2

As far as I know, all file associations are defined on the launchservices.secure.plist file. For macOS Mojave/Catalina this file is located at: ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist You can read the file contents using: defaults read ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices....


1

As Thomas Nelson pointed out, I had made this way too complex. Dropping the cmd=$@ local $@ && sequence solved the problem. Here is the finished function ####################### ##### Send_Notify ##### ####################### # Call this and supply the text you want to have spoken ($1) and the notification message ($2) # ie:...


0

Your code, as is, works for me in macOS Mojave when run from Script Editor; however, I do have Script Editor set to have accessibility privileges for this to work properly. If you are running that code from its own AppleScript app, or whatever you are running the code from, then you need to allow it accessibility privileges as described in the link. Also ...


1

It sounds like you know how to create a systemwide Service or Quick Action, and just need a script to open the actual bluetooth connection. Test the script below initially in Script Editor, which requires any device you wish to connect to have already been paired (it sounds like this is the case). All being well, you can be reasonably confident it will ...


1

Displaying Notifications Notification Center offers another opportunity for providing feedback during script execution. Use the Standard Additions scripting addition’s display notification command to show notifications, such as status updates as files are processed. To show a notification, provide the display notification command with a string to display. ...


0

From https://gist.github.com/jeetsukumaran/5400816 tell application "System Events" set currProcs to (name of processes) set MacVimRunning to (currProcs contains "MacVim") if not MacVimRunning then tell application "MacVim" to activate end if tell process "MacVim" click menu item "New Window" of menu "File" of menu bar 1 ...


1

Thank you, this was just what I needed for some user scripts. I made a slight modification to add a subtitle and sound. If a value is not provided, it is ignored. function _sys_notify() { local notification_command="display notification \"$2\" with title \"$1\" subtitle \"$3\" sound name \"$4\"" osascript -e "$notification_command" } alias sys-notify="...


2

I finally got what I wanted. I used an app called Script Debugger 7, though not necessary, it really helped me with all the classes & options available with each application and detailed help. Further, it was really easy to write scripts in this app. For anybody needing a similar solution, I hope this helps. This script is not the best, in terms of ...


1

This is a follow-up to TJ Luoma's answer, which I hope will fix the issues with the .plist definition that stops the job from being run in the correct manner. From manlaunchd.plist: WatchPaths <array of strings> This optional key causes the job to be started if any one of the listed paths are modified. IMPORTANT: Use of this key is highly ...


0

The problem is that your environment is not being read when run from Automator. The Bash manual for startup files says for scripts invoked non-interactively When Bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value ...


2

This was solved by KniazidisR at https://macscripter.net/viewtopic.php?pid=196447#p196447 set nodePath to "/usr/local/Cellar/node/12.5.0/bin/node " set mercuryParserPath to "/usr/local/bin/mercury-parser " set pageURL to "https://postlight.com/trackchanges/mercury-goes-open-source" do shell script nodePath & mercuryParserPath & pageURL


1

https://support.apple.com/en-il/guide/script-editor/scrptedshtcut/mac The answer is indicated here. Command + period (.)


3

A stay-open application (Polling) Although this question has already been marked as having a satisfactory solution, I'm compelled to provide an alternative. I completely agree with @TJ Luoma, who has provided, what I believe to be, by far the optimal solution, noting that a Stay Open application that polls for disk names every 5 seconds, and has to call out ...


6

I didn't downvote wch1zpink's answer, but it's very much not the way that I would solve the problem. Having an app run an AppleScript every 5 seconds is a very inefficient way to handle this situation, especially since Mac OS already has a built-in feature to do this, namely, launchd. Save this as ~/Library/LaunchAgents/com.tjluoma.itunes-on-mount.plist (...


2

https://github.com/Homebrew/homebrew-cask/issues/50413 The solution was described as going to: /usr/local/Caskroom/CASKNAME/.metadata/CASKVERSION/WEIRDIDENTIFIER/Casks/CASKNAME.rb And then from there I can remove the line that attempts to remove the login item. Then it uninstalls successfully and I can manually remove the login item.


0

It appears that this app is running on startup. In order to remove that (or install it) you have to be an admin. Before uninstalling anything in a multiuser environment, it's a good idea to check with the other users and make sure someone is not using the program. And asking the admin is a great place to ask for help/permission to remove the program.


1

Save this following AppleScript code as a "stay open" application in Script Editor.app. Disable iTunes starting up at login but enable your new "stay open" application to start at login. Be sure to grant appropriate permissions in System Preferences for your new applet to control your computer. on run -- Executed when the script is launched ...


3

One way I can think of doing this is to use a little bit of AppleScriptObjC. It provides access to the various data type representations on the clipboard, and in multiple. After retrieving the full file paths, these can then be passed to the cp command. Wrapping this in a bash function declaration: pastefiles() { IFS=$'\n' fs=($( osascript -e "...


1

You can use Cocoa’s NSURL class via some AppleScriptObjC: use AppleScript version "2.4" -- Yosemite (10.10) or later use framework "Foundation" use scripting additions set test to "https://dskjflkosdjfksdajf903094.example.com/g/f/OWZehaoqssVuXRuxqEivP_9dsa89dosidlzkxck_wqezxcd33sda-34sdf34r/%5BEBOOKS%5DEbook%20Title%20-%20Ebook%20Author%20Name.pdf" set ...


0

It could possibly happen if you have your language set to English, but your region to China: System Settings>General>Language and Region


3

However, if you do prefer to use an AppleScript solution, this following AppleScript code should do the trick. This AppleScript code works for me using the latest version of macOS Mojave. set filePathsTextFile to "/path/to/untitled.txt" set posixFiles to readFile(filePathsTextFile) tell application "Finder" repeat with i in posixFiles try ...


3

As an alternative to using AppleScript, it is so much easier just to do it in Terminal using bash, e.g.: while IFS= read -r line; do echo rm "$line"; done < /path/to/untitled.txt Run it as is with the echo command to have a look1 at its output, and if it look okay, then run the command again without echo in it. Note that when run without the echo ...


Top 50 recent answers are included