Willkommen auf der Blog-Seite von hubionmac.com!
Alles rund um AppleScript und was mich sonst noch so interessiert ;-)!

Wie bekomme ich den aktuellen Kanal der umliegenden Station heraus. AirportRadar, KisMac oder AP Grapher muss man erst mal haben und laden, womit es auch geht ist mit

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s

osxdaily hat auch diese Zeile hier zum Besten gegeben, um einen einfacheren Aufruf zu gewährleisten:

sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

Continue reading...

Das ist nur als Beispiel gedacht, wie so eine Funktion aussehen könnte:

tell application "Contacts"
    activate
    set my_phone_2_check to text returned of (display dialog "Telefonnummer:" default answer "0")
    set allp to people
    set phone_numbers to value of every phone of people
    repeat with i from 1 to count of phone_numbers
        set current_phone_numbers to item i of phone_numbers
        if (count of current_phone_numbers) > 0 then
            repeat with phone_number_2_check in current_phone_numbers
                set phone_number_2_check to phone_number_2_check as text
                if phone_number_2_check starts with "+" then
                    set phone_number_2_check to ("0" & characters 4 through -1 of phone_number_2_check) as text
                end if
                if phone_number_2_check contains " " then
                    set phone_number_2_check to my replace_chars(phone_number_2_check, " ", "")
                end if
                if phone_number_2_check contains "-" then
                    set phone_number_2_check to my replace_chars(phone_number_2_check, "-", "")
                end if
                if phone_number_2_check contains "/" then
                    set phone_number_2_check to my replace_chars(phone_number_2_check, "/", "")
                end if
                if phone_number_2_check = my_phone_2_check then
                    set selection to item i of people
                    error "Die Nummer gibt es schon"
                end if
            end repeat
        end if
    end repeat
end tell
to replace_chars(this_text, search_string, replacement_string)
    try
        if this_text contains the search_string then
            set AppleScript's text item delimiters to the search_string
            set the item_list to every text item of this_text
            set AppleScript's text item delimiters to the replacement_string
            set this_text to the item_list as string
            set AppleScript's text item delimiters to ""
        end if
        return this_text
    on error msg
        error "error on replace_chars" & return & msg
    end try
end replace_chars

Continue reading...

Ich brauchte zum testen einer optimierten Version eines Dubletten-Skripts unbedingt über 7000 Adressen, die mitunter auch mal doppelt vorkommen. Da ich nicht einmal ansatzweise so viele Personen in meiner Datenbank habe, musste halt ein Skript meinen Bekanntenkreis erweitern.


## hubionmac.com 14.01.2011

## creates radnom Apple Addressbook entries (usefull für testing)

set firstnames to {"Anna", "Hannah", "Hanna", "Lea", "Leah", "Leonie", "Lena", "Lara", "Laura", "Sarah", "Sara", "Marie", "Emily", "Emilie", "Emma", "Lilli", "Lilly", "Lili", "Sophie", "Sofie", "Johanna", "Julia", "Mia", "Nele", "Neele", "Lina", "Alina", "Lisa", "Sophia", "Sofia", "Amelie", "Luisa", "Louisa", "Maja", "Maya", "Jana", "Jasmin", "Yasmin", "Clara", "Klara", "Paula", "Katharina", "Charlotte", "Pia", "Josephine", "Josefine", "Chiara", "Annika", "Antonia", "Finja", "Celina", "Emilia", "Angelina", "Jule", "Melina", "Vanessa", "Victoria", "Viktoria", "Michelle", "Lucy", "Lucie", "Nina", "Celine", "Emely", "Emelie", "Emmely", "Franziska", "Isabel", "Isabell", "Isabelle", "Carolin", "Caroline", "Karoline", "Maria", "Pauline", "Melissa", "Marlene", "Amy", "Greta", "Merle", "Eileen", "Aileen", "Ayleen", "Aylin", "Selina", "Ronja", "Vivien", "Vivienne", "Helena", "Sina", "Sinah", "Kim", "Lia", "Liah", "Stella", "Zoe", "Ida", "Eva", "Mara", "Marah", "Carla", "Karla", "Elisa", "Jessica", "Jessika", "Larissa", "Fiona", "Luise", "Louise", "Linda", "Elena", "Lotta", "Carlotta", "Karlotta", "Alicia", "Kira", "Kyra", "Julie", "Juli", "Alexandra", "Jette", "Miriam", "Natalie", "Nathalie", "Fabienne", "Paulina", "Jolina", "Joelina", "Theresa", "Teresa", "Anne", "Christina", "Kristina", "Kimberly", "Kimberley", "Luna", "Milena", "Carina", "Karina", "Nelli", "Nelly", "Dana", "Samantha", "Elisabeth", "Annalena", "Tabea", "Rebecca", "Rebekka", "Linn", "Lynn", "Lyn", "Lucia", "Annabelle", "Annabell", "Ella", "Janina", "Saskia", "Matilda", "Mathilda", "Nicole", "Jennifer", "Lana", "Mira", "Frieda", "Frida", "Gina", "Anastasia", "Melanie", "Diana", "Chantal", "Isabella", "Helen", "Olivia", "Romy", "Martha", "Marta", "Mila", "Leni", "Lenie", "Fenja", "Liv", "Samira", "Xenia", "Svea", "Jenny", "Magdalena", "Maike", "Meike", "Nora", "Helene", "Kaja", "Kaya", "Caja", "Malin", "Marina", "Carolina", "Karolina", "Rieke", "Rike", "Ann", "Lorena", "Dilara", "Jill", "Jil", "Mariella", "Leona", "Janne", "Alissa", "Alyssa", "Maren", "Alexa", "Henriette", "Jenna", "Giulia", "Mina", "Selin", "Laila", "Layla", "Aleyna", "Felicitas", "Svenja", "Alisa", "Alena", "Lene", "Leticia", "Letizia", "Denise", "Mona", "Lenja", "Lenya", "Lilian", "Judith", "Elina", "Anny", "Anni", "Annie", "Marieke", "Marike", "Aliyah", "Aaliyah", "Ina", "Juliana", "Stefanie", "Stephanie", "Evelyn", "Evelin", "Eveline", "Jamie", "Marleen", "Marlen", "Cheyenne", "Josy", "Josie", "Rosa", "Joline", "Joeline", "Nadine", "Tessa", "Christin", "Kristin", "Lotte", "Madita", "Noemi", "Joy", "Valentina", "Tuana", "Ela", "Veronica", "Veronika", "Mareike", "Alessia", "Leyla", "Lucas", "Lukas", "Leon", "Tim", "Timm", "Luca", "Luka", "Finn", "Fynn", "Jonas", "Jan", "Niclas", "Niklas", "Felix", "Paul", "Maximilian", "Max", "Luis", "Louis", "Julian", "Philip", "Philipp", "Phillip", "Filip", "Ben", "Jannik", "Yannick", "Yannik", "Moritz", "Tom", "Nico", "Niko", "David", "Simon", "Alexander", "Elias", "Fabian", "Noah", "Jacob", "Jakob", "Justin", "Eric", "Erik", "Florian", "Lennard", "Lennart", "Nils", "Niels", "Linus", "Daniel", "Tobias", "Dominic", "Dominik", "Julius", "Sebastian", "Johannes", "Kevin", "Henri", "Henry", "Jonathan", "Jason", "Robin", "Jannis", "Janis", "Yannis", "Colin", "Collin", "Benjamin", "Anton", "Marc", "Mark", "Vincent", "Timo", "Mika", "Hannes", "Joshua", "Marlon", "Til", "Till", "Adrian", "Joel", "Pascal", "Ole", "Lasse", "Rafael", "Raphael", "Marcel", "Constantin", "Konstantin", "Dennis", "Denis", "Lars", "Leo", "Leonard", "Carl", "Karl", "Aaron", "Maurice", "Christian", "Kristian", "Justus", "Jona", "Jonah", "Oskar", "Oscar", "Malte", "Kilian", "Oliver", "John", "Liam", "Maik", "Meik", "Mike", "Emil", "Johann", "Benedikt", "Bastian", "Bennet", "Bennett", "Malik", "Marco", "Marko", "Samuel", "Levin", "Luke", "Luc", "Luk", "Maxim", "Cedric", "Cedrik", "Gabriel", "Noel", "Fabio", "Nick", "Jeremy", "Jeremie", "Michael", "Jannes", "Phil", "Hendrik", "Kaan", "Richard", "Marvin", "Marwin", "Julien", "Lennox", "Jamie", "Kai", "Kay", "Mats", "Torben", "Thorben", "Silas", "Michel", "Valentin", "Marius", "Timon", "Thomas", "Tomas", "Dustin", "Manuel", "Robert", "Artur", "Arthur", "Bruno", "Mohammed", "Tristan", "Christopher", "Markus", "Marcus", "Damian", "Martin", "Patrick", "Matthis", "Mattis", "Mathis", "Laurens", "Laurenz", "Leander", "Ian", "Theo", "Steven", "Christoph", "Arne", "Matthias", "Mathias", "Matti", "Conner", "Connor", "Nicolas", "Nikolas", "Lorenz", "Jasper", "Ali", "Laurin", "Andreas", "Kjell", "Lenny", "Lenni", "Sven", "Swen", "Matteo", "Jean", "Ruben", "Chris", "Friedrich", "Henrik", "Henrick", "Frederic", "Frederik", "Magnus", "Milan", "Clemens", "Klemens", "Bjarne", "Stefan", "Stephan", "Leandro", "Henning", "Thore", "Tore", "Melvin", "Fritz", "Can", "Tyler", "Tayler", "Leif", "Roman", "Toni", "Tony", "Antonio", "Peter", "Sam", "Kian", "Arda", "Franz", "Quentin", "Leonardo", "Danny", "Enrico", "Finnley", "Finley", "Finlay", "Ferdinand", "Miguel", "Diego", "Carlo", "Karlo", "Levi", "Anthony", "Mert", "Jayden", "Piet", "Victor", "Viktor", "Dario", "Sascha", "Pepe", "Alex", "Dean", "Mirco", "Mirko", "Len", "Lenn", "Hans"}

set lastnames to {"Mueller", "Richter", "Schneider", "Mueller", "Krueger", "Richter", "Schmidt", "Richter", "Lange", "Mueller", "Schulz", "Neumann", "Mueller", "Schmidt", "Meyer", "Mueller", "Richter", "Schneider", "Mueller", "Schneider", "Wagner", "Schmidt", "Schulze", "Richter", "Schmidt", "Fischer", "Koch", "Mueller", "Richter", "Schneider", "Mueller", "Wolf", "Ludwig", "Mueller", "Schneider", "Wolf", "Schmidt", "Fischer", "Hoffmann", "Schmidt", "Schulz", "Lange", "Schmidt", "Schulz", "Schneider", "Schmidt", "Schulz", "Krueger", "Mueller", "Weber", "Meyer", "Mueller", "Schulz", "Richter", "Mueller", "Herrmann", "Schulze", "Schmidt", "Schulz", "Richter", "Mueller", "Schulz", "Richter", "Herrmann", "Mueller", "Moeller", "Mueller", "Schneider", "Wagner", "Schmidt", "Krueger", "Lange", "Mueller", "Schroeder", "Schulz", "Mueller", "Weber", "Buhmann", "Meyer", "Mueller", "Becker", "Schmidt", "Schulz", "Hansen", "Schmidt", "Meyer", "Schulz", "Schmidt", "Meyer", "Schneider", "Schmidt", "Petersen", "Meyer", "Duhse", "Fischer", "Mueller", "Schmidt", "Hansen", "Schroeder", "Brahmst", "Hansen", "Mueller", "Petersen", "Fischer", "Schroeder", "Schmidt", "Mueller", "Peters", "Meyer", "Schulz", "Schneider", "Meyer", "Herrmann", "Lange", "Meyer", "Schmidt", "Koch", "Schmidt", "Lange", "Weber", "Schmidt", "Spoerl", "", "Meyer", "Mueller", "Schroeder", "Mueller", "Schulze", "Meyer", "Mueller", "Schmitz", "Schneider", "Schmidt", "Schmitz", "Becker", "Mueller", "Schmitz", "Schneider", "Schmidt", "Schaefer", "Wagner", "Weber", "Meyer", "Wolf", "Schmidt", "Wagner", "Koch", "Schmidt", "Wagner", "Weber", "Schmidt", "Gundermann", "Bauer", "Schmidt", "Riek", "Stange", "Scholta", "Lange", "", "Mueller", "Schulz", "Schroeder", "Schmidt", "Koch", "Fischer", "Schmidt", "Herrmann", "Schulz", "Schmidt", "Mueller", "", "Becker", "Ollenhauer", "Wendt", "Schmidt", "Schmitz", "Schneider", "Schmitz", "Schmidt", "Lachher", "Schmidt", "Fischer", "Mathey", "Mueller", "Schneider", "Becker", "Mueller", "Lange", "Schaefer", "Schneider", "Mueller", "Schmidt", "Mueller", "Fischer", "Herrmann", "Mueller", "Bucher", "Schwarz", "Meyer", "Schuermann", "Dura", "Meyer", "Mueller", "Herrmann", "Mueller", "Pannek", "Schmidt", "Schmidt", "Mueller", "Schneider", "Schmitz", "Preis", "Schneider", "Mueller", "Schneider", "Becker", "Jansen", "Schmitz", "Boden", "Mueller", "Schneider", "Schumacher", "Mueller", "Schneider", "Schaefer", "Schmitz", "Schmitt", "Becker", "Schmidt", "Mueller", "Wagner", "Mueller", "Schmidt", "Klein", "Mueller", "Fischer", "Schaefer", "Schneider", "Spies", "Dickfoss", "Schmidt", "Henkemeier", "Becker", "Becker", "Schmidt", "Schaefer", "Mueller", "", "", "Schmidt", "Schneider", "Wagner", "Hartmann", "Baer", "Schmidt", "Mueller", "Weber", "Schmitt", "Mueller", "Bauer", "Wagner", "Schmidt", "Weber", "Fischer", "Schmidt", "Weber", "Herrmann", "Schneider", "Weber", "Schmidt", "Schmidt", "Mueller", "Schneider", "Wagner", "Mueller", "Weber", "Mueller", "Koch", "Fischer", "Mueller", "Fischer", "Frank", "Kroha", "Helmschrodt", "Mueller", "Mueller", "Herrmann", "Weber", "Becker", "Schmitt", "Mueller", "Mueller", "Schneider", "Schmid", "Mueller", "Schmid", "Schneider", "Schmid", "Maier", "Schneider", "Fischer", "Schmid", "Schneider", "Wagner", "Fischer", "Schneider", "Mueller", "Schaefer", "Krause", "Mueller", "Schneider", "Schmidt", "Mueller", "Braun", "Kraus", "Mueller", "Braun", "Bayer", "Mueller", "Weber", "Fischer", "Mueller", "Schmidt", "Kaiser", "Mueller", "Huber", "Fischer", "Mueller", "Herrmann", "Fischer", "Wagner", "Schmidt", "Huber", "Huber", "Schmidt", "Woltering", "Huber", "Fischer", "Maier", "Mueller", "Fischer", "Schneider", "Mueller", "Schneider", "Huber", "Mueller", "Schmid", "Schneider", "Mueller", "Fischer", "Baumann", "Mueller", "Klein", "Wagner", "Schmid", "Wolf", "Grabovac", "Mueller", "Speer", "Koch", "Mueller", "Wagner", "Bauer", "Schmidt", "Wagner", "Kraus", "Fischer", "Bauer", "Halbeck", "Schmidt", "Schmid", "Wagner", "Huber", "Bauer", "Schneider", "Schmidt", "Weiss", "Fischer", "Mueller", "Detsch", "Schmitt", "Sommer", "Wagner", "", "Mueller", "Schmidt", "Schmitt", "Mueller", "Fischer", "Habermann", "Schmidt", "Jaeger", "Paal", "Mueller", "Wolf", "Mensch"}

set firstname_count to count of firstnames
set lastname_count to count of lastnames
set loopcount to (text returned of (display dialog "New Address-Count:" default answer "100")) as integer

repeat with i from 1 to loopcount
set firstname to item (random number from 1 to firstname_count) of firstnames
    set lastname to item (random number from 1 to lastname_count) of lastnames
    tell application "Contacts"
        set theperson to make new person with properties {first name:firstname, last name:lastname}
    end tell
end repeat
tell application "Contacts" to save

Continue reading...

Wenn man im Apple Adressbuch Kontakte als vCard exportieren möchte, erstellt das Programm bei mehreren Kontakten anscheinend immer nur eine Datei, in der alle Informationen stehen… FALSCH, mit gedrückter alt-Taste erstellt das Programm auf Wunsch auch separate VCF-Dateien für jeden Kontakt (siehe Kommentare)…. somit kann man sich das Weiterlesen eigentlich sparen…Nun, dieses Skript (quick&dirty) exportiert die Kontakte in einzelne .vcf Dateien

--hubionmac.com 06.02.2011
--quick&dirty script for exporting contacts as single vCards
--exisiting vCards will not be overwritten by the script, instead new files will 
--get an index like "John Smith 1.vcf"

set doThese to get_item_2_process(true)
tell application "Contacts"
    set destination_path to choose folder with prompt "Destination folder for export:"
    repeat with doThis in doThese
        if first name of doThis is missing value then
            set firstname to ""
        else
            set firstname to first name of doThis
        end if
        if last name of doThis is missing value then
            set lastname to ""
        else
            set lastname to last name of doThis
        end if
        if (lastname & firstname) as text = "" then
            set namestring to "nobody.vcf"
        else
            set namestring to (first name of doThis & " " & last name of doThis & ".vcf") as text
        end if
        set namestring to my checkname_with_pdf_suffix(namestring, destination_path, false)
        my writeToFile((destination_path as text) & namestring as text, (get vcard of doThis), false)
    end repeat
    my display_message(((count of doThese) & " contact(s) exported") as text, 3)
end tell
on writeToFile(MacFilePathTxt, txt, add2eof)
    --lastedit 18.01.2011
    if add2eof is false then
        try
            do shell script "rm " & quoted form of POSIX path of (MacFilePathTxt as alias)
        end try
    end if
    set RefNum to (open for access file MacFilePathTxt with write permission)
    try
        if add2eof is false then
            write txt to RefNum
        else
            write txt to RefNum starting at ((get eof RefNum) + 1)
        end if
        close access RefNum
        return true
    on error
        close access RefNum
        return false
    end try
end writeToFile

to get_item_2_process(askwhat)
    try
        tell application "Contacts"
            activate
            tell application "System Events"
                keystroke "0" using command down --show address-window not matter what…
            end tell
            if askwhat is true then
                set theaction to button returned of (display dialog "Process all or just selection?" buttons {"All", "Selection", "cancel"} default button {"Selection"})
                if theaction = "Selection" then
                    set a to every person whose selected is true
                else
                    set a to people
                end if
            else
                set a to people
            end if
        end tell
    on error msg
        error "error on get_item_2_process" & return & msg
    end try
end get_item_2_process

to checkname_with_pdf_suffix(n, D, looped)
    --check if filename exists in D
    --so if "A File.pdf" exists it names it "A File 1.pdf","A File 2.pdf",…
    tell application "Finder"
        set thefiles to name of every item of (D as alias)
    end tell
    if thefiles contains n then
        if looped = false then
            set n to ((characters 1 through -5 of n) & " 1" & (characters -4 through -1 of n)) as text
            my checkname_with_pdf_suffix(n, D, true)
        else
            set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)
            set tmpcount to (count of characters of (tmp as text)) + 5
            set tmp to tmp + 1
            set n to ((characters 1 through (-1 * tmpcount) of n) & tmp & (characters -4 through -1 of n)) as text
            my checkname_with_pdf_suffix(n, D, true)
        end if
    else
        return n
    end if

end checkname_with_pdf_suffix
on display_message(msgTXT, msgTimeout)
   tell application "System Events"
        set isRunning to ¬
            (count of (every process whose name is "GrowlHelperApp")) > 0
    end tell
    if isRunning = true then
        tell application "GrowlHelperApp"
            — Make a list of all the notification types 

            — that this script will ever send:

            set the allNotificationsList to ¬

                {"Status"}

            — Make a list of the notifications 

            — that will be enabled by default.      

            — Those not enabled by default can be enabled later 

            — in the ‘Applications’ tab of the growl prefpane.

            set the enabledNotificationsList to ¬

                {"Status"}

            — Register our script with growl.

            — You can optionally (as here) set a default icon 

            — for this script’s notifications.

            register as application ¬

                "Address Book" all notifications allNotificationsList ¬

                default notifications enabledNotificationsList ¬

                icon of application "Address Book"

            --Send a Notification…

            notify with name ¬

                "Status" title ¬

                "Status" description ¬

                msgTXT application name ¬

                "Address Book"

            return true

        end tell

    else

        activate

        display dialog msgTXT giving up after msgTimeout

    end if

end display_message

Continue reading...

Die ursprüngliche Version konnte mit iTunes 8 und 9 noch funktionieren… mit iTunes 10 hat sich das GUI wieder etwas geändert. Fall-Line hatte sich der Aktualisierung bereits angenommen, diese Version sollte aber unter jeder System-Sprache funktionieren.
Zudem hat das Skript noch ein kleines Update erfahren. Man kann eine Konfiguration vorgeben oder ohne Vorgabe die aktuelle Einstellung in iTunes einfach nur switchen…

--Airtunes - Switch - Config - script
(**hubionmac.com 10.09.2010
for addition info: http://hubionmac.com/wordpress/?p=2303
orig. Version by http://fall-line.com/2010/09/control-airplayairtunes-feature-of-itunes-with-applescript/
if check_these und uncheck_these = {} then your
Airtunes-Config will be switched the other way around….
Makes use of GUI-Skripting, hopefully Apple will add native AppleScript-Support in iTunes for
Airtunes some day 
**)
set check_these to {} --something like {"Name of Your Air-TunesDevice"}
set uncheck_these to {} --something like {"Computer"}
my check_gui_scripting_is_active()
my check_if_iTunes_window_visible()
my press_speaker_button_and_open_all_speakers()
my check_boxes_and_close_window(check_these, uncheck_these)
on press_speaker_button_and_open_all_speakers()
    tell application "iTunes"
        activate
        tell application "System Events"
            tell application process "iTunes"
                click button 8 of window "iTunes" --Press the iTunes 10 Speaker Button
                key code 125 using {command down} --this is essentiall hitting page down (command + down arrow)
                delay 1
                keystroke return
                delay 1
            end tell
        end tell
    end tell
end press_speaker_button_and_open_all_speakers
on check_boxes_and_close_window(check_these, uncheck_these)
    --if check_these und uncheck_these = {} then your
    --Airtunes-Config will be switched the other way around….
    tell application "iTunes"
        activate
        tell application "System Events"
            tell application process "iTunes"
                tell window 1
                    tell table 1 of scroll area 1
                        set check_computer_allowed to false
                        repeat with i from (count of every row) to 1 by -1 -- Itterate through each row, looking for the criteria below
                            set rowcount to count of rows
                            set a to rowcount
                            if rowcount > 0 then
                                tell group 1 of row i
                                    activate -- Drill into the object group of each row, so we don’t have to later.
                                    -- If "Speaker in Room A" is turned off (value of checkbox 1 = 0), turn it on. Otherwise do nothing
                                    if check_these is {} and uncheck_these = {} then
                                        if i > 1 and value of checkbox 1 as integer = 0 then
                                            set check_computer_allowed to true
                                        end if
                                        if i > 1 then
                                            click checkbox 1
                                        else
                                            if check_computer_allowed is true then
                                                click checkbox 1
                                            end if
                                        end if
                                    else
                                        if (description of checkbox 1) is in check_these and value of checkbox 1 as integer = 0 then
                                            click checkbox 1
                                        end if
                                        if (description of checkbox 1) is in uncheck_these and value of checkbox 1 as integer = 1 then
                                            click checkbox 1
                                            set a to (description of checkbox 1)
                                        end if
                                    end if
                                end tell
                            end if
                        end repeat
                    end tell
                end tell
            end tell
        end tell
        close window 1
    end tell
end check_boxes_and_close_window
on check_if_iTunes_window_visible()
    tell application "iTunes"
        activate
        tell application "System Events"
            tell application process "iTunes"
                --check if itunes Window is frontmost
                if (count of every window) = 0 or (name of window 1 ≠ "iTunes") then
                    keystroke "1" using {command down, option down}
                end if
            end tell
        end tell
    end tell
end check_if_iTunes_window_visible
to check_gui_scripting_is_active()
    tell application "System Events" to set isUIScriptingEnabled to UI elements enabled
    if isUIScriptingEnabled = false then
        tell application "System Preferences"
            activate
            set current pane to pane "com.apple.preference.universalaccess"
            display dialog "Your system is not properly configured to run this script.
         Please select the \"Enable access for assistive devices\"
         checkbox and trigger the script again to proceed."
            return
        end tell
    end if
end check_gui_scripting_is_active

Continue reading...