applescript

Finding the Max in AppleScript [duplicate]

人盡茶涼 提交于 2020-01-25 06:42:09
问题 This question already has answers here : How do I find the index of the maximum value in the list using Applescript? (2 answers) Closed 2 months ago . Basically I just need help with finding the max of this code. set numberList to {3, 4, 5, 6, 7, 8, 9, 10} set max to numberList repeat with x in numberList if x > max then set max to x end repeat display dialog max The error that I am getting is: "Can’t make {3, 4, 5, 6, 7, 8, 9, 10} into type number." number -1700 from {3, 4, 5, 6, 7, 8, 9, 10

Applescript to quit Terminal

我是研究僧i 提交于 2020-01-25 00:22:26
问题 Background: I’m a Mac user, who maintains a program in PostScript. Postscript is interpreted (‘distilled’) by Adobe Distiller. So sometimes I want a second or third session of Adobe Distiller. To open such an instance I have a small text file named ‘ DistillerNewInstance.command ’: open -n -a "Acrobat Distiller" osascript -e 'tell application "Terminal" to close first window' osascript -e 'tell application "Terminal" toquit saving no' The Distiller bit works perfectlly. Happiness. But

AppleScript error “Can’t make \”“ into type integer.” number -1700

社会主义新天地 提交于 2020-01-24 23:01:47
问题 I know this error has been covered here but I have been searching through the answers for days now and when I think I have cracked it I end up breaking the code somewhere else. I am trying to run AppleScript in Xcode to make a backup of a folder on a set network machine. The problem I am having is that the backup is date stamped and in a sub folder on the users Desktop. I am trying to avoid using hard POSIX paths to make the final app universal. All the solutions I have found don't take this

Open, split a iTerm2 window and execute commands inside each of those panes

社会主义新天地 提交于 2020-01-24 22:49:20
问题 I'm trying to create a script which would open a iTerm2 window, split it into 3 panes vertically and run a few commands inside each of those panes. Here's my attempt so far: tell application "iTerm2" activate -- Create main window create window with default profile tell current session of current window set name to "frontend" write text "cd ~/Documents/frontendDir" split vertically with default profile end tell tell second session of current window -- ERROR HERE set name to "backend" write

AppleScript: adding mounted folder to Finder Sidebar?

最后都变了- 提交于 2020-01-24 15:51:47
问题 I have a simple Apple Script that mounts a folder: mount volume smb://machineip/folder This runs on start up since Mac OS X 10.5.5 doesn't have the concept of mapped drives like Windows. The script doesn't go as far as I'd like though. I get the machine IP added to Finder Sidebar and when I click it, all of the shared folders for that machine appear, including the above "folder" with the little eject icon. How do I get that folder to appear under "Devices" in Finder Sidebar using Apple Script

Is it possible to automate attaching a script to a folder

戏子无情 提交于 2020-01-24 01:53:46
问题 I have new folders added daily. Is it possible to link an existing folder action script to the new folder automatically? 回答1: They have always been hidden for some reason, but but there are attach action to and remove action from commands in the System Events scripting dictionary. The syntax also changed a bit around the time of Snow Leopard, which didn't help either. A general purpose handler for attaching folder action scripts (tested in Mojave) would be something like: on run -- example

Applescript: Am I able to save a text file using a variable for the filename and file path?

老子叫甜甜 提交于 2020-01-24 00:25:19
问题 I have created a script to find/replace within the document to create an SQL insert statement, but so far I have been unable to create a statement that allows me to save the results using a saved variable (the date) and extension (.sql) to a different folder. tell (current date) to set {_year, _month, _day} to {year, it's month, day} set _day to text -2 thru -1 of ("00" & _day) -- add leading zeros if needed set _month to text -2 thru -1 of ("00" & (_month as integer)) -- add leading zeros if

Why does this AppleScript get an “AppleEvent handler failed” error on Mac OS X 10.5 Leopard?

ⅰ亾dé卋堺 提交于 2020-01-23 17:21:13
问题 First, I know, Leopard is the old-fogey at this point, but it's the minimum I'd like to be able to support with this script, so please bear with me (it's not even possible under Mac OS X 10.4 Tiger due to a bug w/Mail redirect/forward/reply bug I had uncovered long ago). I've been revisiting building an AppleScript to work in conjunction with Topic Desk's spamtrainer, so it goes through a selection of messages in the Junk folder and attempts to redirect them to a specified mailbox. Here's

Why does this AppleScript get an “AppleEvent handler failed” error on Mac OS X 10.5 Leopard?

微笑、不失礼 提交于 2020-01-23 17:21:05
问题 First, I know, Leopard is the old-fogey at this point, but it's the minimum I'd like to be able to support with this script, so please bear with me (it's not even possible under Mac OS X 10.4 Tiger due to a bug w/Mail redirect/forward/reply bug I had uncovered long ago). I've been revisiting building an AppleScript to work in conjunction with Topic Desk's spamtrainer, so it goes through a selection of messages in the Junk folder and attempts to redirect them to a specified mailbox. Here's

Tick a checkbox only if it's not selected

我的未来我决定 提交于 2020-01-21 07:32:50
问题 When UI Scripting in Applescript, you might want to tick a checkbox: tell application "System Events" tell process "Example Process" click checkbox "Example Checkbox" of sheet 1 of window 1 end tell end tell This has a problem. If the example checkbox is already ticked, you actually un-tick the box. How can you "tick the checkbox only if it's not already ticked"? 回答1: The various UI items have properties you can test. For checkboxes, the value property will be 1 or 0 depending on whether it