Basic AppleScript Dialog: display dialog "Your text here" with icon stop buttons {"OK"} default button {"OK"} giving up after 5
'giving up after 5' will automatically close the script after the indicated interval of time has elapsed.
|
When you run this script, you are prompted to choose an image import folder. The script cycles through the files in the selected folder and determines if they are appropriate image files and then imports the relevant files.
To use this, you need to create a database with a text field named “GraphicName” and a container field named “GraphicField”
tell application "Finder"
activate
set folderPath to (choose folder with prompt "Choose an image folder to import:")
set fileList to list folder folderPath
end tell
set imageCount to 0
repeat with imageName in fileList
tell me to set imageRef to (folderPath & imageName as string)
if folder of (info for (alias imageRef)) = false then
set fileKind to (kind of (info for (alias imageRef)))
--This next line sets things up so that PICT,GIF,JPEG,PNG anf TIFF formats are all valid
if kind of (info for (alias imageRef)) contains "Picture" or kind of (info for (alias imageRef)) contains "Image" or kind of (info for (alias imageRef)) contains "Graphics" then
tell application "FileMaker Pro"
activate
tell database "Picture File.fp5"
set newRecord to (create record)
go to newRecord
set cell "GraphicName" of newRecord to imageName
set cell "GraphicField" of newRecord to file (imageRef)
set imageCount to imageCount + 1
end tell
end tell
end if
end if
end repeattell me to activate
if imageCount = 0 then
display alert "No files of specified types were found in folder: " message (folderPath as string) as warning
else
display dialog "Number of pictures imported using specified file references: " & imageCount with icon 1
end if
tell application "FileMaker Pro" to activate

If you have questions about any other AppleScript issues, contact me at: hyperscripter@gmail.com or http://facebook.com/hyperscripter or to subscribe, click the By Email link at the top of the page.
This is a script, that I use to strip the HTML from my web documents. It really comes in handy, when you want to edit the content of a document without all of the distractions of all of the HTML tags getting in the way. It was written specifically for use with Word 2008, although it could be adapted, with a little tweaking, for use with other apps such as Pages or AppleWorks 6.
To use this script, open an HTML doc, select its contents, and copy to the clipboard, then run the script:
tell application "Microsoft Word"
tell selection
try
set clipboardData to Unicode text of (the clipboard as record)
set clipboardData to (my clearHTML(clipboardData))
type text text clipboardData
on error errormsg
display dialog errormsg
end try
end tell
end tell

This sub-routine eliminates the HTML and returns the result to the main script:
on clearHTML(clipboardData)
set copyText to true
set newText to ""
repeat with targetChar in clipboardData
set targetChar to contents of targetChar
if targetChar is "< " then set copyText to false else if targetChar is ">" then
set copyText to true
else if copyText is true then
set newText to newText & targetChar as string
end if
end repeat
return newText
end clearHTML
For a similar post on this topic, written for AppleWorks 6, go to Converting HTML to Text Format/

In closing, if you have comments or questions, or would like to suggest a topic, contact me at: hyperscripter@gmail.com or http://facebook.com/hyperscripter

If you have used AppleWorks 6 in the past, this script for Pages should be easy to follow, although the syntax is not exactly the same as AppleWorks.
In fact, the Pages application was derived from AppleWorks 6 ! To see the similarities (and the differences) check out some of my other posts on AppleWorks.
This post covers a variety of standard script statements for Pages that you will often want to implement with AppleScript. I tried to make this fun too; run this in the Script Editor:
tell application "Pages"
activate
make new document with data "Hello there!" & return & return & "Let's see some of the scripting we can do with a Pages document!"
set properties of front document to {name:"New Test Doc"}
delay 5
tell front document
select body text
set font name of body text to text returned of (display dialog "Choose a font for the body text:" default answer "Arial")
set font size of body text to 18
set font size of paragraph 1 to 36
set color of body text to (choose color default color {0, 0, 65535})
select paragraph 1
set selection to "Goodbye!"
set font size of paragraph 1 to 36
set color of paragraph 1 to (choose color default color {0, 65535, 0})
select paragraph 2
set selection to "Isn't this a lot of fun?"
delay 5
display dialog (paragraph 1 & " Have fun!!") with icon 1 buttons {"Goodbye !"} default button 1
set selection to "Have fun!!"
set color of paragraph 2 to {65535, 0, 0}
set font size of paragraph 2 to 48
end tell
end tell

If you have questions about any other AppleScript issues, contact me at: hyperscripter@gmail.com or http://facebook.com/hyperscripter or to subscribe, click the By Email link at the top of the page.

This post is a sort of continuation of a previous post on security and GUI. This does not contain any script samples, but is rather information of general utility to all who use the internet and are concerned about potential security issues.
Revealing Personal Info on FaceBook and Twitter
I was inspired to write this post, in part, after reading an article in a local newspaper on mistakes that people make when using Twitter. The most striking of which was a particular case in which someone revealed that they were about to go on vacation.
On the surface, this seems pretty harmless, but consider the fact that this person also provided their real name in their profile and furthermore (real big mistake), the dates that they would be away.
I know that most people would not be foolish enough to give out sensitive info over the internet, so you’re probably thinking: “So what if I reveal my real name in my profile?”
It is not widely known, but internet scammers routinely follow Twitter (and FaceBook) looking for potential victims for identity theft. If you have revealed your real name in your profile, they will ‘follow’ your Tweets to see what other personal information you will reveal, because they know that the typical ‘tweeter’ feels at ease with saying anything that they want to say, thinking that tweets are secure.
If you look like a good candidate for identity theft they will compile their own profile of you and wreak havoc on your credit. It is also not widely known that thieves can sometimes find out where you live and literally ‘rob you’ in the given scenario above. Revealing your name alone can make it possible for scammers to potentially find out your social security number and more, and then, well, be forewarned and protect yourself.

Passwords and Email Etc
What was said in the previous section about your profile applies to email as well; you just have to make a judgement call as to your risk based on how much you work on the internet and the kind of info you share. I spend a lot of time on the internet doing a variety of things, so the measures that I must take may be more stringent than yours. Once again, you have to judge that for yourself.
One issue that applies to email is managing your inbox. If you’re like me, you scrutinize everything that comes in and delete anything that looks questionable. Some say that you should delete and, by all means, do not open anything that does not come from someone you know or a site that you know. I wouldn’t suggest this extreme for everyone and have to admit that with all I do over the internet, I don’t even entirely adhere to that proviso. I do have a few caveats to suggest though.
The first one is, do not fall prey to scams claiming that you have inherited funds from a distant relative (usually from some foreign country). The most current of which supposedly originates through The Bank of Nigeria (see link below for other scams). These people will try to play off of your emotions, trying to see if they can get an initial ‘hook’ to lure you in. Once they have you, they will try to convince you again and again that some fee is required in order to release your supposed inheritance. The old rule of thumb applies here: ‘If it looks to good to be true, it probably is!’
For some other scams go to: www.scam.com/
The second one relates to file suffixes. Do not open any emails containing attachments with prefixes that you do not recognize. By far the most common is ‘.exe’; it stands for execute. It can be a good thing, such as software that you wanted to download, but it also could by spyware to get hold of your personal information or even a virus to corrupt your system. In fact, some of these files are so malicious, that they wiill both steal your info as well as corrupt your computer.
Note: If you use a Mac, don’t even concern yourself with ‘exe’ files in the first place, because they are useless files that your computer may open up, but it will come up as complete gibberish and can’t harm your computer anyway.

On the subject of passwords with email etc, be creative (and clever) about your choices. In general, try to be a little cryptic. For example, instead of using a password such as say, bumblebee, use bum56blebee or bum#bleb$ee. Interspersing symbols or numbers in your password makes your password very difficult to figure out and, as long as you don’t make it too complicated, you should still be able to easily remember it.
The reason for such measures is this: there are people out there who will find out your email address and then run a robot algorithm program that will try different combinations of common English (or foreign) words until they hit a match. Some of these programs are so sophisticated that they can attempt over a million combinations per minute.
For tips on good passwords and other security measures, go to www.microsoft.com/security/
Passwords: www.microsoft.com/security/pc-security/password-checker.aspx
In closing, your best and easiest defense against identity theft is to keep financial information and passwords, as much as possible, stored on an older computer (if you have one) that is not connected to the internet. Furthermore, it is ill-advised to allow Yahoo, for instance, to save your password for you. Although it is probably fairly safe, from time to time you will hear of breaches in security even with a major site such as Yahoo. This is not to single out Yahoo, because this applies equally to Google, Hotmail, even online banking and others.
One final bit of advice is to use sites beginning with ‘https’ as much as possible when dealing with personal information, while they are fairly secure, as it is widely known that taking risks with your info through regular ‘http’ sites is a common source of identity theft over the internet.
If you have questions about other internet issues or, of course, AppleScript, contact me at: hyperscripter@gmail.com or http://facebook.com/hyperscripter or to subscribe, click the By Email link at the top of the page.
For a discussion of security issues with the internet and GUI, go to security and GUI Security Issues with GUI and the Internet
Sometimes I am overwhelmed with the number of items that I have on my desktop and within folders and subfolders and having to spend so much of my time trying to organize them so they will be easy to locate. So, I came up with a script to automate that task.
To use this script, copy it into Script Editor and save it as an applet. When you have done that, select items in the Finder and drop them onto the droplet. It prompts the user for a new folder name, checks first to be sure that it does not already exist, then moves the selected items to the new folder and notifies the user that the task was successful. If the folder already exists, it continues through the repeat loop until a valid folder name has been entered or the user cancels the script or it times out.
on open (targetFiles)
try
tell application “Finder” to set targetFolder to (folder of the front window) as alias
on error
set targetFolder to path to desktop folder as alias
end try
tell application “Finder”
try
repeat
set folderName to text returned of (display dialog ¬
“Enter a name for the transfer folder:” default answer “” with icon 1 buttons ¬
“OK” default button 1 giving up after 45)
set folderExists to (exists folder folderName of folder targetFolder) as string
if not (folderExists = “true”) then exit repeat
(*display alert “The folder \”" & folderName & ” \” already exists.” message ¬
“Please choose an alternate folder name.” as warning buttons “OK” default button 1 ¬
giving up after 5*)
display dialog “The folder \”" & folderName & ” \” already exists.” & return & return & ¬
“Please choose an alternate folder name.” with icon 0 buttons “OK” default button 1 ¬
giving up after 5
end repeat
if not (folderExists = “true”) then
set transferFolder to (make new folder at targetFolder with properties {name:folderName})
repeat with theItem in targetFiles
move theItem to transferFolder
end repeat
display dialog “The selected items have been moved to the new folder \”" & folderName & ¬
” \” .” with icon 1 buttons “OK” default button 1 giving up after 24
tell application “Finder” to activate
end if
on error
return
end try
end tell
end open

If you have questions or would like to suggest a post on another AppleScript issue, contact me at: hyperscripter@gmail.com or http://facebook.com/hyperscripter or to subscribe, click the By Email link at the top of the page
GUI Scripting is a great way to script those applications that do not have a scripting vocabulary and for those with limited scripting support. You may, however, have thought to yourself: “Is it really a good idea to leave it enabled all of the time, especially when I work on the internet a lot?” There are differing opinions on that, but I would say unequivocally – No!
The reason is this: Many of your system preferences and other critical files on your computer cannot be easily scripted without GUI (if at all). Even if you don’t spend much time on the internet, if you share your computer with other users that you aren’t sure you can totally trust, you should at least set a password to authenticate its use.

To play it safe, I begin every GUI script with:
enabledGUIScripting (true) --see below
And end every GUI script with:
enabledGUIScripting (false)
on enabledGUIScripting (theBoolean)
tell application “System Events”
activate
set UI elements enabled to theBoolean
return UI elements enabled
end tell
end enabledGUIScripting

Following this practice, I ensure that no-one has access to GUI during idle or if I forget to manually disable GUI when I leave my computer while connected to the internet.
NOTE OF CAUTION: Quitting your browser does not protect you from potential hackers. Even if you have a system-wide password set, which I highly advise, you are still not completely protected.
To enable/disable GUI Scripting go to System Preferences from the Apple menu and click on Universal Access at the bottom of the window and click on ‘Enable access for assistive devices’. Optionally you can go to YourHD>Applications>AppleScript>AppleScript Utility to set it there.
If you have questions about AppleScript, contact me at: hyperscripter@gmail.com or http://twitter.com/hyperscripter or to subscribe, click the By Email link at the top of the page.
|
 
HTML Guide from Peachpit Press
 iPhoto 6
Create Multiple Folders with Terminal
If you are more of a techy kind of person and are comfortable with using Terminal, here is a script you can use to easily create multiple folders:
First, for a single folder, type in: mkdir "Folder 1"
--or whatever you want to name your folder, this creates a new directory, which, in effect is a new folder.
To place multiple items in the 'Documents' folder:
cd/Users/
Administrator/
Documents
mkdir "Folder 1" "Folder 2"
"Folder 3"
To quickly create multiple folders, create a text file with the desired folder names (as many as you want) and name it something like 'folderList.txt'. Next type this in Terminal:
cat folderList.txt |xargs mkdir
Or you could create folders with the same prefix by entering:
mkdir "Invoices " {"Corporate", "Individual", "Pro-Bono"}
Digg This!!
An AppleScript to Verify a Date Run this in the Script Editor:
set dateRecord to (current date)
set defaultDate to (date string of dateRecord)
try
set apptDate to text returned of (display dialog "Enter appointment date:" default answer defaultDate buttons {"Set"} default button {"Set"})
set datetext to apptDate as text
date apptDate --if an invalid date is entered, the next dialog is aborted and it triggers the error alert below.
display dialog datetext & " is a valid date." with icon note buttons {"OK"} default button {"OK"}
on error
set alertText to "An error has occurred!"
set messageText to quote & datetext & quote & " is an invalid date."
display alert alertText message messageText as warning buttons {"OK"} default button "OK" giving up after 15
return
end try
|
 Concept Drawing for iMac prior to Production
Fun HTML Use this to add interest to your pages, but be careful, if you overdo it, it can make your page look gaudy, if not ridiculous!
Read All About It
Here's is the code as it appears above:
<p align="center" style="padding: 5px; background-color: #FFCE9C; border: dotted 5px #FFCE9C;"><marquee width=20% behavior=scroll direction=left loop=infinite> Latest Headlines... </marquee><blink>Read All About It</blink>/p>
Check out this color HTML!!!
AppleScript for Setting System Volume Copy and paste this into the Script Editor and try it out:
set defaultVolume to "3"
set volumeLevel to text returned of ¬
(display dialog ¬
"Set the system volume to (7 is the highest):"¬
default answer defaultVolume with icon note¬
buttons {"OK"} default button "OK") as integer
set volumeValues to {0, 1, 2, 3, 4, 5, 6, 7} ¬
as list
if volumeLevel is not in volumeValues then ¬
set volumeLevel to defaultVolume
tell application "Finder"
try
set volume volumeLevel
beep 2
on error errDlog
display dialog errDlog with icon stop ¬
buttons {"Abort"} default button ¬
"Abort" giving up after 15
end try
end tell
Earn Wealth on Internet
Learn Tips and Tricks to Making Money on the Internet
www.internetwealth.com
Learn How To Make Money Blogging - Blog Mastermind
Six-figure Yaro Starak Teaches You How To Set Up And Profit From A Successful Blog. Start Making Money From Blogs By Following This Step-by-step, Weekly Coaching Program
http://www.blogmastermind.com/coaching/
Seo Elite: New Seo Software!
The Grand Daddy Of All Seo Software!
Get A Top 5 Google Ranking In Under 30 Days!
http://www.seoelite.com/
Turn Your Photos Into Cash
All You Need Is A Digital Camera, A Computer And An Internet Connection To Get Started Making Extra Income Every Month!
http://turnyourphotosintocash.com/
Infinite Income Plan - Instant Wealth Guide & CDs.
Easy Money For Affiliates, Huge 8.3% Conversions On Generic Traffic. Massive 70% Commissions Plus
HyperCard AppleScript Users:
Heres an AppleScript for backing up a selected group of HyperCard files. this was used in one of my HyperCard stacks, but could be adapted for use in OSX programs with little or no modification:
send "suiteBkp(true)" to bg btn "BackupSuite"
--Use this line to call the handler below (true displays a notification dialog when the process is complete, you must have a button named bg btn "BackupSuite"):
on suiteBkp(theBoolean)
copy line 1 of field "selectedFolder" to theHFFolderPath --You'll need a hidden field named "selectedFolder" that a script (prior to the call) will place the path to the desired folder in.
tell application "Finder"
activate
set todaysDate to (current date)
set bkpYear to (year of todaysDate)
set monthlyBkp to ("Monthly Reports_" & bkpYear) as string
if exists (folder "HyperCard Backup") then
select folder "HyperCard Backup"
delete selection
end if
if exists (folder "HyperCard Backup" of folder theHFFolderPath) then
select folder "HyperCard Backup" of folder theHFFolderPath
delete selection
end if
make new folder at folder theHFFolderPath with properties {name:"HyperCard Backup"}
select {file "Appointments" of folder theHFFolderPath, ¬ file "HyperFile" of folder theHFFolderPath, ¬ file "Outstanding Invoices" of folder theHFFolderPath, ¬ file "Year" of folder theHFFolderPath, ¬ file monthlyBkp of folder theHFFolderPath, ¬
copy selection to folder "HyperCard Backup" of folder theHFFolderPath
select folder "HyperCard Backup" of folder theHFFolderPath
select file "Appointments" of folder ¬ "HyperFile Suite Backup" of folder theHFFolderPath
set name of selection to "Appointments.bkp"
select file "HyperFile" of folder "HyperCard Backup" of ¬ folder theHFFolderPath
set name of selection to "HyperFile.bkp"
select file "Outstanding Invoices" of ¬ folder "HyperFile Suite Backup" of folder theHFFolderPath
set name of selection to "Outstanding Invoices.bkp"
select file "Year" of folder "HyperFile Suite Backup" of ¬ folder theHFFolderPath
set name of selection to "Year.bkp"
set prefMonthlyBkp to (monthlyBkp & ".bkp") as string
select file monthlyBkp of folder "HyperFile Suite Backup" of ¬ folder theHFFolderPath
set name of selection to prefMonthlyBkp
select folder "HyperFile Suite Backup" of folder "The HyperFile Folder"
move selection to desktop
end tell
if theBoolean = "true" then
tell application "HyperCard"
activate
display dialog ¬ "Your backup has been saved to desktop." buttons {"Done"} default button {"Done"} with icon 129 giving up after 10
end tell
end if
end suiteBkp
more HyperTalk
 Macintosh Plus (late 1984), followed close behind the Mac 512k
 The classic Apple IIc (1981), part of a series of Apple computers that preceded the debut of the Macintosh
HyperCard Users Corner:
Here's a simple, but very useful little HyperTalk script for verifying the validity of a date entered by a user, assuming that you have a menu item "flag date..." (or whatever you choose to name it) or it could be altered slightly and placed within a mouseUp statement:
if menuItem = "Flag Date..." then
global tryDate
ask "Enter a date for your new appointment:" with the long date
if it ≠ "" and the result ≠ "Cancel" then
put it into tryDate
else
put "" into tryDate
exit doMenu
end if
if invalidDate() then
answer "The date entered is not valid!"
put "" into tryDate
exit doMenu
end if
--Here you would put the statements to execute if the entered date proves to be valid
put "" into tryDate
end if
function invalidDate
global tryDate
convert tryDate to short date
if the result = "invalid date" then
return true
else
return false
end if
end invalidDate
more HyperTalk

 Mac SE (circa 1987), was a more advanced version of the Mac Plus and had an internal hard drive.
YouTube Video Search Script:
tell application "Finder"
try
set webSearch to text returned of (display dialog "Enter YouTube Video
Search" default answer "" buttons {"Search", "Cancel"} default button 1)
open location "http://www.youtube.com/results?search_query=" & webSearch
on error theError
display dialog theError
end try
end tell
|
Recent Comments