Hot answers tagged

4

on run {input, parameters} is AppleScript syntax, not a valid shell command. If you want to execute AppleScript in the service, use the Run AppleScript action instead of Run Shell Script.


3

To have a portion of the string returned, the format would be: set StringVariable2 to (characters n through n of StringVariable1) as string n is the character number of the string starting at 1 as string is important or otherwise you get a list of single characters returned In your example of removing the last character, it would be: set StringVariable2 ...


2

@Feanux I was answering your question and then you deleted it but I see you reposted it, anyway I have made a Automator app that does this and will attach a screenshot (that was taken by Automator). As you can see it takes two screenshots, one for clipboard and one for preview/save UPDATE:


2

You can use -b option and use Bundle Identifier instead of using Application name. For example, to get Bundle Identifier from Safari: plutil -p /Applications/Safari.app/Contents/Info.plist | grep BundleIdentifier as a result You'll get "CFBundleIdentifier" => "com.apple.Safari" Then You use it like this: open -b com.apple.Safari /path/to/file ...


2

I think what you need is: set T to text returned of (display dialog "Query?" buttons {"Cancel", "OK"} default button "OK" default answer "") If you want to do this from a bash script, you need to do: osascript -e 'set T to text returned of (display dialog "Query?" buttons {"Cancel", "OK"} default button "OK" default answer "")' I can explain it in more ...


2

klanomath's helpful answer contains viable solutions, but the cleanest and simplest approach is to compare items of the same type directly: set datesubmit to {27, May, 2016} set trydate to {day, month, year} of (current date) if trydate = datesubmit then log "works!" end if Both date variables now contain 3-element lists ({ ..., ..., ... }) that can ...


2

After some trying I come to the conclusion that a variable set to {day, month, year} of (current date) isn't a "string" with the form "day, month, year" but "daymonthyear". So you may change the script to set datesubmit to "27May2016" set trydate to {day, month, year} of (current date) log (datesubmit) log (trydate) if trydate as string is equal to ...


1

QuickTime Player doesn't have a Preferences... menu command like other applications do, nor does it have a com.apple.quicktime.plist file to manipulate. Therefore there isn't anything you can do directly, however here is a workaround of sorts. Note that this workaround requires changing the default application for file types, e.g. .mov, you'd normally open ...


1

Perl's File::Find is ideal for iterating over all the files in a folder. This approach deals with one file at a time, is fast, and memory efficient. Use AppleScript to present the folder choice and then pass the selected folder path to your perl script: set myFolder to choose folder with prompt "Choose a folder:" do shell script "perl ...


1

URL is a property of a document or a property of a tab in a window, so use this: if URL of document 1 is "www.google.com" then or this: if URL of current tab of window 1 is "www.google.com" then Update, example of how to use the exists command: tell application "Safari" set b to exists URL of document 1 -- this put false or true into the ...


1

What's the fully qualified pathname of the executable? If it's not within in the $PATH that's passed to the do shell script command, which is /usr/bin:/bin:/usr/sbin:/sbin, then you'll need to use the fully qualified pathname of the executable. To make an executable available globally, it must be in a directory that's included in the $PATH. You can also ...


1

Here is an answer to get right the pathname of .. from AppleScript: Get Current Path to Script within AppleScript and Append Subdirectory Anyway, the actual construct you got: /path/to/folder//myscript.pl is a correct pathname to your Perl script. The 1st / is coming from the terminal one coming from container: /path/to/folder/. Hence your built find ...


1

I finally figured it out: I can achieve what I want by using the $ARGV array which holds all arguments that are passed on to the perl script via the command line. In an applescript I can simply put this line: do shell script "perl myscript.pl inputfile outputfile" Assuming inputfile and ouputfile are the (paths to) the files I want to run the perl script ...


1

The maximum length of a command line is 2**18 bytes: $ getconf ARG_MAX 262144 So that for example this results in an error: read "/usr/share/dict/web2" for 270000 do shell script "printf %s " & quoted form of result If the input is short enough, you can pass it to perl as part of the command line: read "/usr/share/dict/web2" for 260000 do shell ...


1

This runs with Bash, but it evokes some Ruby code: ruby - <<EOF puts /▶[^•]*•/.match("▶the first •2•3•4•5•666643") EOF If you decide to use AppleScript, you have a lot of options for what to match against: on run {input, parameters} set var to "▶the first •2•3•4•5•666643" set output to (do shell script ¬ "ruby - <<EOF puts ...


1

Try the following: tell application "Safari" activate delay 0.5 end tell tell application "System Events" open location "http://localhost:38" delay 0.5 keystroke "w" using command down keystroke "n" using {shift down, command down} end tell Now here is the code I'd choose to use as it checks to see if Safari is already open and ...


1

Not directly. You would have to figure out what underlying preferences the UI is changing, and whether there was a way to edit them directly using AppleScript or terminal commands (such as defaults write -- see man defaults for details.) Unfortunately there is no canonical list of preferences that can be edited in this way, although you can find some here. ...


1

It's System Events that handles the keystrokes. In normal AppleScript the code would look like: tell application "Safari" activate delay 0.5 tell application "System Events" key code 19 using command down end tell end tell As an osascript command line, it would be: osascript -e 'tell application "Safari" to activate' -e 'delay ...


1

The radio buttons are contained within a radio group, and the radio group is contained within a tab group. So the following code will give you the names of the radio buttons. You also need to put in a delay between opening the window and trying to talk to it. Even on an SSD equipped Macbook Pro. You might have to increase the delay if you are on an HDD ...


1

Don't know if still works on current versions of OS X, but somebody wrote a command line tool to get and set resolutions a few years ago: https://github.com/jhford/screenresolution


1

You can use a "Run Shell Script" action and sips to downscale your pictures to any value. Add a "Run Shell Script" action, make sure the input method is set to "stdin" (should be the default) and insert the following script SCALEFACTOR=500 while IFS= read file; do sips --resampleWidth $(($(sips -g pixelWidth "$file" | ...


1

As a proof of concept, I formatted a USB Thumb-drive using a GUID Partition Map and formatted it Mac OS Extended (Journaled) naming it "Encrypted". Then in Finder, I selected the disk named "Encrypted" and control-clicked selecting Encrypt "Encrypted"..., while setting its password to "password". When it was done encrypting, using Terminal, I ascertained ...



Only top voted, non community-wiki answers of a minimum length are eligible