New to apple script...
Hi I am new to apple script; I was using Automator but it became too dumb to it's surroundings after a while. Can you please tell me why these don't do what I think they should; Safari has 2 windows open one with four tabs (window 1 as I have used exists to be sure of) and one with 9 (window 2).
tell application "Safari"
activate tab 6 of window 2
end tell
all it does is bring the frontmost safari window up
Please help
There are a couple of reasons behind this, mostly because you're using the wrong command.
The main thing is that the 'activate' command is used to activate the application. Any other parameters (such as 'tab 6 of window 2') are discarded.
Instead, the appropriate syntax is to set the current tab property of the window:
tell application "Safari"
set current tab of window 2 to (tab 6 of window 2)
end tell
It's a little verbose, but it works.
If you also want to bring that window frontmost you need to change its index:
tell application "Safari"
tell window 2
set current tab to (tab 6 of window 2)
set index to 1
end tell
end tell
Note though that changing the window index will now also change this window to 'window 1' instead of 'window 2'. Something to bear in mind if you're taking further actions.
Similar Messages
-
Hi Friends,
I am new to Indesign Scripting by Apple Script. As a beginner, I am trying to do some basic scripting in Indesign by Apple Script.
My aim is to disable the option of "Overprint [Black] Swatch at 100%" in Indesign. This option is available when we go to Indesign ---> Preferences----> Appearance of Black.
Also, if a user opens a file, in which the swatch is already enabled, then it should prompt him for disabling.
I can make a display dialog in AppleScript. But, I am bit unsure as how can I go ahead and disable this option. I tried this below script:
tell application "Adobe InDesign CS4"
tell every layout window to set overprint preview to false
end tell
However, it is changing the view option to overprint preview.
Appreciate your help and suggestions!
Thanks,
Abhishektell application "Adobe InDesign CS5"
tell the active document
set overprint black of document preferences to false
end tell
end tell -
Install and uninstall of dmg file using Apple script in Mac 10.6 and higher version.
Hi ,
Could anyone please help me to write a Apple script to Install dmg file and do clean uninstall in Mac 10.6.8 and higher version.
My requirement is:
When i run script : it has to install the dmg file which is located inside one desktop folder say 'New Folder'
I need to do clean unistall when i run the script: i need to delete the folder in ~/Library- locate folder say 'CPSPCSHOWSERVER'' move to trash and from Terminal type in command "rm -r ~/.CPS' to completely delte this folder.
Really appreciated all ur help!!
Thanks,
KT.http://macfidelity.de/2008/08/30/how-to-mount-a-dmg-from-terminal-in-mac-os-x/in dex.html
http://osxdaily.com/2011/12/17/mount-a-dmg-from-the-command-line-in-mac-os-x/
http://hints.macworld.com/article.php?story=20030614230204397
http://www.commandlinefu.com/commands/view/2031/install-an-mpkg-from-the-command -line-on-osx -
I use Adobe Photoshop CS4_Bridge _Photo Downloader to import images from CF Cards into my 11" Mac Book Air. I have an issue with the Text files
that seem to accompany each and every image that I do not need. How do I stop Apple Script (which I assume is the culprit in this case) from interferring with this process.Your iWeb Site is stored not on your iDisk, but on a file named Domain.sites in your ~/Home/Library/Application Support/iWeb/ Folder.
If , for whatever reason, you wipe your HD and/or lose this file (Get a new computer, Re-Install your OS, Stolen Laptop, Crashed HD, Etc.) without backing-up your Domain.sites file then you will have to re-build your iWeb sites from scratch again.
Of course you can edit your Published HTML files in a different program such as Dreamweaver or even Text Edit. You just can't edit Published HTML files in iWeb. Not at this time at least.
Use iWebBackup to backup your Domain file to a Blank CD or DVD. Backing up your Domain file to another folder on your computer is not fully backing it up. If your computer gets stolen you still lost the file but if you have your Domain file burned onto a CD you have a backup!
Download iWebBackup Here
You can use iWebExtender to automatically consolidate your files into one folder and delete multiple images.
http://iWebFAQ.com -
Apple Script to Sort through the Address Book
Dear All,
I am quite new to Apple and just a learner on Apple-scripts. Its been quite a task to learn.. I would require some help on a few things..
The script will eventually use numbers to send email and get the user inputs and any yet to reach there..
After going through lots of scripts to sort through the address book and make a clean address book, i found they are quite slow in processing takes about 20~30 Minutes to get through 2000 Contacts..
Hence after reading posting of Mr. Koenig & Mr. Hiroto and specifically on deep copy. I have written the following code which does the following on 2000 records within 6~8Mins.
The Script work its way through all the contact is the address List.. and creates Groups
1. Duplicate Email Id's — List of Contacts with same email ID's including Contacts where the email Id is entered twice.. (Strange.. Address Book Issue, copy of the email Id under work & home)
2. Duplicate Phone — List of Contacts with same Phone Numbers including Contacts where the Phone Nos is entered twice.
3. Duplicate Name — List of Contacts with Same Names
4. Duplicate No Name — List of Contacts without the First Name and Last Name
it also sort the Contacts under the following Group which you can edit later with all the information's..
1. Only Email Ids — List of Contacts with Email ID and No Phone Numbers
2. Only Phone — List of Contacts with Phone Numbers and No Email Id's
3. No Email or Phone — List of Contacts with No Email Id's and No Phone numbers (some half completed contacts )
My Question to the forum is why is the following code still taking too much time..
set onlyDupEList to every person of group theGroupEmail
repeat with j from 1 to count of Dup_email
set tempdata to item j of Dup_email
if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
end repeat
save application "Address Book"
and the scripts slows down when the items in the list is quite large (over 800 or so )..
Any help is appreciated and thanks in advance..
-- the code ---
global MsgTitle
on run
set MsgTitle to "Search for Duplicates in Address Book Contacts"
display dialog ¬
"This Script takes a while to finish" & return & "maybe 10 min or More..." & return & "Depending on the Address Book Contacts." & return & return & "Hence Allow it to run for the while" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
set question to display dialog "Select the Duplicate Search Parameter " with icon 1 with title MsgTitle ¬
buttons {"Contact Name", "Contacts on Phone & Email Id's", "Quit"} default button 3
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
if rtnValue is "Contact Name" then
-- tell application "Address Book" to quit
GetDup_byName("Duplicate Name")
end if
if rtnValue is "Contacts on Phone & Email Id's" then --Contacts on Phone & Email Id's
-- tell application "Address Book" to quit
Get_dup()
end if
end run
--- Search on Name Field ---
on GetDup_byName(theGroupName)
set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
buttons {"Continue", "Quit"} default button 1
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
tell application "Address Book"
activate
set biglist to {}
set NoNameList to {}
set theGroupNoName to "Duplicates No Names"
set theGroup to theGroupName
-- if not (exists (group "Dupilicate Entries")) then
if not (exists (group theGroup)) then
make new group with properties {name:theGroup}
save
end if
if not (exists (group theGroupNoName)) then
make new group with properties {name:theGroupNoName}
save
end if
set the_names to name of people
repeat with i from 1 to number of items in the_names
set theName to item i of the_names
-- return theName
if theName is not in biglist then
copy theName to end of biglist
else
set counter to (people whose name is theName)
if (count of counter) > 1 then
repeat with i from 1 to number of items in counter
set this_item to item i of counter
-- display dialog this_item
add this_item to group theGroup
end repeat
-- return counter as string
end if
end if
-- captures the Contacts without Name ---
if theName contains "@" then
-- display dialog theName
set counterList to (people whose name is theName)
repeat with i from 1 to number of items in counterList
set this_item to item i of counterList
-- display dialog this_item
add this_item to group theGroupNoName
end repeat
end if
-- save application "Address Book"
end repeat
save application "Address Book"
set peopleCount to (count every person)
-- set peopleCount to 50 -- only for testing --
repeat with i from 1 to peopleCount
set first_name to first name of person i as string
set Last_Name to last name of person i as string
if first_name is equal to "missing value" and Last_Name is equal to "missing value" then
-- display dialog first_name & " : " & Last_Name
set end of NoNameList to (id of person i)
end if
end repeat
repeat with j from 1 to the count of NoNameList
set tempdata to item j of NoNameList
-- set testdata to person id tempdata
-- if (name of groups of testdata does not contain theGroupNoEmail) then
add tempdata to group theGroupNoName
-- end if
end repeat
save application "Address Book"*)
display dialog ¬
"This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
end tell
end GetDup_byName
on Get_dup()
set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
buttons {"Continue", "Quit"} default button 1
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
tell application "Address Book"
activate
set theGroupEmail to "Duplicate Email Id's"
set theGroupPhone to "Duplicate Phone"
set theGroupNoEmail to "Only Phone Numbers"
set thegroupNoPhone to "Only Email Id's"
set theGroupNoData to "No Email or Phone"
-- set theGroup to theGroupName
if not (exists (group theGroupEmail)) then
make new group with properties {name:theGroupEmail}
save "Address Book"
end if
if not (exists (group theGroupPhone)) then
make new group with properties {name:theGroupPhone}
save "Address Book"
end if
if not (exists (group theGroupNoEmail)) then
make new group with properties {name:theGroupNoEmail}
save "Address Book"
end if
if not (exists (group thegroupNoPhone)) then
make new group with properties {name:thegroupNoPhone}
save "Address Book"
end if
if not (exists (group theGroupNoData)) then
make new group with properties {name:theGroupNoData}
save "Address Book"
end if
set ListofPeople to people --the_ID
set ListofEmailID to value of emails of people --the_emails
-- return ListofEmailID
set ListofPhones to value of phone of people -- the_phones
-- return ListofPhones
set biglist to {}
set ListEmail_Uniq to {}
set ListEmail_Dup to {}
set No_PhoneList to {}
set No_EmailList to {}
set No_dataList to {}
set FlagEmail to false
set FlagPhone to false
-- repeat with i from 1 to number of items in the_emails
repeat with i from 1 to count of ListofEmailID
set thePersonID to item i of ListofPeople
set theEmails to item i of ListofEmailID
if theEmails is equal to {} then
set end of No_EmailList to thePersonID
else
-- set FlagEmail to true
repeat with j from 1 to count of theEmails
set tmpdata to item j of theEmails
-- return tmpdata
if tmpdata is not in biglist then
set end of biglist to tmpdata
set end of ListEmail_Uniq to {tmpdata} & {thePersonID}
else
set end of ListEmail_Dup to {tmpdata} & {thePersonID}
end if
end repeat
end if
end repeat
-- return ListEmail_Uniq
-- return ListEmail_Dup
-- save application "Address Book"
set biglist to {}
set ListPhone_Uniq to {}
set ListPhone_Dup to {}
-- repeat with i from 1 to number of items in the_emails
repeat with i from 1 to count of ListofPhones
set thePersonID to item i of ListofPeople
set thePhones to item i of ListofPhones
if thePhones is equal to {} then
set end of No_PhoneList to thePersonID
else
-- set FlagPhone to true
repeat with j from 1 to count of thePhones
set tmpdata to item j of thePhones
-- return tmpdata
if tmpdata is not in biglist then
set end of biglist to tmpdata
set end of ListPhone_Uniq to {tmpdata} & {thePersonID}
else
set end of ListPhone_Dup to {tmpdata} & {thePersonID}
end if
end repeat
end if
end repeat
-- return ListPhone_Uniq
-- return ListPhone_Dup
set the Dup_email to {}
-- Find the Duplicates from the sorted list --
repeat with i from 1 to the count of ListEmail_Dup
set tempdata to item i of ListEmail_Dup
set dataEmailDup to item 1 of tempdata
set dataPersonDup to item 2 of tempdata
repeat with j from 1 to the count of ListEmail_Uniq
set tempdata to item j of ListEmail_Uniq
set dataEmailUniq to item 1 of tempdata
set dataPersonUniq to item 2 of tempdata
-- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
if dataEmailDup is equal to dataEmailUniq then
set end of Dup_email to dataPersonDup -- & "," & dataPersonUniq
set end of Dup_email to dataPersonUniq
end if
(* -- the code takes lot more time if add to group was used --
if dataEmailDup is equal to dataEmailUniq then
set testdata to person id dataPersonDup
add testdata to group theGroup
set testdata to person id dataPersonUniq
add testdata to group theGroup
end if
end repeat
end repeat
-- return Dup_email
set the Dup_Phone to {}
-- Find the Duplicates from the sorted list --
repeat with i from 1 to the count of ListPhone_Dup
set tempdata to item i of ListPhone_Dup
set dataPhoneDup to item 1 of tempdata
set dataPersonDup to item 2 of tempdata
repeat with j from 1 to the count of ListPhone_Uniq
set tempdata to item j of ListPhone_Uniq
set dataPhoneUniq to item 1 of tempdata
set dataPersonUniq to item 2 of tempdata
-- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
if dataPhoneDup is equal to dataPhoneUniq then
set end of Dup_Phone to dataPersonDup -- & "," & dataPersonUniq
set end of Dup_Phone to dataPersonUniq
end if
(*if dataPhoneDup is equal to dataPhoneUniq then
set testdata to person id dataPersonDup
add testdata to group theGroup
set testdata to person id dataPersonUniq
add testdata to group theGroup
-- save
end if*)
end repeat
end repeat
-- return Dup_Phone
set onlyDupEList to every person of group theGroupEmail
repeat with j from 1 to count of Dup_email
set tempdata to item j of Dup_email
if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
end repeat
save application "Address Book"
set onlyDupPList to every person of group theGroupPhone
repeat with j from 1 to count of Dup_Phone
set tempdata to item j of Dup_Phone
if onlyDupPList does not contain {tempdata} then add tempdata to group theGroupPhone
end repeat
save application "Address Book"
set onlyPhoneList to every person of group theGroupNoEmail
repeat with j from 1 to the count of No_EmailList
set tempdata1 to item j of No_EmailList
if No_PhoneList does not contain {tempdata1} then
if onlyPhoneList does not contain {tempdata1} then add tempdata1 to group theGroupNoEmail
end if
(*set flagE to false
repeat with i from 1 to the count of No_PhoneList
set tempdata2 to item i of No_PhoneList
if tempdata1 is equal to tempdata2 then
set flagE to true
exit repeat
end if
end repeat
if flagE is false then add tempdata1 to group theGroupNoEmail*)
end repeat
save application "Address Book"
set onlyEmailList to every person of group thegroupNoPhone
repeat with j from 1 to the count of No_PhoneList
set tempdata1 to item j of No_PhoneList
if No_EmailList does not contain {tempdata1} then
if onlyEmailList does not contain {tempdata1} then add tempdata1 to group thegroupNoPhone
end if
end repeat
save application "Address Book"
set onlyList to every person of group theGroupNoData
repeat with i from 1 to count of ListofPeople
if (item i of ListofEmailID is equal to {}) and (item i of ListofPhones is equal to {}) then
set tempdata to item i of ListofPeople
if onlyList does not contain {tempdata} then add tempdata to group theGroupNoData
end if
end repeat
save application "Address Book"
display dialog ¬
"This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
end tell
end Get_dup
on quit
--set MsgTitle to "Change Email ID's Domain Name"
save application "Address Book"
display dialog "Contact Srikanth Kamath at [email protected] for any Help" with title MsgTitle with icon 1 buttons "OK"
continue quit
end quitHello Srikanth Kamath,
I'm not sure you're still following this thread, but anyway here's sample code I said I'd post later.
--SCRIPT2
main()
on main()
script o
-- input data
property xx : {1, 2, 3, 4, 5} -- list of parents
property yy : {{"g", "h"}, {"a", "b"}, {"b", "e", "f"}, {"e"}, {"c", "d"}} -- list of children per parent
-- work list
property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
property qq : {}
property rr : {}
-- (1) build list of children tagged by parent
repeat with i from 1 to count my xx
set x to my xx's item i
set y to my yy's item i
repeat with p in y
set end of my pp to {p's contents, x}
end repeat
end repeat
--return pp -- {{"g", 1}, {"h", 1}, {"a", 2}, {"b", 2}, {"b", 3}, {"e", 3}, {"f", 3}, {"e", 4}, {"c", 5}, {"d", 5}}
-- (2) sort tagged list by child as key
msort(my by_key1, my pp)
--return pp -- {{"a", 2}, {"b", 2}, {"b", 3}, {"c", 5}, {"d", 5}, {"e", 3}, {"e", 4}, {"f", 3}, {"g", 1}, {"h", 1}}
-- (3) retrieve parents with duplicate child
(* retrieve list of {child, parent} for duplicate child *)
set my qq to uniq(my eq_key1, my pp, {_dup:true})
--return qq -- {{"b", 2}, {"b", 3}, {"e", 3}, {"e", 4}}
(* retrieve list of parent *)
repeat with q in my qq
set r to q's item 2
if r is not in my rr then set end of my rr to r
end repeat
return rr -- {2, 3, 4}
end script
tell o to run
end main
on by_key1(x, y)
msort's comparator for list of lists
key = item 1, ascending
returns true iff x and y are out of order
return x's item 1 > y's item 1
end by_key1
on eq_key1(x, y)
uniq's comparator for list of lists
key = item 1
returns true iff x and y are considered equal
return x's item 1 = y's item 1
end eq_key1
on msort(cmp_, aa) -- v1.2f2
Basic recursive merge sort handler having list sorted in place.
handler cmp_ : comparator
* cmp_(x, y) must return true iff list element x and y are out of order.
list aa : list to be sorted in place
script o
property parent : {} -- limit closure to minimum
property xx : aa -- to be sorted in place
property xxl : count my xx
property yy : {}
property cmp : cmp_
on merge(p, q, r)
property xx: source list
integer p, q, r : absolute indices to specify range to be merged such that
xx's items p thru r is the target range,
xx's items p thru (q-1) is the first sublist,
xx's items q thru r is the second sublist.
(p < q <= r)
local i, j, k, xp, xr, yi, yj, ix, jx
if r - p = 1 then
set xp to my xx's item p
set xr to my xx's item r
if my cmp(xp, xr) then
set my xx's item p to xr
set my xx's item r to xp
end if
return -- exit
else
if p < q - 1 then merge(p, (p + q) div 2, q - 1)
merge(q, (q + r + 1) div 2, r)
end if
At this point, sublits xx[p, q-1] and xx[q, r] have been already sorted (p < q <= r)
if my cmp(my xx's item (q - 1), my xx's item q) then
else -- xx[p, q-1] & xx[q, r] are already sorted
return
end if
set yy to my xx's items p thru r -- working copy for comparison
set ix to q - p
set jx to r - p + 1
set i to 1
set j to q - p + 1
set k to p
set yi to my yy's item i
set yj to my yy's item j
repeat
if my cmp(yi, yj) then
set my xx's item k to yj
set j to j + 1
set k to k + 1
if j > jx then
set my xx's item k to yi
set i to i + 1
set k to k + 1
repeat until k > r
set my xx's item k to my yy's item i
set i to i + 1
set k to k + 1
end repeat
return
end if
set yj to my yy's item j
else
set my xx's item k to yi
set i to i + 1
set k to k + 1
if i > ix then
set my xx's item k to yj
set j to j + 1
set k to k + 1
repeat until k > r
set my xx's item k to my yy's item j
set j to j + 1
set k to k + 1
end repeat
return
end if
set yi to my yy's item i
end if
end repeat
end merge
on cmp(x, y)
(* primary comparator *)
return x > y
end cmp
local d, i, j
if xxl ≤ 1 then return
if cmp_ = {} then set my cmp to cmp -- comparator fallback
my merge(1, (xxl + 1) div 2, xxl)
end script
tell o to run
end msort
on uniq(eq_, aa, {dup:dup}) -- v0.21
handler eq_ : comparator eq_(x, y) that returns true iff x and y are considered equal
list aa : pre-sorted list
(precisely, a list organized such that any duplicate items are adjacent to each other)
boolean _dup : option whether return unique items or duplicate items
return duplicate if true, unique otherwise.
script o
property parent : {} -- limit closure to minimum
property xx : aa
property yy : {}
property eq : eq_
on eq(x, y)
(* primitive comparator *)
x = y
end eq
if eq_ = {} then set my eq to my eq -- comparator fallback
local t, x, _on
if (count my xx) < 2 then return my xx's contents
if _dup then
set _on to false
set t to my xx's item 1
repeat with i from 2 to count my xx
set x to my xx's item i
if eq(x, t) then
set end of my yy to t
set _on to true
else if _on then
set end of my yy to t
set _on to false
end if
set t to x
end repeat
if _on then set end of my yy to x
return my yy's contents -- return duplicate elements
else
set t to my xx's item 1
set end of my yy to t
repeat with i from 2 to count my xx
set x to my xx's item i
if eq(x, t) then
else
set end of my yy to x
set t to x
end if
end repeat
return my yy's contents -- return uinque elements
end if
end script
tell o to run
end uniq
--END OF SCRIPT2
In order to apply it to your current Address Book problem, replace the main() handler with something like the following one.
--SCRIPT2a (part)
on main()
script o
-- input data
property xx : {} -- list of parent; given later
property yy : {} -- list of children per parent; given later
-- work list
property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
property qq : {}
property rr : {}
-- (0) get input data from AB
tell application "Address Book"
tell people
set xx to its id
set yy to its every email's value
end tell
end tell
-- (1) build list of children tagged by parent *)
(* omitted (same as the previous) *)
-- (2) sort tagged list by child as key
(* omitted (same as the previous) *)
-- (3) retrieve parents with duplicate child
(* omitted (same as the previous) *)
-- (4) group the retrieved people in AB
tell application "Address Book"
repeat with r in my rr
add person id r to group "duplicate email"
end repeat
end tell
end script
tell o to run
end main
--END OF SCRIPT2a
Good luck,
Hiroto
Message was edited by: Hiroto -
Help creating apple script to create folder and set access levels
I'm trying to create folders in FileMaker Pro using apple script and need some help in setting the access level for the folders. I want to set both Staff and everyone to Read and Write access. Secondly I would like to have a function key set on the desktop to create new folders and set that same access level. The default access is Read and I can not find a way to change that.
ThanksI'm trying to create folders in FileMaker Pro using apple script and need some help in setting the access level for the folders. I want to set both Staff and everyone to Read and Write access. Secondly I would like to have a function key set on the desktop to create new folders and set that same access level. The default access is Read and I can not find a way to change that.
Thanks -
Please help!! Using Apple Script in Automator for Quicktime
I would like to add some metadata to a batch of quicktime movies and then make the files unable to be altered and re-saved so that I can post them on the web. If I open a movie in quicktime and run the following apple script I can then perform save as of movie A into movie B and movie B cannot be altered.
tell application "QuickTime Player"
set saveable of movie 1 to false
-- save self contained
end tell
I would love to be able to do this on a batch level in automator however I cannot figure out how to pass automator items to the apple script so that their saveable can be set to false, and after this I cannot figure out how to have to movies re-saved so the changes will take effect.
Any help at all would be greatly appreciated.how are you passing files to apple script? as finder items?
the following should work then
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}
tell application "Finder"
repeat with cur_file in input
set fname to (name of (get info for cur_file) as text)
tell application "QuickTime Player"
open file (cur_file as text)
set saveable of document 1 to false
tell application "Finder" to set new_item to (path to desktop as string) & fname
save self contained document 1 in new_item
delay 1
close document 1
end tell
end repeat
end tell
end run
</pre>
the above will dump the modified files onto your desktop and give them the same names they had before. You can adjust that as you like of course. -
Apple Script: Incoming Mail - bigger Text with Rule
Salve!
Have some Problems to create an Apple Script. At first - some Mail Accounts from Incoming Mails in Apple Mail App (Mountain Lion) are very fine with Font Size. Some Mail looks like Font Size 6 in the Inbox. Ok, i can size the Font higher with CMD and + ... but it is manual... i dont like this workaround.
So i create an new Rule in Mail App - Incoming Mail from XYZ and then start this Apple Script XYZ...
But i am an beginer with Apple Script and it will not work. Can you please help me? I will start the Script with Apple Rule. And the Script must formated the new incomming Mail with Font Size 12 (or 14... or... Number is only one Number)...
Can you help me please?Launch Applications > Utilities > Terminal.app and see if the undocumented defaults setting defaults write com.apple.mail MinimumHTMLFontSize 12 (that's mentioned here) works for you. That example sets the minimum font size to 12. You might need to restart mail after the change; I haven't used this setting in a while.
-
Move a mouse with Apple script
Hello,
I need some apple script code to move a mouse to a certain location and then click. If possible could it record the location of the mouse, move it to the pre-assigned coordinates, click, and them move it back to where it was.
I am doing this so I can use multivid and Qlab to play different videos on different iOS devices. Multivid doesn't seem to let me have a cue list with different videos playing simultaneously.
I will have my iMac set up with 2 displays, one with Qlab and the other with multivid in full screen.
Thanks for the helpHere's another code using rubycocoa you might try.
_rb_click({|:position|:{30, 10}, |:click|:1, |:restore|:true, |:prep|:false})
on _rb_click(desc)
record desc : event descriptor record;
full spec = {|:position|:pos, |:click|:k, |:button|:b, |:flags|:m, |:restore|:r, |:prep|:p}
defaults = {|:position|:{}, |:click|:0, |:button|:1, |:flags|:"", |:restore|:false, |:prep|:true}
list pos : {x, y} or {}
number x, y = x, y global coordinate of position
{} denotes current location
integer k : click count (0, 1, 2 or 3}; 0 denotes only to move mouse and exit
integer b : button index (1 = left button, 2 = right button)
string m : modifier flags; e.g. 'ck' = control + command
a = capslock
s = shift
c = control
o = option
k = command
boolean r : true to restore original mouse location, false otherwise
boolean p : true to post preparatory left 1-click event to change UI context, false otherwise
return list : {x, y} = mouse location at exit
considering numeric strings
if (system info)'s system version < "10.9" then
set ruby to "/usr/bin/ruby"
else
set ruby to "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby"
end if
end considering
set defaults to {|:position|:{}, |:click|:0, |:button|:1, |:flags|:"", |:restore|:false, |:prep|:true}
set {|:position|:pos, |:click|:k, |:button|:b, |:flags|:m, |:restore|:r, |:prep|:p} to desc & defaults
if pos = {} then
set {x, y} to {"%", "%"}
else
set {x, y} to pos
end if
if k is not in {0, 1, 2, 3} then error "invalid click count: " & k number 8000
if b is not in {1, 2} then error "invalid button index: " & b number 8000
if m = "" then set m to "%"
do shell script ruby & " <<'EOF' - " & x & " " & y & " " & k & " " & b & " " & m & " " & r & " " & p & "
require 'osx/cocoa'
include OSX
if ARGV[0..1] == ['%', '%']
pt = CGEventGetLocation(CGEventCreate(nil)) # current mouse location
else
pt = CGPoint.new
pt.x, pt.y = ARGV[0..1].map {|a| a.to_f}
end
clk, btn = ARGV[2..3].map {|a| a.to_i}
flg = ARGV[4]
res, prep = ARGV[5..6].map {|a| a == 'true'}
etype, mbtn = case btn
when 1 then [KCGEventLeftMouseDown, KCGMouseButtonLeft] # [1, 0]
when 2 then [KCGEventRightMouseDown, KCGMouseButtonRight] # [3, 1]
when 3 then [KCGEventOtherMouseDown, KCGMouseButtonCenter] # [25, 2]
else raise ArgumentError, %[invalid mouse button: #{btn}]
end
mtable = {
'a' => KCGEventFlagMaskAlphaShift,
's' => KCGEventFlagMaskShift,
'c' => KCGEventFlagMaskControl,
'o' => KCGEventFlagMaskAlternate,
'k' => KCGEventFlagMaskCommand,
mf = flg.split(//).inject(0) { |mf, x| (m = mtable[x]) ? mf | m : mf }
src = CGEventSourceCreate(KCGEventSourceStateHIDSystemState)
tap = KCGHIDEventTap
pt0 = CGEventGetLocation(CGEventCreate(src)) # current mouse location
# move mouse to target location
ev0 = CGEventCreateMouseEvent(src, KCGEventMouseMoved, pt, 0) # move mouse
CGEventPost(tap, ev0)
if clk == 0
puts pt.x, pt.y
exit
end
# post preparatory left mouse click to change UI context (optional)
if prep
ev1 = CGEventCreateMouseEvent(src, KCGEventLeftMouseDown, pt, KCGMouseButtonLeft) # mouse left button down
CGEventPost(tap, ev1)
CGEventSetType(ev1, KCGEventLeftMouseUp) # mouse left button up
CGEventPost(tap, ev1)
end
# post target mouse click(s) with given flags
ev = CGEventCreateMouseEvent(src, etype, pt, mbtn) # mouse button down
CGEventSetFlags(ev, mf) # set flags
CGEventSetIntegerValueField(ev, KCGMouseEventClickState, clk) # set click count
CGEventPost(tap, ev)
CGEventSetType(ev, etype + 1) # mouse button up
CGEventPost(tap, ev)
# restore mouse location (optional)
if res
CGEventSetLocation(ev0, pt0) # restore mouse location
CGEventPost(tap, ev0)
puts pt0.x, pt0.y
exit
end
puts pt.x, pt.y
EOF"
set rr to paragraphs of result
repeat with r in rr
set r's contents to r as number
end repeat
return rr
end _rb_click -
Can Apple Script or Automator handle large client email tasks?
Hi,
I am a relatively new Mac user but currently work on a MacBook and Imac G5 with 10.4.9. I have a client list of approxamitely 900 people and I want to send an email to all 900 announcing a change in product services. Is there an Apple Script or automator script (or somewhere I could go to purchase one) that will allow me to import my name and email list in .csv or excel format and then send a slightly customized email to all. I just want the subject line and greeting to the email to include their first name so it looks as if I have taken the time to send them a personal email.
Can anyone steer me in the right direction. Thanks in advance!Hi,
Here's a script to disable a rule" --> tell application "Mail" to set enabled of rule "weekend message" to false
Change "weekend message" by the exact name of your rule.
Make an (iCal Events or Launch agent PLIST or cron) to run the script on Monday at a specific time. -
Airport and Apple Script - on and off script
I've had this problem for a while, trying to turn the airport card in a computer on and off using and apple script. i need it to automatically turn on or off depending on which account if logging into the computer.
I did find that a solution can be found by writing an apple script to turn airport on and off. but my scripting skills aren't good and haven't worked thus far.
So now i'm asking everyone: Can anyone write a script to turn the airport on or off? I bet you can't. (there's some motivation for you)
I think it's my last resort, turning to other apple user and requesting help, because i have not been able to find another solution or a prewritten script (surprisingly)
Thanks very much for your help!
"i'll gladly pay you tuesday for a an apple script today."
thanksI haven't used these tools so I don't know for sure, but doesn't Tiger's parental controls (in the Accounts preference pane) allow you to enable/disable network access by account? Would that work to solve your problem?
EDIT: OK, by starting a new thread I guess you got the same response that I posted for your previous thread. For those interested, this is a continuation of the thread kevin macky, "Account with and without airport internet access", 08:07am Oct 11, 2005 CDT.
If you are interested in trying to automate this, I suggest that you post your question in these areas:
Mac OS X > Mac OS X Technologies > AppleScript
Mac OS X > Mac OS X v10.4 Tiger > Automator -
Removing BCC with Apple Script when automatically BCC myself is set in pref
I have "Automatically Bcc myself" set in the Mail Composing preferences, which I like because I get a copy of email that I send. I also have an apple script that forwards messages to an email address. When I used this apple script on Tiger, the BCC option was never added (it might have been a bug with Mail in Tiger); however, now on Leopard, the BCC option is always added when I used the apple script.
I've tried setting the BCC field to Null and Blank, but that doesn't seem to work. I suspect that the field is set upon send or the "make new" directive. Does anyone know a way to tell Mail to not Bcc automatically in an Apple Script?
Here is the forward apple script program:
(* Cf. http://www.macosxhints.com/article.php?story=20060219014940761 *)
(* RS 31st July 2006 *)
set theAuthority to "person AT here"
tell application "Mail"
set theMessages to the selection
repeat with thisMessage in theMessages
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set visible to true (* comment out whole line to stop 'blinking' windows *)
set content to thisMessage's source
set subject to "Fwd: " & thisMessage's subject
set bcc to null (* my attempt to set bcc to null or blank *)
make new to recipient with properties {address:theAuthority}
end tell
send newMessage
set read status of thisMessage to true
set was forwarded of thisMessage to true
set junk mail status of thisMessage to true
end repeat
end tellThanks for that reply!
After more google searching, I found this on http://www.macosxhints.com/article.php?story=20040425063255443
One of the responses said that you can add the lines:
delete bcc recipients
delete cc recipients
"in that order" to the new message tell and get rid of the recipients. I had tried the delete before, but I thought I had to get the recipients before I deleted them. I'm not a very good apple script person. Here is my final script
(* Cf. http://www.macosxhints.com/article.php?story=20060219014940761 *)
(* RS 31st July 2006 *)
set theAuthority to "email address here"
(* or your personal Knujon address *)
tell application "Mail"
set theMessages to the selection
repeat with thisMessage in theMessages
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set visible to false (* comment out whole line to stop 'blinking' windows *)
set content to thisMessage's source
set subject to "Fwd: " & thisMessage's subject
make new to recipient with properties {address:theAuthority}
delete bcc recipients
delete cc recipients
end tell
send newMessage
set read status of thisMessage to true
set was forwarded of thisMessage to true
set junk mail status of thisMessage to true
end repeat
end tell -
Apple Script/Program start through link on HTML page
Dear Apple Gurus
Probably I'm asking something silly, but I don't know any other way to solve my problem.
I have to do some training videos about the finder and system tools. To have it easy, I would like to ad some buttons to the project where you can start an apple script which does execute some commands just explained in the video. Untill know I'm intend to do the hole thing inside QT but maybe a HTML page does the job too.
My problem is now, how can I start a AppleScript out of a Movie or HTML page.
Is this possible at all or are there any other solutions to to the job?
Best regards
Thomas ThalerHi Thomas,
Yes, you play movies in a smil presentation.
You can define as many regions as you want. You difine regions in the layout:
<layout>
<root-layout background-color="blue" width="320" height="290"/>
<region id="videoregion" top="0" left="0" width="320" height="240" fit="meet"/>
<region id="textregion" top="240" left="0" width="320" height="30"/>
<region id="linkregion" top="270" left="0" width="320" height="20"/>
</layout>
I got part of this from the internet, but here's a quick explanation. The root-layout part defines the whole area. Within this area you have regions. The first region defines the video region and you can give it any id. The origin of the screen is upper-left. fit="meet" means the the movie will be proportional to fit the whole movie. You can change it to other parameters (read the link from the last post). So here, three regions are defined. The first is for the movie (I used a slideshow from iPhoto), the second is for captions in the middle, and the third region is for the link region at the bottom of the screen. You can use any region as a link. Within these regions you place your movies, text, etc. (see the link for more types).
You next place your types in the body:
<body>
<par>
<!-- VIDEO -->
<video src="slideshow.mov" region="videoregion" id="mov"/>
<!-- CAPTIONS -->
<textstream src="caption.txt" region="textregion" system-language="en" system-captions="on" title="english captions" alt="english captions"/>
(a href="file://localhost/Users/kel/Desktop/linkapp" show="new")
<text src="text.txt" region="linkregion" end="id(mov)(end)"/>
(/a)
</par>
</body>
video src says what type of object, slideshow.mov is the name of my movie. If you place the movie in the same folder as the smil file, you can use just its name like I did. Then you enter what region you want the movie in. The id="mov" part is to give this video a reference for later use. I used it to keep the text in the link area running until the movie ended. You don't need captions if you don't want, but if you do here's an example of my captions.txt file:
{QTtext} {font: Arial} {justify: center} {size: 12} {backcolor:0, 0, 0} {timescale: 30} {width: 320} {height: 60}
[00:00:00.00]
Kelvin: Here is my movie.
[00:00:04.15]
{justify:left} {italic} Here is more text. {plain}
[00:00:07.04]
After 4 15/30 seconds the text changes.
So altogether, I had five files in the same folder: the smil file (slidshow.smil - plain text), the movie (slideshow.mov), the caption text (caption.txt - plain text), and the text file for the link region's text (text.txt - plain text). The script application was on my desktop:
"file://localhost/Users/kel/Desktop/linkapp"
It's easy to get a local file url through applescript:
set f to choose file -- the script app
tell application "Finder"
set the_url to url of f
end tell
and the the local file url is returned in the result.
The movie needs work. I was playing around with the colors. blue is not a good background color.
One thing I forgot to say is that you need to read more about the timing (duration). There are a lot of examples and tutorials on the Internet also. It's not that hard though. One thing you might have trouble with is getting repeats to work. I don't think they do.
gl, -
Help with moving contact info using Apple Script in Address Book
Hi folks,
I wonder if someone can help? I imported a few hundred contacts via a Gmail created vCard into my Address Book. The problem is that instead of inserting the email addresses into one of the email fields for each record, it has inserted the email address into the Notes field as follows: "EmailAddress: [email protected]".
I would like help to write an Apple Script that will search my contacts in Address Book, find those with "EmailAddress:" in the notes field, cut the email address that follows it, and pastes it into the Work Email field, carries out the operation for the whole address book and saves the changes.
Can anyone help me write a script for this. I've not used Apple Script before so this will be my first attempt!
Thanks in advance,
ayworldThis should work:
tell application "Contacts"
activate
set thePeople to every person whose note contains "EmailAddress:"
set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
repeat with thePerson in thePeople
set nn to thePerson's note
make new email at end of emails of thePerson with properties {label:"Notes", value:text item 2 of nn}
end repeat
save
end tell
It will leave the entry in notes and make the label of the new email 'Notes"
Normally when I post an AppleScript like this I tell the user to test it out before using it on the actual data but in this case I don;t know how you'd do that given there is only one Contacts and only one Contacts database.
Just make sure you have a backup just in case. I tried it here on some dummy entries in my Contacts and it worked OK.
Again this totaly relies on the data you presented. The Notes field has to be in the format
EmailAddress:[email protected]
for this to work.
regards
Message was edited by: Frank Caggiano - If you select all the text in the box, then right click and select Make new AppleScript the script will open in the AppleScript editor. Just make sure you get all the text it is easy to drop the first or last char when selecting. -
Hi,
I found this Apple script online and here's how it works:
tell application "QuickTime Player"
activate
try
if not (exists document 1) then display dialog "Please open a QuickTime movie." buttons {"Cancel"} default button 1 with icon 1
set thefile to (choose file name)
save document 1 in thefile
close document 1
end try
end tell
+I run the Apple script+
*1. It prompts me to open a movie file in Quicktime*
+I open a movie in Quicktime+
*2. It prompts me for an name and directory to save the new file in*
+I enter a name and directory+
*3. It saves a new reference movie in said directory with said name*
This is useful if I want to customize every file, but unfortunately, I just want to mass create reference movies for a whole bunch of files.
What I am looking for is for an Apple script that is a drag and drop application, so I can drop say 100 movie files or so, and have the Apple script create reference movie files with the same name and in the same directory automatically with no prompts.
Since I am unfamiliar with Apple script I was wondering if someone would be able to edit my existing script to do what I want.
Thanks so much for your help!Use Automator. It's great for repetitious tasks (like the one you've described), and it's very user-friendly. Open Automator, create a new workflow that executes the action you want, and you can apply that action to the resources you wish to edit.
Good resource here:
http://bit.ly/
Maybe you are looking for
-
No data found from oracle application end
Hi all i have made a custom PO report, initially when publish a report for particular user out put is coming but when i use different login user and run the same report then there will be no data found in that report,(output is blank). kindly help me
-
How do I deactivate a dead computer
how do I deactivate a dead computer. I am using elements 10
-
My Address book doesn't work!
Dear Community, it's my first time I write here and I'm italian, so I don't speak English very well... I'm sorry if in this post there are some error... The problem is simple: My address book doesn't work. If I click on its icon on dock, it "jump" fo
-
I am getting the error "ipad could not be restored. an unknown error occurred (3194)" while trying to restore. tried steps 2 n 3 but stil error persists!
-
Sheet music display integrated with Sequencer http://web.me.com/newdotmacuser/CurtisRushBell/SoftwareInnovations/Entries/2010/7/20_9_Digital_SheetMusic.html