FAQ Database Discussion Community


Execute Applescript File from Python Script?

python-2.7,applescript,textmate2
I would really appreciate if someone could help me with this. I would like to make a function to execute an AppleScript file from within a Python script. The script I have so far is basically just a clock that calls the function to execute the file, and a button...

Applescript dictionary does not contain “open location?” How is that phrase found?

dictionary,applescript,missing-features
I'm trying to use the directions. From the web I swiped: tell application "Safari" open location "www.hulu.com" end tell I can only find "open" in the dictionary and I can't find "location" in the document or as a phrase. What am I missing? How would I find "open location" without...

Loop through every photo in Photos

osx,applescript
I want to clean up my Photos library and especially move all my iPhone screenshots to a new album, that way I can easily look through them and delete what I want. Now for this I first wanted to make a smart album in Photos, but it seems that Photos...

Prefixing an Applescript text items list

applescript,delimiter
I have the following code, which prompts user for a comma separated list of places: set AppleScript's text item delimiters to {","} set thePlaces to the text items of the text returned of (display dialog "Insert referenced places separated by commas" default answer "") This will result on a list...

Resize images to specific width only (AppleScript or Automator)

image,osx,applescript,image-resizing,automator
I've been searching google.com a couple of hours trying to find a way to do this, but there is no answer. Everywhere is resize to the longest size, but nothing about resize to the specified width only. Is there any way in Automator or AppleScript to resize images to a...

applescript Calculator not working

applescript,calculator
I have made a calculator which should work but doesn't. The only part that works is the addition. this is my code: my Calculator() on Calculator() display dialog "Calculator" buttons {"Add", "Multiply", "Divide"} if button returned of the result is "Add" then display dialog "What plus What?" default answer ""...

How to copy a file from a selected message to an outgoing message in outlook through applescript?

outlook,applescript
I have been trying to figure out how to copy an attachment from an incoming message in outlook to a new outgoing message through applescript. The code below is what I've got so far, but it's definitely wrong. Outlook throws and error at me stating: "Microsoft Outlook got an error:...

Apple Automator take screen capture and save to user-specified location

applescript,automator
So, I'm trying to use Automator under Mac OS Yosemite to create a service to allow a user to take a screenshot and save it to a location they specify, through some sort of "Save As" dialog. It seemed like it should be easy, but for some reason I'm running...

How to pass date information to AppleScript?

swift,applescript,nsapplescript,nsappleeventdescriptor
I am making one app that can run AppleScript via NSAppleScript. Everything had been fine but I haven't been able to figure out how to pass date information from my app to AppleScript. (Since AppleScript has date type, I suppose this is possible) The way I pass parameters to AppleScript...

“Foundation” framework can be used in AppleScript on Yosemite but not Mavericks

applescript,server
I've written an AppleScript library that makes use of the "Foundation" framework. On one computer (with Mac OS X Yosemite), everything runs fine. On my other computer (which runs Mac OS X Mavericks), I'm getting an error. When digging deeper to check what the issue is, it seems that the...

Check for charset size with AppleScript

security,passwords,applescript
I'm trying to make a script that based on charset size and guesses per second, makes an estimate on how long it would take to crack a password that the user inputs in a box. So far I can only get it to check for numbers, by trying to add...

Python: Reading characters in ASCII and giving an output with clicks

python,osx,applescript
I'm fairly new to python so sorry if this is either very basic or alternatively something that is completely impossible to do. What I'm trying to do is create a script that will read characters then output left or right clicks in ASCII binary according to the character read. Left...

Characters x through y in Applescript

applescript
I'm writing an AppleScript that generates a random number which is then inserted between a string, similar to a password salt (but not really). This is my code: set passSalt to random number from 10000000 to 99999999 do shell script "echo password | shasum -a 512" set passHash to result...

Applescript Error “can't get end of”

osx,applescript,apple,average
I am trying my hand at Applescript and can't see anything wrong with this. The Error I get is error "Can’t get end of {button returned:\"OK\", text returned:\"3\"}." number -1728 from last insertion point of {button returned:"OK", text returned:"3"} This is my code: beep set counter to 0 set tempX...

I have a script to automatically connect to VPN with AppleScript, how do I make it so it only tries to do it if I'm connected to the internet?

osx,applescript
Super n00b to the programming world, however I have done the first part. But every time I'm sitting in an airplane or somewhere else where I don't have an internet connection, an error dialog box shows up telling me it's impossible to connect to the VPN. How can I improve...

Applescript variable not usable in other script

variables,applescript
I have made an applescript that sets variable 'msshutdown' to yes and then shuts down the computer. Now I have another script exported as an application added as a login item that starts up the program 'MainStage' if 'msshutdown' is set to yes and afterwards sets 'msshutdown' to no. This...

Mac OS - Can I generate a clickable link to local file using relative path like “file:///~”

osx,hyperlink,applescript,relative-path,finder
This is the background: in my company, we use Google Drive and often have to tell each other the path to a particular file. Paths are long as we use a lot of nested folders, so it's pretty boring and time consuming to browse through all that. Now, in my...

How is color handled in AppleScript?

osx,colors,applescript,rgb
I'm trying to use AppleScript to change the background color of a Finder window and came across this code snippet, which seems to work... However, I'm not sure the logic of the color array... tell the icon view options of the front Finder window set the background color to {52942,...

How to translate this slider value change from AppleScript to JavaScript

applescript,osx-yosemite,javascript-automation
This bit of AppleScript works. If I have the System Preferences Sound panel open, and run it in the Script Editor app, it changes the volume to be at 50%. tell application "System Events" tell process "System Preferences" set v to value of slider 0 of window 0 log v...

Getting directory of input file (Applescript)

applescript
I'm confused - I've been googling for an hour and have tried probably ten different forms of set posixDirectory to POSIX path of (parent of (path to aFile) as string) but I can't seem to get it right. I'm getting the full POSIX path (including the filename) by doing set...

Use one terminal instance for many do shell scripts?

shell,ssh,applescript
So, I need to make an AppleScript to ssh into my mint headless server. I don't need to transfer files, just run commands. The issue is, when I ssh with one do shell script, it is in a separate instance than the others. Also, bonus if I don't have to...

Save/convert .applescript as .scpt

applescript
Is there a way to convert .applescript files to compiled .scpt files? I am currently using AppleScript-Sublime-Text to edit my AppleScripts in Sublime Text, and to run them (using Cmd-B). But I was wondering, is there a way to also save the files to a .scpt file from within Sublime...

“current record” doesn't work: applescripting Filemaker Pro 13 in a loop

applescript,record,filemaker
I have an filemaker Pro 13 database with around 120 records (it's for a conference). I want to team it up with BBEdit to create individual files for each abstract, thus applescript. Much to my surprise (and despite a lot of web tips on scripting) '[tag:current record]' is not recognised...

Extract PresentationNotes from keynote

javascript,applescript,osx-yosemite,automator,jxa
I'm having a hard time extracting presentationNotes from a keynote presentation using JXA (Javascript for osx) I don't want to use applescript. There is way more to this script than extracting notes. It seems rather simple. However when I get the presentationNotes its in an RichText object that doesn't seem...

How can I call brew from an Applescript

osx,applescript,homebrew
I'm trying to create a script to check if Homebrew is installed on any given mac and in case it is if it has a particular formula installed. I have the part that checks if brew is installed, but when I try to run brew list to see what packages...

Most efficient way to add filler characters to a string in Applescript?

osx,applescript
I've been working on a script that requires you to enter a username that is always equal to or less than 32 characters. My goal is to add extra characters to the end of the string if it is less than 32 characters. For example, if I used the word...

Using AppleScript, how to set the value of a cell of the Numbers App/iWork file

applescript,automator,iwork
Using the numbers file below, how do i set a value into cell B2? The hard part is that i cannot use any of the code below: set the value of cell 2 of column "B" to "200.00" or set the value of cell "B2" to "200.00" Based on the...

Trying to find and replace text in clipboard using applescript

applescript
I am trying to copy a file path to the clipboard and replace the word "Volumes" with "MyServer". Currently I can get the path and replace the spaces, which is working well. Now I just need to replace that word "Volumes" and I'm having no luck. Here is the code...

AppleScript : can’t set clipboard to

applescript,clipboard
I know this is probably really stupid But I can't sent a variable to the clipboard I still have the error message "can’t set clipboard to " I try to set the result as a variable and set the variable as text, string, Unicode text, but always the same issue...

Applescript mystery: A scientific notation conversion subroutine

osx,applescript
I have a bit of a mystery on my hands. I found a subroutine (http://macscripter.net/viewtopic.php?id=27520) to convert a scientific number into a string of digits. However, it seems to delete the remaining digits, no matter what I try. "1.23456789E+4" should become "12345.6789". Instead, it just returns "12345". Try running the...

How do I get the Path to the latest created file in a folder with apple script?

applescript,filepath
I want to get the path to the last file created in folder test set p to "/Users/palmglow/Documents/googledrive/orders/IFTTT/test" set a to POSIX file "/Users/palmglow/Documents/googledrive/orders/IFTTT/test/" set latestFile to last item of (sort (get files of (POSIX file "/Users/palmglow/Documents/googledrive/orders/IFTTT/test")) by creation date) as alias ...

AppleScript (or swift) add hours to time

swift,date,applescript
I'm trying to add 8Hours to a date (from the clipboard) set date1 to the clipboard set newdate to date1 + (8 * hours) display dialog "Purchases were downloaded at " & newdate buttons {"OK"} default button 1 But this is not working as expected, I'm having the error Can’t...

Applescript to “tell” Spotify to play isn't working after OSX update to Yosemite

osx,applescript,spotify
Previously to the Yosemite update, I used this Applescript to control my Spotify. Everything worked as a charm when I ran /usr/bin/osascript /Users/jdrummond/SpotifyControl.scpt play/pause. Now that I have updated my OSX to Yosemite, I keep getting this when I run the same command: /Users/jdrummond/SpotifyControl2.scpt:1217:1222: script error: Expected end of line,...

Generate a Salted Hash in Terminal

hash,terminal,applescript,osx-mavericks
I want to make an AppleScript that generates a salted hash with Terminal. Is there a specific Terminal command that can generate a salted hash, preferably a secure one like SHA-512? If possible, I would like one that's a one-liner so I can use it with the do shell script...

Automator: Choose from list and getting the corresponding variable value

osx,applescript,automator
I'm new to AppleScript but I do have some basic knowledge of Automator. Here is what I want to achieve: There is a simple list of URLs that I often use throughout my work. Like this: Product datasheet: URL1 Licensing: URL2 Price list: URL3 ... etc. In most cases I...

How to use “move…” verb to move sheets in Numbers?

applescript,applescript-numbers
I'm trying to figure out how to re-position sheets in Numbers. There is no way to insert things at specific location so I am hoping that I can find another way. The move verb drew my attention (it is in the Numbers dictionary) however there is little or no information,...

Applescript in Photoshop CS6: can't save a JPEG! WHY?

applescript,photoshop
I wrote a very VERY simple script droplet here. I use it to convert PDFs into a jpg after running an action. I simply drag the PDFs onto the droplet. When it finishes, no file is saved. Ever. I've tried POSIX, quoted form, saving from a server, saving from my...

Applescript Read File line by line

applescript
I'd like to make an applescript that reads a text file and for each line copies the text to the clipboard (what it does with it from here I have sorted) before moving onto the next line and copying that to the clipboard. Thanks!

Why does this applescript that tasks to iTunes sometimes fail with -1712

applescript,itunes
I have some applescript for creating a list of the fiels under iTunes control and writing it to a file, this is the complete script: tell application "iTunes" if (count of every file track of library playlist 1) is equal to 0 then set thePath to (POSIX file "/tmp/songkong_itunes_model.txt") set...

make bash script display system event dialog, then take its result and use it in an if statement

osx,bash,shell,applescript
This is my first time posting on StackOverflow after lurking for long time. I am running Mac OS X 10.10.3. I am a bash novice. I have a script that, after asking for confirmation using read in Terminal, uses grep to check whether /dev/disk1 is mounted, then formats that disk....

Status window that's always on top with AppleScript

osx,window,applescript,apple
I have a script that automates interaction with another program with a window that takes up the whole screen. I need to create a window that is always on top that I can print lines of text to so that my script can continuously give me status updates. A window...

sending Apple event to console application

applescript,appleevents
I have console app named "MyApp" it is running and I see it in the activity monitor. I'm writing in AppleScript Editor the script: tell application "MyApp" display dialog "Hello World" end tell When running the script the editor asks me where is MyApp? And it doesn't appear in the...

How to customise notification in os x using applescript

osx,notifications,applescript
Say I have a file sometext.txt . I want the contents of this txt file to show up in the notification which I will trigger using displaynotification in applescript. In other words I want to be able to: display notification "File's content" with title "Title". How can I do it?...

In outlook 2011, how can I get an occurrence event out of a series using applescript?

outlook,applescript
In outlook 2011 I try to use the following code to get a single occurrence out of a series of events, but it shows the error ""Microsoft Outlook got an error: The specified object is a property, not an element." number -10008". What went wrong? tell application "Microsoft Outlook" activate...

Unable to unwrap NSAppleEventDescriptor in SWIFT

objective-c,osx,swift,applescript,nsappleeventdescriptor
I'm having an Applescript which gives me a result. But I am unable to unwarp the value to String so i can use it. var set: String = "set windowTile to \"\"\n" var tell: String = "tell application \"System Events\"\n" var setFrontApp: String = "set frontApp to first application process...

How do I escape spaces in a path with Applescript?

path,escaping,applescript,filenames,space
I've written a script so I can quickly get a link to files and folders on my server. The problem is that the string I get does not escape spaces. Can someone tell me how to escape the spaces for '%20' ? tell application "Finder" set sel to (the POSIX...

Check if ssh is being run on another administrator user and kill it. (AppleScript)

ssh,applescript,kill-process,multiple-users
I would like to check if the process 'sshd' is running on the user 'ladmin' and kill it from my user 'patrick' if it is. I am an administrator also. Here is my code: tell application "System Events" set ProcessList to name of every process if "sshd" is in ProcessList...

Make Username and Password input box with AppleScript

passwords,applescript,apple,username,inputbox
I would like to make a dialog input box that looks exactly like this in AppleScript: Except without the picture in the top left of the lock. Also, I need to be able to save both inputs. I know I can use tell application "System Events" to display dialog "blah...

Accessing property values in applescript

applescript
I have some AppleScript code; tell application "OmniGraffle" activate tell canvas of front window repeat with obj in graphics set ObjName to id of obj display dialog "This is the dialog " & ObjName end repeat end tell end tell This returns the ID of each of my graphics, but...

AppleScript throwing errors on curly braces in string

shell,applescript,curly-braces
I'm trying to generate a shell script in AppleScript. When using the following pattern: set tDur to "PT1H21M7S" set tSh to "echo '" & tDur & "' | egrep -o '[0-9]+M' | sed s/M// | sed -e :a -e s/^.\{1,1\}$/0&/;ta" ...I get the error: Expected “"” but found unknown token....

applescript how to remove “\”s from my text in a variable

applescript
Okay so I have a code that grabs text from Wolfram alpha after I ask a question and create the URL and stores it in the variable "answer" but it has / symbols mixed in with the text and the system pronounces words wrong because of it. How can I...

How can I check for existence of Itunes track in Applescript without throwing error

applescript,itunes
the idea of this script (simplified to show the issue) is checks if a track exists, tell application "iTunes" set matchtrack to get first track in playlist 1 whose persistent ID is "F1A68AD90AA66648" if matchtrack is not {} then print name of matchtrack else print "no track found" end if...

How to click a button that's only visible when hovered over?

osx,applescript
I'm tinkering with an applescript that would clear notifications from Notification Center. At this point cannot figure out a way to click the clear button. You see, the button only appears if cursor is hovering on the row of the app, or rows below that belongs to this app. I...

Applescript, Chrome: Make new tab at specified index

applescript
I have this simple Applescript, which reopens active tab in new tab tell application "Google Chrome" tell first window set theUrl to URL of active tab set myTab to make new tab at end of tabs set URL of myTab to theUrl end tell end tell So I can open...

How to use a command line argument of apple script in do script?

applescript
In terminal.app I am executing the command. osascript filename.scpt 'argument1' 'argument2' The filename.scpt script will set it's variable named scriptName from the second argument it receives when run from the CL. set scriptName to item 2 of argv The filename.scpt will then use the variable scriptName in a do script...

Automator Apple Script to convert jpeg image

applescript,apple,automator
I used below automator function to convert png image to jpeg in bulk. It worked fine and converted all images in folder at once. But quality of jpeg image is not full. Image 1: Automator Functions Image 2: Preview App shows quality of image. How can we do same in...

Trouble formatting a string with multiple quotation marks

xcode,swift,terminal,applescript,osascript
I am making a NSTask which runs osascript to gracefully quit an application instead of a killall/kill command. I have this: let killtask = NSTask() killtask.launchPath = "/usr/bin/killall" killtask.launchPath = "/usr/bin/osascript" killtask.arguments = ["-e","'quit app", ""Transmission"""'"] killtask.launch() The troublesome line is the arguments I'm trying to pass. The command in...

Applescript confirm sudo password in ssh connection

applescript
I´m opening a ssh connection to an Ubuntu Box with applescript. How can I provide the sudoer password asked by apt: tell application "Terminal" set currentTab to do script ("ssh -p" & pnumber & " " & user & "@localhost;") delay 2 do script ("sudo apt-get update") in currentTab --...

Multiple if conditions within nested repeat while in applescript

applescript
I've never used AppleScript before, so i'm quite unfamiliar with the language, but i'm doing my best. Here's what i'm trying to accomplish: Run a script while selecting a folder filled with .ARW and .JPG files. Iterate through the items in the folder. If the current item is .ARW, iterate...

Get return values from Applescript in Swift

osx,swift,applescript
Is it possible to run a Applescript in Swift and receive the return values? I have a script like the following. How can I run this in swift and receive the return value? global frontApp set windowTitle to " tell application "System Events" set frontApp to first application process whose...

Check if app is running via bash in shell script

bash,applescript,osascript
My "if" statement which is responsible for checking if app is running doesn't work. It's always returns "false" Here is a script.sh: #!/bin/bash osascript -e "do shell script \" if (ps aux | grep "[[S]kype]" > /dev/null) then echo "RUNNING" > /Users/someuser/Desktop/RUNNING.txt else echo "STOPPED" > /Users/someuser/Desktop/STOPPED.txt fi \" with...

Passing Multiple Parameters from Applescript to Terminal Command Script

osx,bash,parameters,terminal,applescript
I have been trying to figure out how to pass multiple parameters from an Applescript to a Terminal Command Script. For example when running a terminal command file you are able to receive parameters programatically like so: #!/bin/bash var=$1 var=$2 The Applescript Code that I have been working with is...

Applescript Syntax (Multiple Args) Inside Objective-C File

objective-c,scripting,format,applescript,applescript-objc
I have been working on trying to run an Applescript from within Objective-C that queries out to the terminal to run some shell commands. I am running into an issue with how to format the command within Objective-C, so that the script object gets referenced properly. This is what the...

Variables with On/End Statements in AppleScript

variables,applescript,osx-mavericks
I'm experimenting with on and end statements in AppleScript. Consider the following script. set mytext to "Hello, World" on greeting(mytext) display dialog mytext default answer "" set othertext to text returned of result end greeting greeting(mytext) say othertext I want to carry over the variable mytext into greeting and I...

OS X Script Editor - Open 3 images in 1 Photoshop file

image,osx,applescript,photoshop
Working in Script Editor, I have been trying to make an script that opens three selected JPEG files into a single Photoshop document. I'm trying to arrange them one by one in a line. The code I wrote opens them, but in separate documents. This one is AppleScript, any other...

Expected end of line but found end of script

applescript,apple
This is my script and I don't know why it is saying "expected end of line but found end of script." set thanks to 1 set I_HATE_YOU to 2 set um to 3 set good to 1 set bad to 2 set dont_care to 3 display dialog "hi what is...

AppleSctipt Finding File with partial filename

get,applescript,filenames
I am an applescript noob and i need help getting a certain log file that has a long string of numbers in its title. The number changes and the filename before the number string is unique to the folder it is in. Is there some way i can use the...

Pass Multiple Applescript Variables to Ruby

ruby,variables,applescript
I'm working on a Ruby script that requires some variables from Applescript. Right now I'm having success grabbing them one at a time, but it seems inelegant and possibly slow. For example: note = %x{ osascript <<APPLESCRIPT tell application "Evernote" if selection is not {} then set the_selection to selection...

InDesign Applescript Resizing Placed Images

resize,applescript,indesign
Please explain how to make applescript understand I want to select all images on the active page (which in my case are going to be one), to resize the image and fit frame to content. tell application "Adobe InDesign CS6" set myPagecount to count pages of active document repeat with...

Getting absolute Path of Directory in Application

osx,swift,applescript
I have built an application where i am using a script. Now i would like to add these script to my package. How do i add the script? What would be my absolute Paths to call this Script from my application? ...

Search a custom property

applescript
I am using AppleScript to search through a bunch of my contacts, with a specific (custom) property. Here is my code: tell application "Address Book" set allPeople to every person whose last name = "CERTAIN_LAST_NAME" get properties of item 1 of allPeople end tell The specific last name is just...

AppleScript throws an error when creating a folder

applescript
Okay, maybe I AM stupid, but why it's happening? Here's my code set openedFile to (choose file with prompt "Select a file to read:" of type {"PNG"}) tell application "Finder" set parentFolder to POSIX path of (parent of openedFile as text) set icFolder to make new folder at parentFolder with...

How to get POSIX path of the current script's folder in JavaScript for Automation?

osx,applescript,osx-yosemite,osascript,javascript-automation
In AppleScript it’s possible to get the the POSIX path of the folder the current script is located in using this line: POSIX path of ((path to me as text) & "::") Example result: /Users/aaron/Git/test/ What’s the JavaScript equivalent?...

how do you find the square root of a number in applescript

applescript,calculator,square-root
I have a simple calculator code and I want to include square root in it. I am relatively new to applescript and I have no idea how. It might be nooby but thanks anyway!

AppleScript : keystroke : too slow

applescript,keystroke
The keystroke on my script take around 5/7 seconds until going to the next step. I didn't set any delay. E.g : -- Click 1 click pop up button 1 of group 2 of group 2 of group 1 of group 2 of group 6 of group 2 of group...

Applescript Error -1700, cant make ~/Desktop/ into an alias

osx,applescript
set source to (choose folder default location ("~/Desktop/") with multiple selections allowed) repeat with filetocopy in source set n to (quoted form of (POSIX path of filetocopy)) & " " set dir to do shell script "dirname " & n set bn to do shell script "basename " & n...

In Applescript, finding only bold words in TextEdit causes app to hang

ms-word,applescript,textedit
just trying to find a vanilla applescript way of setting a variable to all bold words of a document. I've looked for ways using Applescript in Word, Pages & TextEdit and TextEdit seems to be the only one (could be wrong, though). The good news is that the following script...

use statement not working in AppleScript

applescript,use
I am creating my first AppleScript library in a script file, and would like to use the handlers in that file using the use statement (I followed these instructions). So I tried: use script "My Library" create_new_track(10, 2, 2) Inside my "My Library.scpt" file, there is a handler called "create_new_track"....

Activate the frontmost Safari and run Javascript

osx,process,applescript
I'm trying to run Javascript on the Safari, whose frontmost is true. tell (application "Safari" whose frontmost is true) to do JavaScript theScript in current tab of first window But I get an error like this: execution error: Can’t get application "System Events" whose frontmost of it = true. Access...

Apple script Global variable not working when executing the service using a keyboard shortcut

applescript,automator
I have created a service in Automator to open a terminal using a different color schema everytime. global terminalpos on run {input, parameters} try get terminalpos on error set terminalpos to 0 end try set colorsList to {"Pro", "Basic", "Grass", "Homebrew", "Man Page", "Novel", "Ocean", "Red Sands", "Silver Aerogel", "Solid...

Loop stalling when deleting files

applescript
The script below is supposed to delete all files ending in .aux, etc. in the current directory (i.e. directory displayed in the finder window) The script seems to stall on deleting .aux files. Any hint is welcome. try tell application "Finder" set lieu to target of window 1 set finale...

Apple Script that copies/pastes text is broken in Yosemite

osx,applescript,automator,yosemite
I made a simple AppleScript that copies the layer names from Photoshop and pastes them into Illustrator. It worked fine in Mountain Lion but now it doesn't work properly in Yosemite. It repeats 6 times, but it doesn't seem to activate Illustrator on the first run through. It does activate...

Applescript Automator default text field value

xcode,applescript,automator
i'm trying to make an automator action to rename files to my specific needs. that's 3 text field, one for the date in YYYYMMDD format, one of the project I'm working on and one for the filename itself. so i've figured everything out so far except this specific question/task. is...

How do you make a repeat command on applescript activated by a button?

applescript
I have a applescript code to make a choose your own adventure game. I want to make a command to repeat the entire code when a button is clicked. This is all the code I have: set volume 3 beep set volume 5 delay 0.5 beep set volume 7 delay...

AppleScript check for string value in input

applescript
new to applescript and this small check is driving me nuts. I want to check if the input to the script has the substring of "mob". If i create a varible with mob1234, It works and returns true. on run {input, parameters} set testString to "mob1234" display dialog {"MOB" is...

applescript help naming .plist and removing extention

applescript,osx-yosemite,info.plist
i am creating an applescript to create a file with property list elements but without the .plist extension! my issue is if i use a dialog to get the name of the file eg. tell application "SystemUIServer" display dialog "Enter filename :- " buttons {"Generate file"} default answer "Generate Keyfile"...

mdfind with single quotes

osx,bash,applescript,spotlight
I'm writing an applescript that will find a file for me based on the filename including extension. The script uses mdfind in the bash shell. I've had luck with this construction: mdfind name:'"filename.avi"' But it breaks down when my filename has a single quote (apostrophe) in it like so: mdfind...

Try statements acting up in AppleScript

applescript
I'm trying to figure out try statements in AppleScript. I got it to compile, but it doesn't do what I want it to do. try do shell script "cat " & passData on error display dialog "Create a password to protect this file. After creating the password, you will need...

Apple Script : Cleaning textedit text

text,applescript,textedit
I want to clear some text from a textedit text but its only half working for me tell application "TextEdit" set documentText to text of document 1 set {oldTID, my text item delimiters} to {my text item delimiters, "Administration"} set textBits to text items of documentText set my text item...

Hard link breaks after changing original (AppleScript .scpt) file

applescript,inode
I have an AppleScript Library file (.scpt) saved in ~/Library/Script Libraries which I use to call handlers from, in other scripts. I want also want to keep that file as part of a git repository. So my idea was: create a hard link in ~/Library/Script Libraries to the file in...

How do I get a value from a url and use as a variable in an apple script?

php,bash,applescript
I found how to pause and resume SABnzbd using the API http://localhost:8080/sabnzbd/api?mode=pause but how do I get the true or false value from here http://www.flatmat.net/intr-over.php (this is a PHP script that I wrote) to use in an applescript(or bash script) to pause SABnzb if true or resume if false?

Make AppleScript Case-Sensitive

applescript,case-sensitive
In the following script, set theText to "ASDF" set lowercase to "abcdefghijklmnopqrstuvwxyz" set numeric to "0123456789" set containsLowercase to false set containsUppercase to false set containsNumber to false set containsSomethingElse to false repeat with theCharacter in theText if lowercase contains theCharacter then set containsLowercase to true else if uppercase contains...

Trouble using Applescript in ApplescriptObjc Xcode project

xcode,applescript,applescript-objc
I'm very new to Applescript-ObjC and am trying to do something pretty simple. I have this applescript app that I've been using to convert text to Title Case and ALL CAPS. The app works great. But when I try to bring it into the Xcode AppDelegate.applescript and attach it to...

Applescript: Textedit Password

osx,passwords,applescript,textedit
I'm new to Applescript. I am stumped on this problem of how to read and write a text file and use the contents as a variable. I have done research on this, but nothing works or makes sense. I want to read a text file, which would contain a word...

AppleScript “on open” misbehavior

applescript
I have a list of jpeg images on a local server that I use an AppleScript droplet to resize in Photoshop. I use "on open" to do this, but something strange happens: they open in two parts. The files are named as follows: 0_203.jpg 1_203.jpg 2_203.jpg 3_203.jpg 4_203.jpg 5_203.jpg 6_203.jpg...

reseting Finder from objective c/swift in sandbox

objective-c,osx,cocoa,swift,applescript
I'm trying to rest Finder from my code (in sandbox). One of the approaches that I tried is calling following apple script: tell application \"Finder\" to quit but it doesn't seem to work on the Mavericks. Any ideas?...

AppleScript: execution error -10810 when launching certain applications from shebang'ed scripts

applescript
I'm running OS X 10.10.2. I'm facing a weird issue where AppleScript won't launch applications from shebang'ed scripts while working fine everywhere else (Script Editor, piping to osascript, etc.). Specifically, consider the following example script named launch-app: #!/usr/bin/osascript launch application "TextEdit" When TextEdit is not running and I do ./launch-app...

Moving a file into a folder with Applescript

applescript
I'm fairly new to learning applescript, and I'm trying to set up something for my school's announcement system in order to make it more automated. This is supposed to take the current date, check if a folder for the month exists, and if it doesn't- create one. Then it should...

Click “See All” Link in iTunes with AppleScript

applescript,automator
I am trying to use AppleScript to navigate iTunes. This is working thus far, but I am having trouble clicking the "See All" link/text (image below). You may note that there are two "See All" links, one for iPhone and one for iPad. I am trying to click the one...

Enabling Yosemite's Dark mode through Terminal or Applescript OSX 10.1

osx,shell,applescript,settings,osx-yosemite
Is there any way to turn on Yosemite's Dark Mode through Shell Script (Terminal) or Applescript? I have tried: sudo defaults write /Library/Preferences/.GlobalPreferences AppleInterfaceTheme Dark but it does not work. Please help!...