New answers tagged

0

I ran into this problem some time ago, and my solution was to use curl beforehand to determine if an address was accessible. Make a subroutine to check if an address exists: on addressExists(address) try do shell script "curl -I --connect-timeout 0.5 'http://" & address & "'" --will error if address does not exist return true ...


0

OK. I figured this out with the help of @kenjikato. @user3439894 pointed out my variable typing issues. Kenji's fixes resolved that issue and his reporting additions helped me troubleshoot more quickly and productively when the script still failed to move past the first entry in the list array. With the help of our friend Google, one of the thrown errors ...


0

I was able to make your script work properly with a couple of small changes, and a couple of additions that will make sure things run smoothly 😉. Most likely your main error is item 3 from these changes. You should not overwrite the thePath var on line 19, rather set the POSIX output to a new variable like saveToPath. This in turn means you need to change ...


0

I would have gone about this a bit differently. First, I'd use Disk Arbitrator so the external disks would mount read-only and not preform any Spotlight indexing. There's no need to allow indexing if the target is just .qbb and .qbo files to be found using the find command. Second, I'd use an Automator Folder Action with a Run Shell Script action, as IMO ...


1

The following example AppleScript code works for me in macOS Catalina to restart the system and click the Restart button on the "There is a user sharing this computer. If you restart they will be disconnected" dialog that shows if Users accessing File Sharing on the machine are connected. tell application "Finder" to restart repeat 5 times try ...


1

– user3439894, Thanks for the Help! This got me really close! For anyone who needs to do the same thing, here's what I did to make it work. In my circumstance, I needed an application, so I can save it on a hard drive and use it on whatever Mac I'm working on at the time. I didn't need another service to clutter up my menus. Here's how it's done: 1) ...


0

launchd manages the daemon(s) that ultimately run your job (in your case an scpt). But in a setup similar to the "man behind the curtain" in The Wizard of Oz you don't talk directly to launchd. Instead, you will prepare a .plist (property list) file that will be parsed by launchctl, and only then presented to launchd for action. I did this (manually ...


3

On Mojave it is simpler than I thought. Clicking the power/fingerprint button will quickly bring the login screen out, with the other user already chosen, ready for the password to be inputed. After the login it will be possible to switch with just fingerprint-click + fingerprint (for authentication). That's pretty convenient! Note: I am not sure if that ...


0

I do not think that you can build a browser like that, but I do know that there is a very simple browser out that which will take whatever URL it is sent and pass it to the clipboard: https://github.com/alistairmcmillan/short/tree/master/Copy%20URL%20to%20Clipboard Perhaps that might help.


0

Fix for wch1zpink's answer on OS X 10.15.4, thanks to the UI Browser app: tell application "System Preferences" reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays" end tell tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display" set isScaled to value of radio button "...


0

Can’t guarantee this, but here’s what I would try: Create a .webloc on the desktop, pointing to any URI. Select it, Get Info, and change its application to your desired default. You’ll have to change “suggested apps” to “other” to be able to do it. Check the box to do it for all files of this type.


1

you can use this tutorial to use launchd: https://www.maketecheasier.com/use-launchd-run-scripts-on-schedule-macos/ <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>9</integer> <key>Minute</key> <integer>0</integer> <string>/Users/user/Scripts/...


1

It seems that TextEdit hardcodes the position for new document windows, and it's not possible to tweak this behaviour using defaults write to modify TextEdit's Preferences. See this old post from Apple Discussions: The current version of TextEdit does not maintain a preference in the com.apple.TextEdit.plist file concerning window placement for the ...


2

Turns out, My answer was simple I added a delay function set myTime to (time of (current date)) set waitTime to 86400 - myTime delay (waitTime) tell application "Messages" activate end tell tell application "System Events" keystroke "Good Morning" keystroke return log {"checked at % seconds since midnight", myTime} end tell delay (3600)


1

Obviously the other answer works but there is an AppleScript method as well. tell application "System Events" to tell screen saver preferences to set delay interval to 0


1

red_menace gave a hint about sending commandline arguments into osascript to be received by the AppleScript run handler, but given that he didn't show how this would be done, I thought it might be helpful to demonstrate this method, especially as it's by far the simplest. The beginning of the script is going to look identical to red_menace's, and indeed ...


-1

Try dragging it to the applications folder. Siri may only be able to open apps that are in the applications folder. Or you might be able to use Automator.


1

Arguments for a stand-alone osascript are passed as a list of strings to the AppleScript run handler, for example on run argv - see the osascript man page. If you are using osascript inside another script, you can just use the arguments you already have - expanding variables in a heredoc, for example. The following example will use arguments from the ...


1

The @user3439894 comment provides a better solution but since this is tagged as applescript, here is an applescript answer. Will prompt user to choose one or more rtfd, copy them to the desktop, turn them into actual folders, extract each one's text/rtf component to the desktop, and trash the unwanted bits. I don't know how you actually get the target files ...


-1

For a single document, unless there's formatting you want to preserve, the easiest way is to first save it as a plan text document, then re-save it as an RTF. Or first paste the selection into BBEdit then Select All, Copy, and Paste into TextEdit. If there is formatting you want to save, and there are only a few icons or other objects, just delete them and ...


-1

Ok in that case I've ended up putting a dummy button between both /usr/bin/osascript -e 'display dialog "Choose Button ..." buttons {"YES", "", "NO"} with icon file ((path to home folder as text) & "Path:to:picture.png")'


1

Getting your application to respond specifically to a user clicking on its dock icon is difficult. A simpler task is to get your application to respond to acquiring focus where it previously belonged to another application, i.e. whenever your application is brought into the foreground, which clicking on the dock icon will do. I've heavily commented the ...


0

Renaming and moving files with other actions in Automator usually involves saving the list of file items to restore later, then adding the other actions using the Ignore Input option as needed to keep from mixing up the various results. If you are using a destination folder for the final result, you can use a workflow something like: Folder Action receives ...


1

I thought that since I do have this app that I'd take a look at it. Normally I avoid UI scripting to every extent possible but having been compelled to do so recently, I decided that playing around with this might help me understand it better. I did at least get a headache out of the effort. Anyway, I don't believe it is possible (at least with my v4) ...


0

No answer, but still bugged by this – "macOS bug". While the significance of 1946-02-14 08:34:56 is truly an inspiring story, this does not seem to be the culprit of this issue at all. Using the workflow below I see the exact same behavior. When I move a file from desktop into Downloads/ it is displayed with a "Date created" and "Date added" of today. I ...


1

I could get this to work by piping the password to sudo from a file instead of using echo: sudo -S date 0101000120 < ~/passwd.txt I'm not sure what security implications this has though, but it feels wrong ... If you're after a quick and dirty solution then this will do it, however as per nohillside's comment, here are some instructions to run sudo ...


1

Not on macOS No, there is no Apple supported programmatic way of logging in a user on macOS. One approach would be to create a virtual smart card and simulate a user logging in. This would require significant effort and development time.


1

Along with the information window, a dialog can be put up to get the whereFrom text, with a little AppleScriptObjC (since a shell script has been posted in another answer) to add it. Extending the Automator folder action in my answer to your previous topic, the replacement Run AppleScript action would look something like: use AppleScript version "2.4" -- ...


0

If you want to add Where from: info under More info: on a file's Get Info window, i.e., as if pressing ⌘I on a selected file in Finder and seeing it there, then the following example in Terminal can do that: xattr -w com.apple.metadata:kMDItemWhereFroms 'https://apple.stackexchange.com/questions/386599/manually-enter-where-from-text-for-screenshot-metadata' ...


1

It takes a few seconds to do its thing, but you can use a folder action. If you are using Mojave or later, a destination folder for the screenshots can be set by using the Options menu of the Screenshot.app. Create a folder action document in Automator, setting it to receive files added to the screenshot folder, and add a Run AppleScript action: on run {...


0

I found the answer on StackOverflow: https://stackoverflow.com/questions/3485061/applescript-i-copied-the-finder-selection-to-the-clipboard-can-i-get-the-full https://stackoverflow.com/questions/15748909/get-path-of-file-from-clipboard-in-os-x Specifically: First install https://github.com/programming-nu/nu: brew install nu Then this script does what ...


-1

There is a right click command on AppleScript. Might also be worth looking into a combination of CliClick and cURL using Brew / Bash for this purpose.


1

Numbers don't work like that. Sorry. There is a function that does exactly what you want but I don't know if it's available in Apple Script. The function is called mod. I know it's available in python. The function works like so. enter 2 numbers into the mod function. An example is mod(12,2). what you are asking is 12 divisible by 2. so you could have mod(...


0

Here is a one liner to toggle between dark-mode osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to not dark mode' Better as a method dark-mode() { osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to not dark mode' }


1

Found the answer using text delimiters set saveTID to text item delimiters set text item delimiters to ", " set Final to rarOrder as text set text item delimiters to saveTID set the clipboard to Final


1

I eventually solved the problem using SwiftDefaultApps command line tool swda. It works. Although, this box now shows up blank in system setting.


1

If you are using Node.js and want to create notifications on multiple platforms including Apple, this library probably has what you want: https://github.com/mikaelbr/node-notifier disclaimer: I am not the author


0

You could try the following example AppleScript code: set src to quoted form of ¬ (choose folder with prompt "Choose source folder where source tree is rooted at")'s POSIX path set shellCommand to ¬ "cd " & src & " && echo 'Object #' > \"$HOME/Desktop/names.csv\"; ls | grep -Eo '^[0-9]+' | sort -u >> \"$HOME/Desktop/names....


-1

I have a solution that may work for you. This approach will not require the use of Automator or keyboard shortcuts for pasting text into password fields. In Script Editor.app, paste this following AppleScript code into a new document and save it as a .scpt file. I named my version Cyber_Test.scpt. For this following approach to work correctly, you will ...


1

You're telling Applescript to send key down and key code 13. Just use the following: osascript -e 'tell application "System Events" to key code 13'


1

Errors in folder actions will fail silently unless you trap them. You can use a try statement, but in your snippet you are ignoring errors, such as: AppleScript itself doesn't know about file names, so you need to use something that does, such as Finder; The shell uses spaces as delimiters between arguments, so you need to make sure they are used as needed ...


1

From this answer, I made a workout solution. But I am hoping for a more direct method. app = Application.currentApplication(); app.includeStandardAdditions = true; app.openLocation("timer://30m")


1

I've found it useful to put the folder action code into a template that can also be run as an applet, droplet, or from the Script Editor. It can then be used for testing and/or manually run for chosen files: on run -- applet or from the Script Editor doStuff for (choose file with multiple selections allowed) end run on open droppedItems -- droplet ...


1

The alternative is to activate your app through Dock: tell application "System Events" to click UI element "MyAPP" of list 1 of application process "Dock" The way I got here is to use Automator's record feature and copy the steps" and paste them in Script Editor. It translates them to AppleScript.


0

If the application is already running then try this: tell application "System Events" to set frontmost of process "NameOfApp" to true


1

First, you're going to need an AppleScript that can mute the system audio. set volume 0 Now you need a way to execute this script from anywhere. We'll use macOS services, and Automator makes this super easy for us. Open Automator Make a New Document of type "Quick Action" (or "Service" in older macOS) Drag a new Run Applescript action into the workflow. ...


Top 50 recent answers are included