New answers tagged applescript
0
you could ssh root@apple-tv.local killall AppleTV, also you might want to change your passwd from the default. As for a icon, you could but the above into a file and name it with a .sh extention, which could then be 'clicked on'.
If you don't want to be prompted for a ssh passwd, set up some ssh keys.
Setting up ssh keys
If you already have a key on your ...
0
You can schedule an event once with at:
at 23:59 <<< 'osascript -e "quit app \"Mail\""; pmset sleepnow'
Or to schedule it to repeat every day, edit the crontab with EDITOR=nano crontab -e and add an entry like this:
59 23 * * * osascript -e 'quit app "Mail"'; pmset sleepnow
0
Here's a strictly applescript version that accomplishes this given a hard-coded time value. You could, of course make this part interactive if you want. Also, this version assumes the time-string relates to today.
--Get time setting for action to occur
set t to "3:16:30 PM"
--build a time string to use as a target.
set cd to (current date) as text
set ...
0
If you run this to kick off the keynote then it will quit Keynote as soon ( well within 5 seconds ) as you stop presenting (esc). If you want it to quit after you sit on the final slide for a preset amount of time then just say so.
tell application "Keynote"
if not playing then
start
repeat while playing
delay 5
end ...
0
I've been using Airfoil to do this for years. Only one Mac needs to have the music: it is streamed across the network to the other. You need a reasonably well performing network for this to work well: sometimes my WiFi plays up and the audio can get a little out of sync as a result. For me, it works best when using their software on both Macs (Airfoil on ...
1
You can combine AirPlay in iTunes 11 and up with something like AirSever to accomplish this with good results and very little effort. (Note: For more options on how to turn your Mac in to an AirPlay receiver please see: Can I use a Mac Mini as an Airplay audio receiver?)
Install the AirPlay receiver software of your choice on the machine you want to stream ...
0
According to an answer here, a folder can be excluded from Spotlight indexing (achieving the same effect as adding it to the Privacy tab, although the folder won't actually be listed there) by either
adding .noindex to the end of the folder's name, or
creating an empty file .metadata_never_index inside the folder (eg with touch ...
1
I use an AppleScript that toggles through 3 of the 'scale' options depending on the current option...
local index1, index2, index3
set index1 to 3 -- 1440 x 900 (Best for Retina)
set index2 to 4 -- 1680 x 1050
set index3 to 5 -- 1920 x 1200 (More Space)
-- Launch "System Preferences", open the "Displays" options and change to the "Display" tab
tell ...
2
You could take advantage of the fact that 44 is evenly divisible by 5.5 and use an inner and outer loop:
repeat
keystroke "i"
repeat 8 times
keystroke "o"
delay 5.5
end repeat
end repeat
Note that for the keystroke command to work, you need to be in a tell block for the System Events application.
0
I thought this was a handy bit of code to tidy up and expand on a bit.
on evenRandomNumber(low, high)
repeat
set randomNumber to (random number from low to high)
if randomNumber mod 2 = 0 then exit repeat
end repeat
return randomNumber
end evenRandomNumber
on oddRandomNumber(low, high)
repeat
set randomNumber to ...
0
I'm with the plist aspect of your question, but this script will run and stay open in the background checking the time every four minutes ( customizeable )to see if the day or time necessitates a status change. Does that work in your situation?
Any links to explain your use of plists above would be appreciated.
property idleTImer : 10 --seconds
property ...
1
This should do what you asked for. It will ask you to choose from a list if the user name you enter matches more than one contact and also if the selected contact has more than one email address to choose from.
set recipientList to {}
tell application "Mail"
activate
repeat
set userResponse to display dialog "who would you like to send the ...
1
You could repeat key code commands until the frontmost application changes:
delay 1
activate application "TextEdit"
tell application "System Events"
repeat while (path to frontmost application) is (path to application "TextEdit")
repeat 3 times
key code 123
delay 0.3
end repeat
repeat 3 times
...
1
I just did some tests : AppleScript is not well suited for what you ask since it is Single Threaded. Therefore exiting the loop in such situation does not seem possible.
Here is a code that do what you want but without exiting the loop.
tell application "VisualBoyAdvance" to activate
repeat while true
set mydate to current date
repeat while ...
0
You could use a Create Archive action and rename the resulting archive:
d=${1%/*}
start="$d/${d##*/}"
name="$start.zip"
i=2
while [[ -e $name ]]; do
name="$start $i.zip"
let i++
done
mv "$1" "$name"
open -R "$name"
Or use a run shell shell script action like this:
for n in $(seq $(printf %s "$@" | tr -dc / | wc -c)); do
uniq=$(printf %s\\n "$@" | ...
0
In Automator:
Add Get Selected Finder Items
Add Run Applescript
Inssert this code for the Applescript:
on run {input, parameters}
set pathList to {}
repeat with itemNum from 1 to count of input
tell application "System Events"
copy POSIX path of (container of (item itemNum of input)) to end of pathList
end tell
end repeat
return pathList
end run
...
0
Here are some conceptual answers that would work, and potentially can be expanded to launching any app in any virtual machine space, although insecurely.
Method 1. Drop boxes.
Each VM has a shared directory from the host machine. This directory must be publically writeable.
A script on any machine can write a file to any of these directories.
Each VM ...
0
This is an edited version — quite possibly not the best one — of the script shown in this answer to the Automatically Save Attachments in Mail.app in 10.8 Mountain Lion thread, I've tested it and it works:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
...
1
I would suggest that you visit the Chrome store, get the GMail extension made by GMail, install it. Research how you find and open Chrome extension files on your disk. If I remember correctly the GMail extension has the option to make Chrome + Gmail the default Mac email application. You may learn something by exploring the code of that extension. It may ...
0
I'm not an Applescript expert, but you might consider simplifying the scripts to remove the timing aspects and use the daemon launchd for scheduling. After all, that's why Apple put it into the OS.
Though you're obviously not afraid of the command line and plist editing, Lingon is an application that provides a simple GUI interface to launchd (for the rest ...
1
Unless you're dying to program this yourself, you should probably check out Webmailer. It does pretty much exactly what you're looking for — a handler for mailto links and other system email actions that will redirect them to Gmail, or whatever else you want (it can work with scripts or any URL you want to give it). It's no longer maintained, but I believe ...
0
Here is another option:
set rand1 to randNum(10, 98)
on randNum(low, high)
(random number from low to high)
tell the result to if it mod 2 = 0 then return it
randNum(low, high)
end randNum
0
set rand to (random number from 0 to 99)
if rand mod 2 is not equal to 0 then
set rand to rand - 1
end if
2
You can just multiply by 2:
(random number from 5 to 49) * 2
0
The entries have to be on a single line. If you use /etc/crontab, the sixth field has to be the username:
0 9,17 * * * yourusername osascript ~/Documents/disablemail.scpt
You can edit the user's crontab with crontab -e (or EDITOR=pico crontab -e). The entries can't include username fields:
0 9,17 * * * osascript ~/Documents/disablemail.scpt
0
Cron was replaced by launchd a while back. If you're just getting started with this project, you might want to do it in launchd.
1
It's a problem that i have brought to their attention on multiple occasions. and as of right now, they still haven't even fixed the problem in v9 betas. so, if this is a deal breker for you (as it was for me), keep using parallels v7. it's the last one that they have that applescripting still works properly in.
0
jmlumpkin's answer is spot-on, but you can make it even easier on yourself. As I described in a blog post, you don't need to copy and paste the script into the new workflow you create. You can call the original AppleScript from inside the workflow, instead:
on run {input, parameters}
run script file "Macintosh HD:Some Directory On Disk:a cool ...
2
I don't know how it compares against other options, but you could use pdfotext. It can be installed with brew install xpdf.
do shell script "/usr/local/bin/pdftotext /usr/share/doc/bash/bash.pdf -" without altering line endings
Calibre also comes with some command line utilities:
/Applications/calibre.app/Contents/MacOS/ebook-convert ...
2
Using the Python Objective-C bindings, you could create just a small python script to get it from the built in OS X Dictionary. Here's a post that details this script"
#!/usr/bin/python
import sys
from DictionaryServices import *
def main():
try:
searchword = sys.argv[1].decode('utf-8')
except IndexError:
errmsg = 'You did not ...
2
I was also going to suggest open dict://word, but Google's dictionary API also uses the New Oxford American Dictionary:
#!/usr/bin/env ruby
require "open-uri"
require "json"
require "cgi"
ARGV.each { |word|
response = ...
6
You can use...
open dict://my_word
...which will open the Dictionary application and lookup the string my_word. If you want to use multiple words use something like open dict://"Big Bang Theory".
There's no output in the Terminal though.
1
I don't think it's possible, but FastScripts does seem to use custom icons in the menu:
2
The load script command loads a script as an object to be run, rather than as text to read or manipulate.
If you want to access the actual text of your script, you can use osadecompile:
do shell script "osadecompile ~/Library/Scripts/test.scpt"
word 2 of result
Compiled scripts saved with AppleScript Editor usually have LF line endings in strings but CR ...
0
FastScripts pauses running scripts before keystroke and key code commands if modifier keys have not been released.
One cool trick in 2.6.1 is the way FastScripts behaves when your scripts include “keystroke” commands to synthesize keyboard presses. In the past, these scripts were tricky to get right in FastScripts, because the synthesized keystroke would ...
1
I only tested this with the normal version of the preference pane, and it doesn't probably work if you have a Magic Mouse:
tell application "System Preferences"
reveal pane "com.apple.preference.mouse"
end tell
tell application "System Events" to tell process "System Preferences"
tell radio group 1 of window 1
if value of radio button 1 is 1 ...
1
That is a nice way of starting a random screen saver.
If, however, you'd simply like to start the active screen saver, you can use this in Mountain Lion:
tell application "System Events" to start current screen saver
1
By "main", do you mean the Info.plist file of your .app ?
That's Apple recommandation so far: https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW1
Top 50 recent answers are included

