New answers tagged

0

You're close. Get the path to your file by making a one-line script: set the_file to choose file Copy the result of that. Then, in the script that will open the "Fallen_Order_Intro" script, tell the Finder to do the opening for you, pasting in your second script's path, obtained using the "choose file" script. Here's how it would look if your ...


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

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

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 ...


0

I don't think its possible to auto run an applescript file when someone opens an email. But the user can manually open the file and run it.


0

I just found a way to do it. Although I'm creating an application instead of a service, they are almost the same. The basic idea is to put tell application iTerm into another script or into quotes, such that the optimization process won't make it open iTerm before executing this script. Thus you'll get the real result of if application "iTerm" is running. ...


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 ...


0

Karabiner, which Joonas suggested, natively has back/forward options for buttons 4 and 5. You do not have to create a xtml file. The option is under 'pointing device' > 'button to key' > 'use button 4 and 5 as back/forward'. I have only used it for 30 minutes so far, but it worked straight away by just activating those checkmarks (mouse: ttesports black v2)


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 ...


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:


0

Thanks guys! :) I have figured out the solution. Turns out my original script was set remMachine to "eppc://user@1.2.3.4.local" using terms from application "Finder" set volume 10 of machine remMachine end using terms from Thank you for all the help :) The solved script was: set remMachine to "eppc://user@1.2.3.4.local" tell ...


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 ...


0

In order to remotely control a Mac, say your desktop machine, you must first set it up for commands to be sent to it. To do this, launch System Preferences > Sharing on the Mac you want to control. Click the box next to Remote Apple Events, and set user restrictions if you need to. Next, you will need the IP address. In System Preferences, switch to Network ...


0

Use its or of it, like this: tell application "TextEdit" set theDoc to document of window 1 get every window whose its document is theDoc -- or --> get every window whose document of it is theDoc end tell


0

I did a bit of experimentation, and I get varied results. Fortunately, one of those results was 4. I did this by outsourcing the calculation to Python: on run {input, parameters} set var to "wx̀y" set output to (do shell script ¬ "python - <<EOF # -*- coding: utf-8 -*- print len(u'" & var & "') EOF") return output end run


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 ...


0

Building upon jackjr300's answer, you can add the path to the comment with this modified script: set input to choose file with prompt "Select files (to put the file name into the Spotlight Comment)" with multiple selections allowed tell application "Finder" repeat with i in input tell item i to try set tName to (get name) ...


0

Download with Description For gathering future YouTube contributions, consider downloading the files using the open source tool youtube-dl. youtube-dl can automatically put the YouTube meta-data into the downloaded file, so that it is accessible by Spotlight on OS X. As an example, the following command downloads every Global Mission of Peace YouTube ...


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 ...


0

This is very easy: Get some text to search for. You can use "Ask for text". Or something like the following: display dialog "What do you want to search for?" default answer "" Make a Google search URL. I used this snippet: on run {input, parameters} return "https://www.google.com/search?q=" & input end run Get the contents from the ...


0

This is the method I used on my entire Zotero library (~3GB of PDFs). Note that the only annotations I use are highlighting (single color) and comments. Whether or not this successfully converts more complicated annotations depends on the detail of the skimembed script, which I don't know much about. What worked The original skimembed script converts a ...


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 ...


0

Use the key code 19 command, because the keystroke "2" command simulate the key code 84 (numeric keypad) instead of key code 19. tell application "System Events" to key code 19 using command down To know the key code of some key, download this application --> https://itunes.apple.com/us/app/key-codes/id414568915?mt=12 But, you do not need GUI Scripting ...


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 ...


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 ...


0

I managed to find the following solution. tell application "System Events" to tell process (name of current application) tell menu bar item "Edit" of menu bar 1 click menu item "Paste" of menu 1 end tell end tell delay 0.1 The delay is there to give the system time to copy before using the clipboard.


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


0

To set the path of an AppleScript script or app to a variable use the following code: set thePath to POSIX path of (path to me as text) Example: set thePath to POSIX path of (path to me as text) display dialog "The path to me is: " & thePath If you want the path up to the script or app set to a variable use the following code: set thePath to ...


0

(The manual way) Cmd-click (or right-click) the Acrobat window title and choose the parent folder. Åpen Terminal and drag the PDF-file into the terminal window. Copy the file path from the Terminal window.


0

So here's an AppleScript that I pasted together with the help of some other answers and the AppleScript reference. This puts the URL of the frontmost Acrobat document to the clipboard, e.g: file://localhost/Users/Your%20Username/Documents/Some%20Folder/Filename.pdf tell application "System Events" tell process "Acrobat" set thefile to ...


0

Someone posted this and when I reloaded the page it was gone! Not sure why: seems to work!: diskutil eject "/Volumes/Photos" This is a shell script, not an AppleScript, but since I'm triggering it in Keyboard Maestro, it's just as good.


0

You can use this Apple Script to close this window: tell application "System Events" key code 53 using {command down, option down} -- ESC + ALT + CMD keystroke "w" using command down end tell This window is owned by loginwindow process and it's not that easy to interact with it. Here's the code to press Force Quit button on this window: tell ...


0

In Acrobat, like in many applications, you can drag-and-drop the document icon from the window's title bar to other applications, which hands over the file's path (hold down the mouse button slightly longer before dragging). For example, if you drop the icon on the Desktop, the Finder creates an alias icon. If you drop it in a TextEdit document, the PDF is ...


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 ...


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" | ...


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.


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 ...



Top 50 recent answers are included