IWeb Applescript and Automator - scripts you shouldn't be without
Applescript and automator will automate mundane manual repetative task that seem to take forever. These scripts fill in iWeb's void that makes it hard to implement advance features such one click ftp publishing, code editing, swithching domain site files, etc. Don't miss out on these scripts that will save you ton of time. These are scripts you shouldn't be without.
Work smarter not harder with iWeb applescript, only from MacEzzy.
-- Also check out the free downloadable iWeb templates.
Powerbook G4 Ti Mac OS X (10.4.4)
Thank you for your feedback.
-- Article never mentions compressed or uncompressed. Traditionally tiff format is used for buttons and small images on web pages and jpeg is used for higher quality photos exemplified by iWeb.
-- Search engine spiders or crawlers start from top of the page to the bottom of html pages. They craw for topic as well as content. This is exactly what appears from iWeb html pages for meta (meta name="Generator" content="iWeb 1.0.1")
-- I am the first to admit I don't know everything but I don't make up information. I use iWeb on a daily bases and try new things to push the envelope. Things that I find helpful to me I make it available for other iWeb community users so that they don't go through tribulation.
-- I put google ads and paypal donate buttons throughout the pages to test if iWeb is up for commercial challenge. I also tested how well the search and replace script worked. I have exemplified in macezzy website it is possible to use iWeb for business purpose. The script worked extremely well, it would have taken hours to insert google and paypal codes manually. Using the script it only took 10 min. I wanted to share that with other users who might wanted to do similar things. Sorry if that offend you, I will remove them.
-- I never claimed to have created the script except the script that makes the first folder in documents folder. I did change the wording so that it is clear to users that they are switching sites(domain file). I did not create the awesome search and replace script either. I do mention that I have made the iWeb_ftpUpload automator.
I have started macezzy site when iWeb was introduced and there wasn't much information about iWeb. I have and do try many things with iWeb and report to iWeb community users of things that I find helpful. I haven't made a dollar off the site and I have invested lot of my time because I like to see other users succeed.
Powerbook G4 Ti Mac OS X (10.4.4)
Similar Messages
-
I have studyed html for 3 days and wordpress for 3 days , word , excel for 5 days, and llustrator and photoshop 13 yeas ago for 6 months.
and still now its so hard to understand some how.
but I am in need of understading now with the printed documents from my computer.
and I wonder , so there are many defferent way to communicate with anyone out side of the world, right?
like I know email , fax, facetime,
but there are other way now I think because of the documents I found.
and also with applescript and automator can do anything possible like even the child can click one and start conecting etc..
I have the copy from its ,
does anyone have time to explain me what it is?
It's not that of teenager who doesn't want paretns to know or else,
but I am quite serious for my situations.
Please Help !
Mac OS snow leopard to lion to moutain lion,,,,,
but I don't know when it started yet.Using JavaScript to script System Events wouldn't be any better, since it uses the same Apple Events mechanism (how well it uses it is another topic). To hold down a key you would need to use something that has access to the deeper system APIs, most likely using Xcode.
And yes, your code snippet will press the arrow key 5 times (I am guessing that the missing space in key code is a typo). You can place the cursor in a bunch of text in another application such as TextEdit, and use your script to activate it before performing the key codes to get a better idea of what is happening (trying to reposition the cursor in the Script Editor will reveal a bug with the delay command). -
Is there an AppleScript or Automator Script that will wake a Mac from Sleep?
Is there an AppleScript or Automator Script that will wake a Mac from Sleep?
Frank and All,
The following answer to your question above is complicated, but I hope it explains why my question was formed with so much frustration in it.
I have an OpenOffice(OO) Macro that was launched with Calendar at 6pm each business night. It ran properly in all Apples operating systems until I Hit Maverick(OSX10.9). From then on, the AppleScript would run from one to 3 days, then would disappear from the Calendar entry. The Calendar alert would still run, but the "OpenFile" section of the alert would disappear. I also was running elgato EyeTV HD during the day, so I would use energy saver to put my MacBook Pro to sleep at 12 Midnight and wake it again at 9am. I picked up a used Mac Mini to do the EyeTV stuff, provide AppleTV the files in H264 format through iTunes' media share, and found it had plenty of power to do the 6pm automated stuff simultaneously as well. Because I still wanted to run the OpenOffice Macro on my MacBook Pro at 6pm, and wanted to use it for a host of other things when I was on the road, I wanted it to sleep most of the time and only wake up automatically to run the 6pm OO Macro. When I called Apple about the issue I was having with Maverick and Calendar loosing the OpenFile command as part of the Alert Message, they told me the no longer supported answering AppleScript Questions but they now would support Automator questions. I pointed out that the OpenFile would also fail after one to three days if I used a Calendar Alert to launch an Automator App. At first, I did not like Automator, but now I see why Apple is pushing us to use it. Automator adds a TIME STAMP ID to the Apps developed in Automator so the first time you launch the App after a change to it, you must reply to a dialog message saying that this is the first time you are running this version of the App. If a Scammer has replaced your app with one that can reek havoc on your computer, the replacement app will not run unless you are there to agree that you know where the modified app came from and click the OK button to continue (BRILLIANT, Enhanced Security idea on Apples part). I also noticed that after Mountain Lion, the Applescript delay timing was all screwed up as well. Well I tried to use LaunchD Task Scheduler to circumvent the Calendar Problem and that worked until I upgraded to Yosemite Last week. Then LaunchD no longer worked and I am only into a few days of using The Calendar Launched Automator App to see if it will continue to run.
But I think I solved the dilemma I was having with opening an Automator App in a Sleeping Mac. I Googled up the following question, "AppleScript to wake up computer". I went thru several complex responses until I found this on that is INCREDIBLE EASEY! What came back was a brettterpstra.com response from Feb 20th,2014. What it said, in a Quick Tip: caffeinated your Terminal Article, if you wanted to wake a Mac from sleep, use the Terminal command named "Caffeine -u -t 1". I placed it in an Automator Most Used Action called "Run Shell Script -- Caffeine -u -t 1" and it worked! Now, I can put my Mac to Sleep but at 6pm, the Automator App will launch, run the "Caffeine -u- -t 1" command and proceed to work as if I had awakened the Mac From Sleep mode by pressing a keyboard key and had run the Automator Script with a double click.
Sorry for the long, drawn-out reply, but maybe this will help others. -
Using Applescript and Automator to manage files and folders
Hi all.
I need to make a simple action via applescript and-or automator to take the file it's been applied to (via the services) create a folder around it with the same name as the file.
So far, I've searched the web, found some solutions but none are really working.
Here's the script I found :
set myFolder to findFolder()
tell application "Finder" to set myFiles to files of myFolder as alias list
repeat with aFile in myFiles
set bName to my baseName(aFile)
tell application "Finder"
set folderExists to exists folder bName of myFolder
if not folderExists then make new folder at myFolder with properties {name:bName}
move aFile to folder bName of myFolder
end tell
end repeat
---------------- HANDLERS ----------------
on baseName(myFile)
tell application "System Events" to set {fileName, fileExt} to {name, name extension} of myFile
return text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
end baseName
on findFolder()
activate application "SystemUIServer"
-- Bug pointed out by Lauri Ranta http://www.openradar.me/9406282
tell application "Finder"
activate
set mySelection to (get selection)
if mySelection ≠ {} then
set mySelection to first item of (get selection)
if mySelection's class = folder then
set currentFolder to mySelection
else if mySelection's class = document file then
set currentFolder to parent of mySelection
else if mySelection's class = alias file then
set currentFolder to original item of mySelection
end if
else
set currentFolder to target of front Finder window
end if
end tell
return (currentFolder as alias)
end findFolder
And here's a page where they explain how to use automator and the Services to do what I <allmost> want, with some adaptation.
But it still doesn't work.
http://hbase.net/2011/08/17/move-selected-files-into-a-new-folder-using-applescr ipt-and-automator/
So if anybody has an idea n how I could do this ?
It It could either be a folder action (I drag and drop the files into a folder and boom, they get their folder around them)that I would set on a folder on a network drive, or locally, it doesn't matter, or a service (right clic on the file and boom folder around it.
So if anyone could help with this I'd be grateful...Hi,
Make an Automator Service (Service receives selected "Files or Folders" in the "Finder.app").
Use this script in the "Run AppleScript" action:
on run {input, parameters}
tell application "Finder"
repeat with aFile in input
if class of (item aFile) is not folder then
set {tName, fileExt} to {name, name extension} of aFile
if fileExt is not missing value and fileExt is not "" then
set tName to text 1 thru -((count fileExt) + 2) of tName
tell (get container of aFile)
if not (exists folder tName) then make new folder at it with properties {name:tName}
move aFile to folder tName
end tell
end if
end if
end repeat
end tell
end run
This script work on files with a name extension. -
AppleScript or Automator script to Change Mail Subject
The following AppleScrip works great with Microsoft Outlook and I tried to change the name to Mail and it did not work
tell application "Microsoft Outlook"
try
set theMessage to item 1 of (get current messages)
if class of theMessage ≠ incoming message then error -99
on error
display dialog "please select an incoming message before running
this script" buttons {"Abort"} default button 1 giving up after 10
end try
set oldSubject to subject of theMessage
try
set newSubject to text returned of (display dialog "Enter New
Subject:" default answer oldSubject)
on error
-- user cancelled
return
end try
set subject of theMessage to newSubject
end tell
What I am trying to do is create an Automator script that can be added to my usr/Library/Serices folder that will let me change the Subject of an OS X 10.7 Apple Mail message.
I am s novice on AppleScripts so some help will be appreciatedThe error I get when I edit Microsoft Outlook to Mail says
Expected “,” but found plural class name. -
Alternatives to AppleScript and Automator?
AppleScript is so hard to use. Why has Apple let it languish, so utterly broken and hard to use? Is something coming around the bend and they prefer to replace it rather than patch it? Do we need to wait for OS 11?
+ iTunes 10 won't run any scripts, claiming I need iTunes 2.0.3, the old string comparison for version number bug. Sure one can hack the number but that's honestly not the right answer.
+ Automator doesn't accept variables, which requires a hack for editing the UUID in the XML form of the workflow.
+ Dictionaries and the bizarre and inconsistent COBOL-like syntax for object access are just too wild to grok. Hence these forums for constantly full of real people asking for advice, that is to say they want someone to write it for them. And who can blame them?
I've read Neuberg's Definitive Guide, which just makes me laugh as I get the picture of a language for which excuses must be made every few pages. Despite matt's excellent wring and research, the subject is so twisted he can't convey a consistent mental model. AppleScript is just failed tech which only a few fans "get". I grok everything from LISP to TCL, but AppleScript is just a disaster, a mess.
Sorry, I just needed to vent. This isn't a troll for defensive reactions. I would appreciate sympathy and alternative ideas for AppleScript. Can I learn some other language that uses Apple Events in a saner fashion? (Apple Events may in fact be part of the problem too, I know.) Will these work in every place AppleScript is accepted (iTunes script menu, Services plug-ins)?You will get arguments from both sides, but AppleScript is far from broken - weird perhaps, but it does get changed and updated for each OS version. There are a few AppleScript forums such as macscripter.net to help you figure out it's quirks, but I don't see it being replaced anytime soon.
+ I don't run iTunes 10, but that particular bug doesn't have anything to do with AppleScript itself, just the way the version number gets looked at.
+ Automator does use variables, but the particular action needs to be written to use them - Apple is being a bit slow to update a lot of it's included actions, but you are welcome to write your own or use a third party action. There are also actions that will let you run a shell script such as bash, Python or Ruby.
+ You won't get any argument from me about the scripting dictionaries, although those are written by the particular application developer.
You definitely do not need to use AppleScript, so if you are looking for something other than a compiled language such as Objective-C or C/C++, there is perl, Python, php, tcl, and Ruby, in addition to the command line shells such as bash, ksh, zsh, and tcsh. Apple events are what is ultimately used by any scripting language to control the various applications - for an Apple-Event bridge, you might take a look at appscript. -
AppleScript and Automator forums
I was trying to help someone who wanted to do the same thing to hundreds of files and my thought was to suggest either Automator or AppleScript to them. These technologies seem related to me. Anyway, the AppleScript forum is under "Mac OS X Technologies", the Automator forum is under "Mac OS X v10.4 Tiger". I would expect to find these technologies together, AND if there is an Automator forum under Tiger, I'd expect to find one under Leopard as well. I know there was some talk about reorganizing the forums, I wanted to mention that this seemed confusing to me.
I believe csv files are just plain text files in which case what you want can be easily done with a shell script.
the following terminal command will take the contents of file1.csv and write every even line to file2.csv
cat path/to/file1.csv | sed -n '2,${p;n;}' > path/to/file2.csv
You need to put the paths to the files in question in the above.
for example if those files are located in your Documents folder the command would be
cat ~/Documents/file1.csv | sed -n '2,${p;n;}' > ~/Documents/file2.csv
You can put it inside an automator workflow using run shell script action.
If you want odd rather than even lines change the command to
cat path/to/file1.csv | sed -n '1,${p;n;}' > path/to/file2.csv -
Applescript and Automator Issue
Hi all,
I'm trying to design an Automator and Applescript code that will perform the following.
1. Target specified application and make active
2. Hold down s key for 15 seconds
3. Hold down the left arrow key for 0.75 seconds
4. Hold down s key for 15 seconds
5. Hold down right arrow key for 0.75 seconds
6. Repeat this 100000 times.
The code I have developed is as follows:
activate application "MyApplication"
repeat 1000000
tell application "System Events"
key down (key code 1)
delay 15
key up (key code 1)
end tell
tell application "System Events"
key down (key code 123)
delay 0.75
key up (key code 123)
end tell
tell application "System Events"
key down (key code 1)
delay 15
key up (key code 1)
end tell
tell application "System Events"
key down (key code 124)
delay 0.75
key up (key code 124)
end tell
The problem is that this program is recognizing the key codes all wrong. The key code 1 refers to my "a" key when it should be referring to "s". Key code 123 and 124 don't do anything. Is there something wrong with my code? Help would be appreciated.
ThanksUsing JavaScript to script System Events wouldn't be any better, since it uses the same Apple Events mechanism (how well it uses it is another topic). To hold down a key you would need to use something that has access to the deeper system APIs, most likely using Xcode.
And yes, your code snippet will press the arrow key 5 times (I am guessing that the missing space in key code is a typo). You can place the cursor in a bunch of text in another application such as TextEdit, and use your script to activate it before performing the key codes to get a better idea of what is happening (trying to reposition the cursor in the Script Editor will reveal a bug with the delay command). -
IMovie 08 slideshow infinite loop - with Applescript and Automator?
As many people I try to use iMovie for a slide show with an infinite loop. But there is no button inside the program for it. I don't want to export the project to use the loop function of Quicktime. Because that means compression of the slide show photos - Export with Quicktime: H.264, Best Quality.
I already compressed the photos with JPG in High Resolution (Photoshop) and dropped them into the project. The result of double compression is not fine (enough). And the amount of data increases.
So I tried to program a short Applesript for an infinite loop in iMovie. First it seemed to be very simple. iMovie "cmd g" starts the fullscreen presentation of the project. At the end you press "spacebar" and it runs again.
(Finder object)
tell application "System Events"
tell application "iMovie" to activate
keystroke "g" using command down
end tell
(Pause)
tell application "System Events"
tell application "iMovie" to activate
keystroke "space bar" (or "arrow left"?)
end tell
(infinite loop)
Unfortunately it didn't loop. At the end of the presentation the screen remains black. Only a beep signals that the Applescript pressed the spacebar. What did I wrong?
In some groups people say it's impossible to program a script for iMovie because it does not support Applescript.
BlackletterI made a simple mistake in the code.
wrong:
keystroke "space bar"
right:
keystroke space
Now the infinite loop runs in iMovie! -
Mount script for ext2 - mixing applescript and shell script
Hello
i want to do a .app using the ScriptEditor to get my external usb-disc mounted.
I tried ExtFS Manager before, but was not as happy with it.
so the basic idea is some kind of mixture of apple script and bash-shell script, but im not sure how to combine it.
shell script:
#!/bin/sh
sudo kextload /Library/Extensions/ext2fs.kext
mkdir ~/usb_music/
sudo mount -t ext2 -o nosuid,w,m=777,user /dev/disk1s5 ~/usb_music/
sudo chmod a+rwx ~/usb_music/
apple-script:
on run
try
do shell script ""
end try
end run
any ideas how to get it combined and working ?
best regards
fidel
MacBookPro 15,4" 1,83 GHz Mac OS X (10.4.8)is there a way to implement it in a way that normal users can work with sudo to mount the drive ?
kextload requires superuser privileges, so at some point some part of your script is going to need to run with elevated privileges.
It is possible to configure sudo to allow non-admins to run any other commands. You could either allow non-admins to to run kextload or, preferably, allow them to run your shell script.
man sudoers will give you the details on how to configure sudo to do this, which might be as simple as:
<pre class=command>ALL ALL=(ALL) /usr/local/bin/myscript</pre>
This will allow all users to run /usr/local/bin/myscript as root. -
Applescript and Automator HELP!!!
I have changed an application's Info.plist file to make it hidden form the dock and finder, using automator a series of actions complete. After these I want to make the applications window which is currently showing on the desktop to be hidden, however I can't seem to use commands due to this application being hidden from finder. Thanks.
I have changed an application's Info.plist file to make it hidden form the dock and finder, using automator a series of actions complete. After these I want to make the applications window which is currently showing on the desktop to be hidden, however I can't seem to use commands due to this application being hidden from finder. Thanks.
-
Hello.
I would like to search for specific online сhеss games. Each game has a single adress. We are talking about millions of games. Obviously, it's far too long to index all the games. So I will set a limit and use the script at night. Conditions should be something like this:
For adress example.com/game=NumberA to example.com/game=NumberB
Search every web page containing SpecificWord
Store wanted web adresses somewhere (so I could see the games by myself during the day)
As you can see, I know nothing about Applescript and I don't know how to start, nor how the script can pick up adresses. I think it's possible and not difficult to code, just time consuming for the program to search through thousands of games.
Should I use AppleScript or Automator? Should the script open Safari (or Firefox if possible) or can it search without any browser? Is it possible to simultaneously search through multiple pages/adresses? Maybe I could write several scripts for different ranges of games? If so, how many pages can I open at once? For instance I could disable images in Firefox to load quicker. How much time does it need to search for one game? 1, 2, 3, 4, 5 seconds?
Any easy tutorials, examples of similar codes, advices, hints or tips are appreciated.Thanks for answering. Sorry that I was so unclear. My main problem was how to get urls and games id as variables. But then I thought there already should be programs doing web crawling. I have found Scrapy which use Python language.
(Maybe I should edit my question, add Scrapy and Python as tags instead of applescript and automator. Is it possible?)
I have Mac OS 10.6.8, Python 2.6.1. Scrapy needs at least Python 2.7 so I have downloaded the last version of Python (3.3). I think I can handle the programming in Scrapy thanks to their tutorial. The most difficult part should be... how to install Scrapy. Don't laugh at me.
I have entered "sudo easy_install Scrapy" in the terminal. But the terminal still uses Python 2.6.1. Python 3.3 is installed but I don't know how to clean update Python. If anyone knows, feel free...
When I write scrapy in the terminal, here is what I get:
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 4, in <module>
import pkg_resources
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg _resources.py", line 2556, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg _resources.py", line 620, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg _resources.py", line 518, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: lxml
It seems Scrapy also needs something called lxml. Right now I am trying to make Python 3.3 the default python version. Is there a web crawler GUI which already includes Python, Scrapy, lxml?
By default I also have Python 2.4 and 2.5. Does the system need them? I prefer not to delete system files but together all Python versions weigh 500 MB.
In regard to the real example URL: let's say instantchess.com. Here's a game URL: http://www.instantchess.com/?EXP=1&GPI=84094532
84094532 is the game id. Let's say I want to search every Reti openings (thus the page must contain the word "Reti") from id 84000000 to 85000000 and store games id in my computer. If I have understood correctly, I need to search through the source code of the pages.
Feel free to add any remarks, suggestions, ideas. -
iCal failing to run applescripts: The 'Open' button does not change to 'Run', and the script file is opened but not executed.
Calendar (not called iCal anymore) does not include that capability any longer, apparently. What you have to do now is go to Automator and create a Calendar Alert action. You can add a Run AppleScript object to the action and paste in your script there, then when you save it, it will become available as a choice in the alert menu in Calendar.
-
Adding AdSense and Other Script Based Items to iWeb Websites
For all those who are trying to figure out how to add AdSense and other script based content, here is a tutorial on how to do so. You can see this article with graphics and other niceties on my website:
http://keylime.ca/adsense%20on%20iweb.html
For now, here is the text-only version.
The following is a simple step by step how-to for adding script based items to iWeb based websites easily and quickly.
First things first, you need a tool to use for finding and replacing text in numerous files quickly and easily. This one works great, and is free:
http://lonestar.utsa.edu/llee/applescript/simplefindreplace.html
This tutorial will show you how to add AdSense banners--but you could easily add any sort of script based content with the same instructions.
1. Open your iWeb project.
2. Click on the Inspector. Click on the Page properties icon.
3. In the Header Height field, increase it enough to add your AdSense banner. The banners are of various sizes. You should know this value from when you generated your AdSense code.
4. Add a Text item to your page. Make the text item as large as your banner.
5. Add a unique string to your text item, such as mywebsitenamegoogleads. It is vital that the text string be unique and not be anywhere else in the page. The string must be the same in each text item on each page you will be adding AdSense banners to. You can center the text, but no not vertically center it. Vertically centering the text will turn the text item into a PNG file as opposed to a document division!
6. Cmd-Click the text item and drag it into the header. Cmd-Clicking an item allows you to move it into a footer or header.
7. Repeat steps 1 through 6 for each page you will be adding AdSense banners to. Take note: Once you lay out your page header, you can select all of it, copy, and paste it to each page. iWeb remembers its original position, so you don’t have to move it around!
8. Publish your site to a folder. It is against the terms and conditions of .mac to have ads on your .mac account, so you will have to put your site on a regular server.
9. Open Simple Find and Replace.
10. Drag and drop the folder you published your website to into the target field in Simple Find and Replace.
11. Put your unique string from step 5 into the Find field.
12. Put your AdSense code into the Replace field.
13. Click Start Replacing.
14. Put your website online. That’s it!
I hope Apple decides to integrate a tool to make this easier!
Mac OS X (10.4.5)Should be the same process whether you publish to .Mac or any other host. You're dealing with the same files in either case. Just follow the directions and you'll do just fine! Good luck!
James
==> www.DirtDoog.com <==</a>
Place A Virtual Pin On Putt-Putt's GuestMap! -
How to hide rows and columns by AppleScript or Automator for printing
Hello,
I have to hide first empty rows (I do it by: organize - Column B is not empty)
then: By context-menu in Header of Column K: Hide column
and: By context-menu in Header of Column L: Hide column
How can I make this 3 Steps automatic with AppleScript or Automator or maybe by formula?
Thanks for any helpHere is an edited version which allow you to choose the custom template on the fly.
No need to edit a property in the script.
--[SCRIPT printtable(s)_choosecustom]
Enregistrer le script en tant que Script ou Application : printtable(s)_choosecustom.xxx
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner une partie de table, une table ou même plusieurs tables.
Aller au menu Scripts , choisir Numbers puis choisir “printtable(s)_choosecustom”
Le script crée un nouveau document depuis un modèle perso sélectionné,
puis applique « Colle les valeurs » au contenu du presse-papiers.
Il envoie enfin la commande d'impression.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
Sous 10.6.x,
aller dans le panneau "Général" du dialogue Préférences de l'Éditeur Applescript
puis cocher la case "Afficher le menu des scripts dans la barre des menus".
--=====
Save the script as a Script or an Application : printtable(s)_choosecustom.xxx
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a subset of a table, a table or even several tables.
Go to the Scripts Menu, choose Numbers, then choose “printtable(s)_choosecustom”
The script create a new document based on the selected custom template,
then apply “Paste Values” to the clipboard's contents.
At last, it issue the print command.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2011/02/20
2011/03/16 -- replaced the Blank template by a custom one defined thru the property custom_template
2011/03/17 -- Let choose the custom template, no longer Paste but Paste Values.
--=====
property theApp : "Numbers"
--=====
on run
--my doyourduty()
run script doyourduty
end run
script doyourduty
--on doyourduty()
my activateGUIscripting()
Copy the selected items *)
my raccourci(theApp, "c", "c") (* cmd + c *)
Create a new document based upon Blank.template *)
set myNewDoc to my makeAnIworkDocFromCustom()
As it's a custom template, there is no default table to delete.
Delete the default table *)
tell application "Numbers" to tell document 1 to tell sheet 1 to delete table 1
my selectMenu("Numbers", 4, 8) (* Paste Values *)
my raccourci(theApp, "p", "c") (* cmd + p = Print *)
my raccourci(theApp, return, "") (* return = validate the Print command*)
--end doyourduty
end script
--=====
Creates a new iWork document from a custom template and returns its name.
example:
set myNewDoc to my makeAnIworkDocFromCustom()
on makeAnIworkDocFromCustom()
set nb_chiffres to 3 (*
2 = allow 99 templates
3 = allow 999 templates *)
Grab the localized names of the templates folders *)
tell application "Numbers"
set templates_loc to localized string "Templates"
-- set myTemplates_loc to localized string "My Templates"
end tell -- to application a
Define the path to the folder storing custom templates *)
--set chemindesmodeles to "" & (path to library folder from user domain) & "Application Support:iWork:Numbers:" & templates_loc & ":" & myTemplates_loc & ":"
set chemindesmodeles to "" & (path to library folder from user domain) & "Application Support:iWork:Numbers:" & templates_loc & ":"
Grab the list of every items stored in the folder *)
tell application "Finder"
set entire_contents to entire contents of folder chemindesmodeles
end tell
Build two lists. One contain the path to every custom templates.
The other contain the names of these templates and the names of subfolders *)
set indx to 1
set cheminde_mesmodeles to {}
set nomsde_mesmodeles to {}
set le_conteneur to ""
tell application "System Events"
repeat with i from 1 to count of entire_contents
set un_element to item i of entire_contents as text
try
if type identifier of disk item un_element is in {"com.apple.iwork.numbers.template", "com.apple.iwork.numbers.sfftemplate"} then
if name of container of disk item un_element is not le_conteneur then
set le_conteneur to name of container of disk item un_element
copy (text 1 thru nb_chiffres of "---") & space & le_conteneur to end of nomsde_mesmodeles
end if
copy un_element to end of cheminde_mesmodeles
copy text -nb_chiffres thru -1 of ("00" & indx) & space & name of disk item un_element to end of nomsde_mesmodeles
set indx to indx + 1
end if
end try
end repeat
end tell -- System Events
if my parleAnglais() then
set le_titre to "Numbers’s custom templates"
else
set le_titre to "Modèles personnalisés de Numbers"
end if
Choose the template to use.
If you select a subfolder name, the script beep and ask one more time *)
tell application (path to frontmost application as string)
repeat
set mon_choix to choose from list nomsde_mesmodeles with title le_titre
if mon_choix is false then error number -128
try
set mon_choix to text 1 thru nb_chiffres of (item 1 of mon_choix) as integer
exit repeat
on error
beep 1
end try
end repeat
end tell
tell application "Numbers"
set nb_doc to count of documents
open (item mon_choix of cheminde_mesmodeles)
repeat until (count of documents) > nb_doc
delay 0.1
end repeat
set doc_name to name of document 1
end tell -- the_App
return doc_name
end makeAnIworkDocFromCustom
--=====
on parleAnglais()
local z
try
tell application theApp to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
on activateGUIscripting()
(* to be sure than GUI scripting will be active *)
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true
end tell
end activateGUIscripting
--=====
==== Uses GUIscripting ====
This handler may be used to 'type' text, invisible characters if the third parameter is an empty string.
It may be used to 'type' keyboard raccourcis if the third parameter describe the required modifier keys.
I changed its name « shortcut » to « raccourci » to get rid of a name conflict in Smile.
on raccourci(a, t, d)
local k
tell application a to activate
tell application "System Events" to tell application process a
set frontmost to true
try
t * 1
if d is "" then
key code t
else if d is "c" then
key code t using {command down}
else if d is "a" then
key code t using {option down}
else if d is "k" then
key code t using {control down}
else if d is "s" then
key code t using {shift down}
else if d is in {"ac", "ca"} then
key code t using {command down, option down}
else if d is in {"as", "sa"} then
key code t using {shift down, option down}
else if d is in {"sc", "cs"} then
key code t using {command down, shift down}
else if d is in {"kc", "ck"} then
key code t using {command down, control down}
else if d is in {"ks", "sk"} then
key code t using {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
key code t using {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
key code t using {command down, shift down, option down}
end if
on error
repeat with k in t
if d is "" then
keystroke (k as text)
else if d is "c" then
keystroke (k as text) using {command down}
else if d is "a" then
keystroke k using {option down}
else if d is "k" then
keystroke (k as text) using {control down}
else if d is "s" then
keystroke k using {shift down}
else if d is in {"ac", "ca"} then
keystroke (k as text) using {command down, option down}
else if d is in {"as", "sa"} then
keystroke (k as text) using {shift down, option down}
else if d is in {"sc", "cs"} then
keystroke (k as text) using {command down, shift down}
else if d is in {"kc", "ck"} then
keystroke (k as text) using {command down, control down}
else if d is in {"ks", "sk"} then
keystroke (k as text) using {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
keystroke (k as text) using {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
keystroke (k as text) using {command down, shift down, option down}
end if
end repeat
end try
end tell
end raccourci
--=====
my selectMenu("Numbers",4, 8)
==== Uses GUIscripting ====
on selectMenu(theApp, mt, mi)
tell application theApp
activate
tell application "System Events" to tell process theApp to tell menu bar 1 to ¬
tell menu bar item mt to tell menu 1 to click menu item mi
end tell -- application theApp
end selectMenu
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) jeudi 17 mars 2011 21:29:15
Maybe you are looking for
-
How to Pass the internal table data?
DearAll, How to pass the Data of one internal table on a 1.html page to another html page for output, in BSP Application. regards.
-
IPad 2 icons go missing from desktop on rotating basis
As stated, iPad 2 icons go missing from desktop on rotating basis. My iPad was new as of Xmas day. I have NOT synced to iTunes (I don't want to at this time) and I have NOT upgraded the software to iOS 5.0.1 (still on 5.0). I have downloaded about tw
-
Hi, Has anyone experienced problems with the audio when importing to imovie hd06 from a dv tape? It starts out fine but the later clips seems to alter the sample resolution in the audio file so that audio is the same lenght but pitch is lower..? Macm
-
help please?
-
Interactive Forms - Print orientation - ZPL
Hi, i am going to create my first label on a zebra printer with adobe forms (LiveCycle-Designer 8.2). When i print the label with a portrait-format everything is fine. In a special case the height of the label is about 2cm and the width is 10cm. So t