<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>hubionmac.com</title> <atom:link href="http://hubionmac.com/wordpress/feed" rel="self" type="application/rss+xml" /><link>http://hubionmac.com/wordpress</link> <description>script the unscriptable</description> <lastBuildDate>Thu, 17 May 2012 07:27:58 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Outlook: Kalender Kategorien setzen</title><link>http://hubionmac.com/wordpress/archives/3278</link> <comments>http://hubionmac.com/wordpress/archives/3278#comments</comments> <pubDate>Sat, 12 May 2012 08:05:58 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[Outlook]]></category> <category><![CDATA[category]]></category> <category><![CDATA[label]]></category> <category><![CDATA[outlook]]></category> <category><![CDATA[tags]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3278</guid> <description><![CDATA[Exportiert man einen lokalen Kalender aus iCal und öffnen diesen in Outlook, wird dieser direkt hinzugefügt, nur wird man nicht gefragt, welcher Kategorie die neuen Einträge zugeordnet werden sollen. Das ist bei Kalendern, die nur über 12 Monate gehen nicht weiter schlimm, schließlich gibt es ja eine Listenansicht. Für größere Kalender mit Events über mehrere [...]]]></description> <content:encoded><![CDATA[Exportiert man einen lokalen Kalender aus iCal und öffnen diesen in Outlook, wird dieser direkt hinzugefügt, nur wird man nicht gefragt, welcher Kategorie die neuen Einträge zugeordnet werden sollen. Das ist bei Kalendern, die nur über 12 Monate gehen nicht weiter schlimm, schließlich gibt es ja eine Listenansicht. Für größere Kalender mit Events über mehrere Jahre ist diese Script hier gedacht, es setzt die Kategorie alle Events ohne Kategorie auf einen wählbaren Wert. Das besondere dabei ist das Ermitteln der <em>category id</em>.<p><pre class="Plum_Code_Box"><code class="">## 2012-05-07 hubionmac.com
## Setzt die Kateorie aller Events ohne Kategorie auf einen Ausw&auml;hlbaren Wert
tell application &quot;Microsoft Outlook&quot;
  ##Ziel-Kategrorie abfragen und ID ermitteln
  set cat_names to {}
  set cat_ids to id of every category
  set i to 0
  repeat with cat_id in cat_ids
    set i to i + 1
    set cat_names to cat_names &amp; (i &amp; &quot;: &quot; &amp; (get name of category id cat_id) as text)
  end repeat
  set theid to item (word 1 of ((choose from list cat_names with prompt &quot;Kaegorie ausw&auml;hlen:&quot;) as text) as integer) of cat_ids
  set setcounter to 0
  ##Das Skript geht davon aus, dass es sich um den 2. Kalender handelt, (Exchange)
  tell calendar 2
    repeat with thevent in (get every calendar event)
      if (get category of thevent) = {} then
        set category of thevent to {category id theid of application &quot;Microsoft Outlook&quot;}
        set setcounter to setcounter + 1
      end if
    end repeat
    display dialog &quot;Die Kategorien von &quot; &amp; setcounter &amp; &quot; Events wurde gesetzt.&quot;
  end tell
  
end tell
</code>
									</pre></p> ]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3278/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Wie lösche ich &#8220;unwiederbringlich&#8221; meinen Schreibtisch per Skript</title><link>http://hubionmac.com/wordpress/archives/3267</link> <comments>http://hubionmac.com/wordpress/archives/3267#comments</comments> <pubDate>Tue, 17 Apr 2012 12:28:11 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[NERV!]]></category> <category><![CDATA[AppleScript]]></category> <category><![CDATA[attachments]]></category> <category><![CDATA[delete]]></category> <category><![CDATA[mail]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3267</guid> <description><![CDATA[Es gibt sicherlich direkte Methoden, doch ich wählte heute eine ganz besondere. Beim Testen von einem Skript schrieb ich folgenden Code: set thepath to path to &#34;desk&#34; tell application &#34;Mail&#34; repeat with a in (get selection) repeat with b in (get every mail attachment of a) display dialog (thepath &#38; &#34;dd.scrpt&#34; as rich text) --save [...]]]></description> <content:encoded><![CDATA[Es gibt sicherlich direkte Methoden, doch ich wählte heute eine ganz besondere. Beim Testen von einem Skript schrieb ich folgenden Code:<p><pre class="Plum_Code_Box"><code class="">set thepath to path to &quot;desk&quot;
tell application &quot;Mail&quot;
  repeat with a in (get selection)
    repeat with b in (get every mail attachment of a)
      display dialog (thepath &amp; &quot;dd.scrpt&quot; as rich text)
      --save b in (thepath as rich text)
    end repeat
  end repeat
end tell
</code>
									</pre></p> Die verheerende Zeile habe ich sicherheitshalber mal auskommentiert. Nun, durch diese Zeile löschte mir Apple Mail auf einen Schlag den gesamten Schreibtisch =) Ich wollte heute ja auch noch etwas die Platte aufräumen... so ging das recht schnell. Aber zahlreiche Gigabyte an Daten (ich habe eine Backup, man ist ja Profi ;-) ) sollen nicht umsonst gelöscht und wiederhergestellt worden sein, das Skript zum <a href="http://hubionmac.com/wordpress/archives/2087">Speichern von Emails als PDF nebst deren Anhängen</a> funktioniert nun wieder unter 10.7, und das ohne den Schreibtisch zu löschen =) ]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3267/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Mail: Wordcount einer neuen Email</title><link>http://hubionmac.com/wordpress/archives/3259</link> <comments>http://hubionmac.com/wordpress/archives/3259#comments</comments> <pubDate>Sun, 15 Apr 2012 21:13:25 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[Apple Mail]]></category> <category><![CDATA[system events]]></category> <category><![CDATA[wordcount]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3259</guid> <description><![CDATA[Via Script auf neue noch nicht verschickte Email-Nachrichten zuzugreifen ist in Mail (wohl auch noch unter V 5.2) nicht so ohne weiteres möglich. Stattdessen muss man sich mit UI-Scripting weiterhelfen, um sich z.B. die Anzahl der Worte des just verfassten Nachrichten-Textes anzeigen zu lassen. tell application &#34;Mail&#34; to display alert (&#34;Wordcount: &#34; &#38; my return_wordcount_new_mail_window()) [...]]]></description> <content:encoded><![CDATA[<a href="http://www.fischer-bayern.de/phpBB2/viewtopic.php?t=3320" title="Beitrag im Fischer-Bayern Forum, der eigentliche Grund" target="_blank">Via Script</a> auf neue noch nicht verschickte Email-Nachrichten zuzugreifen ist in Mail (wohl auch noch unter V 5.2) nicht so ohne weiteres möglich. Stattdessen muss man sich mit UI-Scripting weiterhelfen, um sich z.B. die Anzahl der Worte des just verfassten Nachrichten-Textes anzeigen zu lassen.<p><pre class="Plum_Code_Box"><code class="">tell application &quot;Mail&quot; to display alert (&quot;Wordcount: &quot; &amp; my return_wordcount_new_mail_window())
on return_wordcount_new_mail_window()
  tell application &quot;Mail&quot; to activate
  ##new mail window in apple mail 5.2 (Lion 10.7.3)
  tell application &quot;System Events&quot;
    get system attribute &quot;sysv&quot;
    if result is greater than or equal to 4144 then -- Mac OS X 10.3.0
      if UI elements enabled then
        tell application process &quot;Mail&quot;
          try
            return count of every word of (get value of static text 1 of group 1 of UI element 1 of scroll area 4 of window 1)
          on error
            return &quot;got an error&quot;
          end try
        end tell
      else
        beep
        display dialog &quot;GUI Scripting is not enabled&quot; &amp; return &amp; return &amp; &quot;Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again.&quot; with icon stop
        if button returned of result is &quot;OK&quot; then
          tell application &quot;System Preferences&quot;
            activate
            set current pane to pane &quot;com.apple.preference.universalaccess&quot;
          end tell
        end if
      end if
    else
      beep
      display dialog &quot;This computer cannot run this script&quot; &amp; return &amp; return &amp; &quot;The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer.&quot; with icon caution buttons {&quot;Quit&quot;} default button &quot;Quit&quot;
    end if
  end tell
end return_wordcount_new_mail_window</code>
									</pre></p> Ich habe den Code unter 10.7.3 getestet, es kann aber sein, dass er bei Umstellung des Mail-GUIs (bei einer älteren oder neueren Version) nicht funktioniert... die Tücken des UI-Scriptings halt ;-)]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3259/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Tips: Shortcuts und defaults</title><link>http://hubionmac.com/wordpress/archives/3251</link> <comments>http://hubionmac.com/wordpress/archives/3251#comments</comments> <pubDate>Fri, 06 Apr 2012 12:18:26 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[Apple Mail]]></category> <category><![CDATA[Shortcuts]]></category> <category><![CDATA[Spotlight]]></category> <category><![CDATA[spotlight]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3251</guid> <description><![CDATA[Ich liebe Shortcuts! Einem Rechner durch Gesten gewünschte Arbeitsschritte mitzuteilen, ist ja ziemlich praktisch, doch wer jeden Tag mit der Kiste arbeitet, der sehnt sich vielleicht schon mal nach einer einfacheren Methode z.B. Dateien in Emails einzufügen. Rein vom Ansatz her hat Apple es da auch gut in OSX umgesetzt und so ist vieles, was [...]]]></description> <content:encoded><![CDATA[<p>Ich liebe Shortcuts! Einem Rechner durch Gesten gewünschte Arbeitsschritte mitzuteilen, ist ja ziemlich praktisch, doch wer jeden Tag mit der Kiste arbeitet, der sehnt sich vielleicht schon mal nach einer einfacheren Methode z.B. Dateien in Emails einzufügen. Rein vom Ansatz her hat Apple es da auch gut in OSX umgesetzt und so ist vieles, was mit <strong>Drag&amp;Drop</strong> funktioniert auch via <strong>Copy&amp;Paste</strong> zu erledigen. Das Funktioniert besonders gut mit Texten und Dateien. Kopiert man eine Datei im Finder (cmd+c), kann man diese dann in Mail auch ganz einfach an eine Email anhängen (cmd+v).<br />In Lion scheint das ganze auch <strong>in Spotlight</strong> zu <a title="OSX Hints" href="http://hints.macworld.com/article.php?story=2012040500202573" target="_blank">funktionieren</a>. Wählt man eine Datei aus dem Suchergebnis aus, kann man diese via Drag&amp;Drop also auch via Copy&amp;Paste kopieren und in eine Email einfügen, so wie <a title="YouTube" href="https://www.youtube.com/watch?v=HkwNtzgCkRA" target="_blank">hier</a>.</p><p>Ein weitere cooler Tip zu dem Thema ist die <a title="Shortcuts" href="https://support.apple.com/kb/HT1343" target="_blank">Shortcut-Sammlung von Apple</a>, wenngleich ich die nur in Programme funktionieren, die auch die korrekten Funktionen verbaut haben und nicht wie Adobe gerne auch mal eigene Klassen für Text-Felder&amp;Co verwenden.</p><p></p><p>Und was auch wunderbar hilft, den Alltag etwas einfach zu gestallten ist die richtige Einstellung, nicht nur vor dem Rechner, sondern auch im System. Diese von Apple aber nicht immer öffentlich (also via GUI) zugänglichen Einstellungen verhindern das Anlegen von unsichtbaren .DS_Store-Dateien auf Netzwerk-Shares oder lassen das Dock 2D-Look erscheinen... und weil das wirklich ein Schatz sein kann, habe ich <a title="Defaults List" href="https://github.com/mathiasbynens/dotfiles/blob/master/.osx" target="_blank">die Seite</a> hier auch noch einmal als <a title="Defaults " href="http://hubionmac.com/wordpress/wp-content/uploads/2012/04/job_109-_osx.pdf" target="_blank">PDF</a> angehängt, quasi als dezentrale Datensicherung =)</p>]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3251/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Terminal: Kennworte ändern</title><link>http://hubionmac.com/wordpress/archives/3220</link> <comments>http://hubionmac.com/wordpress/archives/3220#comments</comments> <pubDate>Tue, 27 Mar 2012 01:42:58 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[OS X]]></category> <category><![CDATA[terminal]]></category> <category><![CDATA[change password]]></category> <category><![CDATA[directory services]]></category> <category><![CDATA[keychain]]></category> <category><![CDATA[shell]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3220</guid> <description><![CDATA[Ich habe gerade ein paar schöne neue Tricks gefunden, wie man Kennworte via Terminal ändern kann. Das User-Kennwort nicht etwa via passwd sonder über dscl . -passwd /Users/customer thenewpassword Und jetzt kommt eigentlich der Oberhammer, ich habe gedacht, seitdem Keychain-Access aus dem OS entfernt wurde, könnte AppleScript gar nicht mehr auf den Schlüsselbund zugreifen, aber [...]]]></description> <content:encoded><![CDATA[Ich habe gerade ein paar schöne neue Tricks gefunden, wie man Kennworte via Terminal ändern kann. Das User-Kennwort nicht etwa via <em>passwd</em> sonder über <code>dscl . -passwd /Users/customer thenewpassword</code> Und jetzt kommt eigentlich der <a href="http://www.maclovin.de/2010/02/access-os-x-keychain-from-terminal/" title="Blog entry about Security terminal app" target="_blank">Oberhammer</a>, ich habe gedacht, seitdem Keychain-Access aus dem OS entfernt wurde, könnte AppleScript gar nicht mehr auf den Schlüsselbund zugreifen, aber weit gefehlt. Es geht über ein Terminal-Programm mit dem Namen <em>security</em>, also einfach <code>security find-internet-password -s hubionmac.com | grep "acct" | cut -d '"' -f 4</code> für den ersten Login-Namen für hubionmac.com und <code>security -v 2>&#038;1 >/dev/null find-internet-password -gs hubionmac.com | cut -d '"' -f 2</code> für das Kennwort... Jetzt muss ich nur noch herausfinden, wie es hinbekomme, dass ich das ohne Abfrage-Dialog "security möchte auf den Schlüsselbund zugreifen..." laufen lasse und zwar so, dass ich das auf das Skript beschränke kann und nicht pauschal alle Zugriffe von security freischalte...]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3220/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>InsertLinks from Dropbox and YouTube</title><link>http://hubionmac.com/wordpress/archives/3202</link> <comments>http://hubionmac.com/wordpress/archives/3202#comments</comments> <pubDate>Sun, 25 Mar 2012 12:26:48 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[Things I add to a new system]]></category> <category><![CDATA[Useful Snippets]]></category> <category><![CDATA[dropbox]]></category> <category><![CDATA[insert]]></category> <category><![CDATA[links]]></category> <category><![CDATA[youtube]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3202</guid> <description><![CDATA[Ein Bekannter verschickt immer mal wieder Emails mit Info-Material an Interessenten und hat bisher die Dateien auch direkt an die entsprechende Email angehängt. Dabei entstanden schon einmal 20MB Pakete, die er durch seinen ländlichen DSL-Anschluss mühsam treiben musste. In Zeiten von DropBox und YouTube macht es aber da mehr Sinn, statt der Dateien einen Public-Link [...]]]></description> <content:encoded><![CDATA[<p>Ein Bekannter verschickt immer mal wieder Emails mit Info-Material an Interessenten und hat bisher die Dateien auch direkt an die entsprechende Email angehängt. Dabei entstanden schon einmal 20MB Pakete, die er durch seinen ländlichen DSL-Anschluss mühsam treiben musste. In Zeiten von DropBox und YouTube macht es aber da mehr Sinn, statt der Dateien einen Public-Link und statt Video-Dateien in Format-XY einen YouTube-Link zu verschicken, die Infos sind ja keine Staatsgeheimnisse. Zudem muss er keine übergroßen Emails verschicken und die Mailbox des Empfängers quillt nicht über.</p><span id="more-3202"></span><p>Nur das einfügen dieser Links in eine Email ist etwas umständlich, die YoutTube-Links holt man sich von deren Seite und die öffentlichen Dropbox Links kann man sich über einen Rechts-Klick in einem Untermenü in die Zwischenablage kopieren lassen. Das dauert in Summe doch schon recht lange und wenn immer mal wieder neue Dateien hinzukommen, müssen vorbereitete Textbausteine (das gilt wohl auch für Text-Expander) auch erst mal gepflegt werden. Aus dieser Situation ist mir die Idee für ein <strong>InsertLink Skript</strong> gekommen, welches die Liste der Links selber erzeugt und zur Auswahl anbietet.</p><h1>Die Voreinstellungen:</h1><p>Startet man das Skript zum ersten Mal, möchte es die <strong>Public-ID der Dropbox</strong>, sowie den Namen des YouTube-Kanals wissen. Damit man sich nicht selber die ID aus der URL-kopieren muss, kopiert man sich einfach einen x-beliebigen Public-Link der Dropbox in die Zwischenablage und startet das Skript. Handelt es sich bei dem String in der Zwischenablage um einen Public-Link (<em>http://dl.dropbox.com/u/...</em>) bedient sich das Skript und trägt die Public-ID in die Voreinstellungen ein. Danach wird noch der <strong>YouTube Channel-Name</strong> abgefragt und fertig sind die Einstellungen.</p><h1>Die Funktionsweise bei Dropbox:</h1><p>Ich wollte das Ding jetzt nicht über das API auf die Drop-Box zugreifen lassen, das wäre für eine reine Datei-Liste echter Overkill und da sich der Download-Link neben dem Dateinamen nur durch eine bestimmte Public-ID unterscheidet reicht es dem Skript den Pfad der Datei und die ID zu geben. Für die Suche nach der Datei habe ich einen <strong>Pseudo-AppleScript-Datei-Browser</strong> entworfen, der über einfache Auswahllisten eine schnelle Navigationen durch die Untiefen des Public-Dropbox-Ordners erlaubt. Hat man eine oder mehrere Dateien gefunden, kann man diese Auswählen und die entsprechenden Public-Dropbox-Links werden vom Skript erzeugt (inkl. <strong>URL-Encoding</strong> der Sonderzeichen) und an der Cursor-Position eingefügt.</p><h1>Die Funktionsweise bei YouTube:</h1><p>Hier mache ich mir die Ausgabe eines <strong>XML-Feeds</strong> zu Nutze, das Skript braucht nur einen Benutzernamen und ruft sich die 25 aktuellsten Filme des Kanals (Titel und URL) als Atom-Feed ab, wenn man weiter zurückgehen möchte, lädt das Skript auch weitere ältere Filme in die Liste. Hier kann man dann auch einen oder mehrere Filme auswählen und die Titel werden nebst URL, <strong>an der aktuellen Cursor-Position eingefügt</strong>.</p><hr /><h1>Für den visuellen Typen</h1><p>Viele Worte und deshalb gibt es auch <a href="https://www.youtube.com/watch?v=AYOabebhkco" title="Youtube Video: Demo InsertLinks" target="_blank">einen Film</a> dazu ;-)</p><p><h1>Aso und der Code</h1><p><pre class="Plum_Code_Box"><code class="">--25.03.2012 hubionmac.com
--Script for inserting Public-Dropbox links and Links to films of your Youtube-Channel into an email or any other text-field
--26.03.2012
-- removed properties from code, there do not help, only when you want to store real constant values&hellip; the path to you home dir isn&#039;t
-- changed typeThis handler, so it uses the clipboard instead, this kills your clipboard contents on every run, but it works 100%
-- tweaked the file-browser-handler a bit, so that the paths are 100% absolute without any ../ in it
-- set selection of lists to first item of list  per default
-- added intervall_passed handler and set the update intervall of the xml feed to 900sec (15min), so the script remembers the xml-feed for 15min and does not load it on every run
property plist : &quot;com.hubionmac.hubis_insertlink&quot;
set DropBoxPublicFolder to (POSIX path of (get path to &quot;cusr&quot;) &amp; &quot;Dropbox/Public/&quot;)
set StandardPublicLinkURL to &quot;http://dl.dropbox.com/u/&quot;
set dropbox_public_ID to &quot;&quot;
set current_timestamp to do shell script &quot;perl -e &#039;print time.\&quot;\\n\&quot;;&#039;&quot;
-- GET THE DROPBOX ID
try
  set dropbox_public_ID to do shell script &quot;defaults read &quot; &amp; plist &amp; &quot; &#039;Dropbox plublic ID&#039;&quot;
on error
  try
    set tcb to the clipboard as text
    if tcb starts with &quot;http://dl.dropbox.com/u/&quot; then
      set dropbox_public_ID to (characters ((count of every character of &quot;http://dl.dropbox.com/u/&quot;) + 1) through -1 of tcb) as text
      set dropbox_public_ID to (characters 1 through ((offset of &quot;/&quot; in dropbox_public_ID) - 1) of dropbox_public_ID) as text
      do shell script &quot;defaults write &quot; &amp; plist &amp; &quot; &#039;Dropbox plublic ID&#039; &quot; &amp; dropbox_public_ID
      display alert dropbox_public_ID &amp; &quot; was saved as yout DropBox ID in the preferences.&quot; as informational giving up after 2
    else
      error
    end if
  on error
    display alert &quot;I don&#039;t know your Dropbox Public ID yet, please copy a plublic Dropbox to the clipboard and restart the Script&quot; as informational giving up after 5
  end try
end try
if dropbox_public_ID is not &quot;&quot; then
  -- GET THE YOUTUBE CHANNELNAME
  try
    set youtube_channelName to do shell script &quot;defaults read &quot; &amp; plist &amp; &quot; &#039;Youtube channel name&#039;&quot;
  on error
    set youtube_channelName to text returned of (display dialog &quot;I don&#039;t know your Youtube-Channel name yet, please enter it here.&quot; default answer &quot;&quot;)
    if (youtube_channelName as text) &ne; &quot;&quot; and (youtube_channelName as text) &ne; &quot;false&quot; then
      do shell script &quot;defaults write &quot; &amp; plist &amp; &quot; &#039;Youtube channel name&#039; &quot; &amp; youtube_channelName
    end if
  end try
end if

if dropbox_public_ID is not &quot;&quot; and youtube_channelName is not &quot;&quot; then
  -- ASK WHAT TO INSERT (FileLink or YouTube Link)
  set thelist to {&quot;DropBox (&quot; &amp; dropbox_public_ID &amp; &quot;)&quot;, &quot;YouTube (&quot; &amp; youtube_channelName &amp; &quot;)&quot;, &quot;--delete preferences--&quot;}
  set theaction to word 1 of ((choose from list thelist with prompt &quot;Insert Links from:&quot; default items item 1 of thelist) as text)
  
  -- DROPBOX GET LINKS
  if theaction as text = &quot;DropBox&quot; then
    set DropBoxFiles to my getFileList(DropBoxPublicFolder, &quot;&quot;, true)
    repeat with i from 1 to count of DropBoxFiles
      set item i of DropBoxFiles to (StandardPublicLinkURL &amp; dropbox_public_ID &amp; &quot;/&quot; &amp; my URL_Encode(my remove_from_string_beginning(item i of DropBoxFiles as text, DropBoxPublicFolder)) as text)
    end repeat
    set AppleScript&#039;s text item delimiters to return
    set DropBoxFiles to DropBoxFiles as text
    set AppleScript&#039;s text item delimiters to &quot;&quot;
    my typeThis(DropBoxFiles)
    -- YOUTUBE GET LINKS
  else if theaction as text = &quot;YouTube&quot; then
    set youtubeinfo to my getYouTubeURL(youtube_channelName, 1, 25)
    set thestring to &quot;&quot;
    repeat with info in youtubeinfo
      set thestring to thestring &amp; Video_Titel of info &amp; &quot;:&quot; &amp; return &amp; Video_URL of info &amp; return &amp; return
    end repeat
    typeThis(thestring as text)
    --RESET/DELETE PREFERENCES
  else if theaction as text = &quot;delete&quot; then
    set myplist to quoted form of (POSIX path of (get path to &quot;pref&quot;) &amp; &quot;com.hubionmac.hubis_insertlink.plist&quot;)
    do shell script &quot;rm &quot; &amp; myplist
    display alert &quot;Preferences have been removed.&quot; giving up after 2 as informational
  end if
end if

on getFileList(RootDir, subDir, firstRun)
  --24.03.2012 hubionmac.com
  --gives you some kind of file dialog in form of a simple applscript-list-dialog
  --returns a list of files (NOT Folders)
  --rootdir is absolute path of the file dialogs root
  --subdir is empty string only used in recursion
  --firstRun is used for recursion, too, should be true on first run 8-)
  if RootDir does not end with &quot;/&quot; then error &quot;RootDir must end with \&quot;/\&quot;!&quot;
  --check that we are still in inside RootDir
  set CurrentPath to quoted form of RootDir &amp; subDir
  if ((do shell script &quot;cd &quot; &amp; CurrentPath &amp; &quot;;pwd&quot;) as text) starts with ((characters 1 through -2 of RootDir) as text) then
    -- GET FOLDERS --
    try
      set CurrentFolders to {&quot;:::Folders:::&quot;} &amp; every paragraph of (do shell script &quot;cd &quot; &amp; CurrentPath &amp; &quot;;ls -d */&quot;)
    on error --no directories here
      set CurrentFolders to {}
    end try
    -- GET FILES --
    try
      set CurrentFiles to every paragraph of (do shell script &quot;cd &quot; &amp; CurrentPath &amp; &quot;;ls -1p | grep -v /\\$&quot;)
    on error --no visible files here
      set CurrentFiles to {}
    end try
    if CurrentFiles &ne; {} then set CurrentFiles to {&quot;:::Files:::&quot;} &amp; CurrentFiles
    if firstRun is true then
      set thefiles to choose from list CurrentFolders &amp; CurrentFiles default items (item 1 of (CurrentFolders &amp; CurrentFiles)) with multiple selections allowed
    else if firstRun is false then
      set thefiles to choose from list {&quot;..&quot;} &amp; CurrentFolders &amp; CurrentFiles default items (item 1 of ({&quot;..&quot;} &amp; CurrentFolders &amp; CurrentFiles)) with multiple selections allowed
    end if
    set myoutput to {}
    if thefiles &ne; false then
      repeat with thefile in thefiles
        if thefile as text = &quot;..&quot; then
          set myoutput to getFileList(RootDir, subDir &amp; &quot;../&quot;, false)
        else
          if thefile as text does not start with &quot;:&quot; then
            if thefile as text does not end with &quot;/&quot; then
              if subDir as text does not contain &quot;..&quot; then
                set myoutput to myoutput &amp; {(RootDir &amp; subDir &amp; thefile) as text}
              else
                --removes .. from outputpaths so you always get a nice clean absolute path
                set cleanedpath to ((do shell script &quot;cd &quot; &amp; quoted form of RootDir &amp; subDir &amp; &quot;;pwd&quot;) &amp; &quot;/&quot;) as text
                set myoutput to myoutput &amp; {(cleanedpath &amp; thefile) as text}
              end if
            else
              set myoutput to getFileList(RootDir, subDir &amp; thefile, false)
            end if
          end if
        end if
      end repeat
    end if
  else
    set myoutput to getFileList(RootDir, &quot;&quot;, true)
  end if
  return myoutput
end getFileList

on remove_from_string_beginning(thestring, remove_these)
  repeat with remove_this in remove_these
    if thestring starts with (remove_this as text) then
      set thestring to (characters ((count of every character of (remove_this as text)) + 1) through -1 of thestring) as text
    end if
  end repeat
  return thestring
end remove_from_string_beginning

on URL_Encode(thestring)
  return do shell script &quot;/usr/bin/python -c &#039;import sys, urllib; print urllib.quote(sys.argv[1])&#039; &quot; &amp; quoted form of thestring
end URL_Encode

on typeThis(t)
  set the clipboard to t
  tell application (path to frontmost application as text)
    activate
    tell application &quot;System Events&quot;
      keystroke &quot;v&quot; using command down
    end tell
  end tell
  (**this did not work 100% on every link, so we use the clipboard instead
  set umlauts to {&quot;&uuml;&quot;, &quot;&auml;&quot;, &quot;&ouml;&quot;, &quot;&Auml;&quot;, &quot;&Uuml;&quot;, &quot;&Ouml;&quot;, &quot;&sect;&quot;, &quot;&acute;&quot;, &quot;`&quot;}
  set contains_umlauts to false
  repeat with umlaut in umlauts
    if t contains umlaut then
      set contains_umlauts to true
    end if
  end repeat
  
  tell application (path to frontmost application as text)
    activate
    tell application &quot;System Events&quot;
      if contains_umlauts = false then
        keystroke t
      else
        
        repeat with c in t
          if c is not in umlauts then
            keystroke c
          else
            if (ASCII number of c) = 159 then
              keystroke &quot;u&quot; using option down
              keystroke &quot;u&quot;
            else if (ASCII number of c) = 134 then
              keystroke &quot;u&quot; using option down
              keystroke &quot;u&quot; using shift down
            else if (ASCII number of c) = 138 then
              keystroke &quot;u&quot; using option down
              keystroke &quot;a&quot;
            else if (ASCII number of c) = 128 then
              keystroke &quot;u&quot; using option down
              keystroke &quot;a&quot; using shift down
            else if (ASCII number of c) = 154 then
              keystroke &quot;u&quot; using option down
              keystroke &quot;o&quot;
            else if (ASCII number of c) = 130 then
              keystroke &quot;u&quot; using option down
              keystroke &quot;o&quot; using shift down
            else if (ASCII number of c) = 164 then
              key code (20) using shift down
            else if (ASCII number of c) = 96 then
              key code (24) using {control down, shift down}
            else if (ASCII number of c) = 171 then
              key code (24) using control down
            end if
          end if
        end repeat
      end if
    end tell
  end tell**)
end typeThis



on getYouTubeURL(theChannel, thestartIndex, maxResults)
  set theurl to &quot;&#039;http://gdata.youtube.com/feeds/api/videos?max-results=&quot; &amp; maxResults &amp; &quot;&amp;start-index=&quot; &amp; thestartIndex &amp; &quot;&amp;author=&quot; &amp; theChannel &amp; &quot;&#039;&quot; --list info
  set thexmlfile to (path to &quot;temp&quot;) &amp; &quot;youtubefeed.xml&quot; as text
  set thexmlfile_ to quoted form of POSIX path of thexmlfile
  if intervall_passed(plist, &quot;lastrun&quot;, &quot;900&quot;) is true or ((do shell script (&quot;if test -e &#039;&quot; &amp; thexmlfile_ &amp; &quot;&#039; ; then echo 1 ; else echo 0 ; fi&quot;) as text) as integer as boolean) is false then
    do shell script &quot;curl &quot; &amp; theurl &amp; &quot;&gt;&quot; &amp; thexmlfile_
  end if
  set thetitles to {}
  set thetitles_ to {}
  set theurls to {}
  set theindex to 0
  tell application &quot;System Events&quot;
    tell contents of XML file thexmlfile
      set thetotalcount to value of XML element &quot;openSearch:totalResults&quot; of XML element 1
      repeat with i from 1 to count of XML elements of XML element 1
        set theelement to XML element i of XML element 1
        if name of theelement is &quot;entry&quot; then
          set theindex to theindex + 1
          set thetitles to thetitles &amp; ((value of XML element &quot;title&quot; of theelement) &amp; &quot; ##&quot; &amp; theindex as text)
          set thetitles_ to thetitles_ &amp; ((value of XML element &quot;title&quot; of theelement))
          set thelink to (value of XML attribute &quot;href&quot; of XML element &quot;link&quot; of theelement)
          set theurls to theurls &amp; (characters 1 through ((offset of &quot;&amp;&quot; in thelink) - 1) of thelink as text)
        end if
      end repeat
    end tell
  end tell
  if thetotalcount &gt; (thestartIndex + maxResults) then
    set thevideos to choose from list (thetitles &amp; {&quot;--update--&quot;, &quot;--more--&quot;}) default items item 1 of (thetitles &amp; {&quot;--update--&quot;, &quot;--more--&quot;}) with multiple selections allowed
  else
    set thevideos to choose from list (thetitles &amp; {&quot;--update--&quot;}) default items item 1 of (thetitles &amp; {&quot;--update--&quot;}) with multiple selections allowed
  end if
  set myoutput to {}
  if thevideos &ne; false then
    repeat with thevideo in thevideos
      if thevideo as text = &quot;--more--&quot; then
        set myoutput to my getYouTubeURL(theChannel, maxResults + 1, maxResults)
      else if thevideo as text = &quot;--update--&quot; then
        do shell script &quot;curl &quot; &amp; theurl &amp; &quot;&gt;&quot; &amp; thexmlfile_
        set myoutput to my getYouTubeURL(theChannel, 1, maxResults)
      else
        set theurlindex to last word of (thevideo as text) as integer
        set myoutput to myoutput &amp; {{Video_Titel:item theurlindex of thetitles_ as text, Video_URL:item theurlindex of theurls as text}}
      end if
    end repeat
  end if
  return myoutput
end getYouTubeURL


on getRecord(xmlFile, i)
  set myRecord to {}
  tell application &quot;System Events&quot;
    tell contents of XML file xmlFile
      set theXMLDB to the name of XML element 1 --similar to the previous handler
      tell XML element i of XML element theXMLDB
        set myRecord to {(value of XML element &quot;studentID&quot;), (value of XML element &quot;lastName&quot;), (value of XML element &quot;firstName&quot;), (value of XML element &quot;emailAddress&quot;)}
      end tell
      
    end tell
  end tell
  return (myRecord) --pass the list back to the main handler to be put in the table
end getRecord


to intervall_passed(plist, valuename, trigger_intervall)
  --input a plist like &quot;com.hubionmac.testapp
  --input a valuename like &quot;lastrun&quot;
  --input a trigger_intervall like 1000
  --and the handler returns true if the stored EPOG-timestamp from the plist is older than 1000 seconds
  --if true the EPOC-Timtestamp in the plist is updated
  set current_EPOC to do shell script &quot;perl -e &#039;print time.\&quot;\\n\&quot;;&#039;&quot;
  try
    set last_EPOC to (do shell script &quot;defaults read &quot; &amp; plist &amp; &quot; &quot; &amp; quoted form of valuename)
  on error
    set last_EPOC to &quot;0&quot;
  end try
  set EPOCDiff to do shell script &quot;echo &quot; &amp; current_EPOC &amp; &quot;-&quot; &amp; last_EPOC &amp; &quot;|bc&quot;
  set mystatus to ((do shell script &quot;if test &quot; &amp; EPOCDiff &amp; &quot; -gt &quot; &amp; trigger_intervall &amp; &quot;;then echo 1 ; else echo 0  ; fi&quot;) as integer) as boolean
  if mystatus is true then
    --update stored epoc-timestamp
    do shell script &quot;defaults write &quot; &amp; plist &amp; &quot; &quot; &amp; quoted form of valuename &amp; &quot; &quot; &amp; current_EPOC
  end if
  return mystatus
end intervall_passed
</code>
									</pre></p></p>]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3202/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Soziale Profile aus Apple Adressbuch löschen</title><link>http://hubionmac.com/wordpress/archives/3178</link> <comments>http://hubionmac.com/wordpress/archives/3178#comments</comments> <pubDate>Wed, 21 Mar 2012 04:34:38 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[Address Book]]></category> <category><![CDATA[Useful Snippets]]></category> <category><![CDATA[addressbook]]></category> <category><![CDATA[AppleScript]]></category> <category><![CDATA[delete]]></category> <category><![CDATA[social profile]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3178</guid> <description><![CDATA[Ich wurde von Phil angeschrieben, der verzweifelt versucht hat, das wohl erst seit kurzem im Apple Adressbuch eingeführten social profile via AppleScript zu löschen. Das Problem dabei scheint zu sein, dass ein normales delete social profile 1 of somePerson nicht funktioniert, da dieses Element kein Bestandteil der contact info ist. So zumindest meine Vermutung, wenn [...]]]></description> <content:encoded><![CDATA[Ich wurde von Phil angeschrieben, der <a href="http://stackoverflow.com/questions/9784980/using-applescript-to-clean-up-address-book-behaves-weirdly-when-it-comes-to-soci" title="Link zu Request of stackoverflow" target="_blank">verzweifelt versucht hat</a>, das wohl erst seit kurzem im Apple Adressbuch eingeführten <em>social profile</em> via AppleScript zu löschen. Das Problem dabei scheint zu sein, dass ein normales <code>delete social profile 1 of somePerson</code> nicht funktioniert, da dieses Element kein Bestandteil der <em>contact info</em> ist. So zumindest meine Vermutung, wenn ich mir das AppleScript-Funktionsverzeichnis anschaue. Ich finde den Zustand ehrlich gesagt recht passend; wenn es schon so schwierig ist, sein soziales Profil bei FaceBook, Google+, Twitter &#038; Co. wirklich zu löschen, dann sollte man es mindestens genau so schwer haben, wenn man dies via Skript auf einem Mac versucht. Aber ich würde darüber nicht schreiben, wenn ich dafür keine Lösung parat hätte. <span style="color:red"><strong>VORSICHT, der folgende Code LÖSCHT alle sozialen Profile, der im Adressbuch ausgewählten Person!!!</strong></span><p><pre class="Plum_Code_Box"><code class="">--&copy; hubionmac.com 21.03.2012
-- example code that REMOVES ALL SOCIAL PROFILES
-- from every selected person in your Address Book
-- de-facebook, de-twitter,&hellip; you contacts ;-)

set mySelectedPersons to selection

repeat with aSelectedPerson in mySelectedPersons
  set social_ids to id of (every social profile of aSelectedPerson)
  repeat with social_id in social_ids
    my delete_social_profile(aSelectedPerson, social_id)
    save
  end repeat
end repeat

on delete_social_profile(thePerson, theID)
  --handler for removing social profiles from Address Book
  --only way since social profile is not contained by contact info or something else and so delete social profile xy does not work
  -- input a single reference to a person in the address book and
  -- a the uniq ID of a social profile as text
  tell application &quot;Address Book&quot;
    set social_index to 0
    repeat with i from 1 to (count of every social profile of thePerson)
      if (id of social profile i of thePerson) as text = theID as text then
        set social_index to i
        exit repeat
      end if
    end repeat
    if social_index = 0 then error &quot;error on delete_social_profile, given ID was not found in this person&quot;
    --you cannot delete/kill a social profile, but when you remove/take away
    --all stored information (username and URL) from it, it commits suicide
    --and is removed from the address book, philosophic programming, isn&#039;t it?
    set user name of social profile social_index of thePerson to &quot;&quot;
    set url of social profile social_index of thePerson to &quot;&quot;
  end tell
end delete_social_profile</code>
									</pre></p>]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3178/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Email-Statistik</title><link>http://hubionmac.com/wordpress/archives/3104</link> <comments>http://hubionmac.com/wordpress/archives/3104#comments</comments> <pubDate>Thu, 15 Mar 2012 00:23:44 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[Apple Mail]]></category> <category><![CDATA[Things I add to a new system]]></category> <category><![CDATA[AppleScript]]></category> <category><![CDATA[graph]]></category> <category><![CDATA[html]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[mail]]></category> <category><![CDATA[statistics]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3104</guid> <description><![CDATA[Es gibt verschiedene Gründe und auch Wege Emails auszuwerten. Ich diesem Beispiel breche ich es mal herunter auf die pure Anzahl von Emails Pro Tag/Monat/Jahr. Eine entsprechende Eingrenzung nach Absender ist zwar im Skript enthalten, ich würde hierfür aber einfach ein entsprechendes intelligentes Postfach definiere, so kann man recht zuverlässig z.B. alle Emails einer Person, [...]]]></description> <content:encoded><![CDATA[<p>Es gibt verschiedene Gründe und auch Wege Emails auszuwerten. Ich diesem Beispiel breche ich es mal herunter auf die pure Anzahl von Emails Pro Tag/Monat/Jahr.<span id="more-3104"></span>Eine entsprechende Eingrenzung nach Absender ist zwar im Skript enthalten, ich würde hierfür aber einfach ein entsprechendes intelligentes Postfach definiere, so kann man recht zuverlässig z.B. alle Emails einer Person, mit Anhang, die XY im Betreff haben herausfiltern und auf dieses Suchergebnis dann das Skript anwenden und seine "statistischen" Schlüsse daraus ziehen. Schon kann man in Zahlen belegen (ist ja zur Zeit recht populär), wann einem der Chef mit Email-Weiterleitungen am meisten genervt hat, <a href="http://www.youtube.com/embed/4c-CRDuCvGg" title="YouTube Video" target="_blank">ab welchem Zeitpunkt die Ex-Freundin anfing weniger Emails zu schicken</a> als bisher, wann einem Newsletter am öftesten informierten...</p><p>Dies ist nur eine Quick&#038;Dirty Lösung, die Datumsstempel sammelt, sortiert und über ein paar Terminal-Tricks daraus verwertbare Tabellen erstellt. Der vermutlich bessere Weg wäre, alle Daten in einer großen Tabelle zusammenzufassen (am besten dann noch via Ruby (rubygem,rmail,fastercsv) ) und dann über JavaScript entsprechende Statistische Auswertungen anzustoßen... später mal, zur Zeit tut dieses Ding genau das was ich möchte und das via AppleScript, ein wenig Basic-Shell-Tricks (awk, sort, uniq), HTML und JavaScript (<a href="http://www.highcharts.com" title="HighCharts JavaScript Library" target="_blank">Highcharts</a>) ;-)</p> <a class="download_button" href="http://hubionmac.com/wordpress/wp-content/plugins/download-monitor/download.php?id=49" title="Download: Mailstats v.0.1"><span class="title">DOWNLOAD</span><br /><span class="name">Mailstats v.0.1</span><br /> <span class="info">170.18 kB (21 hits)</span></a>]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3104/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>In eigener Sache: Jobsuche mal anders</title><link>http://hubionmac.com/wordpress/archives/3100</link> <comments>http://hubionmac.com/wordpress/archives/3100#comments</comments> <pubDate>Sun, 26 Feb 2012 19:16:38 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[Allgemein]]></category> <category><![CDATA[Job]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3100</guid> <description><![CDATA[Hallo zusammen, Ich suche eine Job, vorzugsweise als Apple-Techniker/-Supporter. Der Blog ist vielleicht nicht der ultimative Weg einen Job zu suchen (auch nicht der einzige für mich), doch wäre es vermutlich ziemlich dumm, nicht auch hier die Möglichkeit zu ergreifen. Sollte also jemand eine entsprechende vakante Stelle in Aussicht haben und nach einem kreativen, motvierten [...]]]></description> <content:encoded><![CDATA[Hallo zusammen,Ich suche eine Job, vorzugsweise als Apple-Techniker/-Supporter. Der Blog ist vielleicht nicht der ultimative Weg einen Job zu suchen (auch nicht der einzige für mich), doch wäre es vermutlich ziemlich dumm, nicht auch hier die Möglichkeit zu ergreifen. Sollte also jemand eine entsprechende vakante Stelle in Aussicht haben und nach einem kreativen, motvierten und lernbereiten neuen Mitarbeiter suchen. Holá me llamo Hubi. I can repair PCs and Macintosh Computers. Ich bin ausgebildeter System-Elekotroniker mit >5 Jahren Berufserfahrung und war neben einer längeren Beschäftung bei einem "nahmhaften" Apple-Serviceprovider, über ein Jahr in der Veranstalltungsbranche tätig (Netzwerktechnik und Boxen schleppen). Ich lerne Windows und iOS gerade so richtig kennen, verstehen und zeitweise verabscheuen und bin ein Terminal-Fan. Ich mag auch Pinguine und kleine Teufel. Ich bin zeitweise etwas exzentrisch, gestehe mir aber auch gerne Fehler ein(meine eigenen und auch die von anderen) ;-P. Ich bin auch dankbar für  jeden Hinweis, Tips oder Anregungen, sei es via Kommentar oder <a href="mailto:hubi@hubionmac.com">Email</a>.Yours Hubi]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3100/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>AppleScript: der etwas andere Aufruf eines AppleScript Handlers</title><link>http://hubionmac.com/wordpress/archives/3095</link> <comments>http://hubionmac.com/wordpress/archives/3095#comments</comments> <pubDate>Fri, 24 Feb 2012 14:15:18 +0000</pubDate> <dc:creator>hubi</dc:creator> <category><![CDATA[AppleScript]]></category> <category><![CDATA[automation]]></category> <category><![CDATA[handler]]></category> <category><![CDATA[list]]></category> <category><![CDATA[repeat]]></category><guid isPermaLink="false">http://hubionmac.com/wordpress/?p=3095</guid> <description><![CDATA[Manchmal hat man einen Haufen Handler in AppleScript. Respekt, wenn man den Nerv hat, das alles sauber, in insich stimmige Handler zu verfrachten. Das ist ein guter Weg und macht Änderungen am späteren Code (gerade bei längeren Skripten) um einiges unkomplizierter. Nur wenn man ein solches Handler-Konstrukt aufgebaut hat, ist es vom Code oft ziemlich [...]]]></description> <content:encoded><![CDATA[<p>Manchmal hat man einen Haufen Handler in AppleScript. Respekt, wenn man den Nerv hat, das alles sauber, in insich stimmige Handler zu verfrachten. Das ist ein guter Weg und macht Änderungen am späteren Code (gerade bei längeren Skripten) um einiges unkomplizierter. Nur wenn man ein solches Handler-Konstrukt aufgebaut hat, ist es vom Code oft ziemlich aufwendig (viel zu tippen) diese dann auch auszuführen und kann am Ende auch wieder unübersichtlich werden.<br /> Nach eine Anfrage an mich, habe ich mir mal ein paar Gedanken dazu gemacht und bin zu diesem Code-Beispiel gekommen.</p><span id="more-3095"></span><p><pre class="Plum_Code_Box"><code class="">set handler_names to {sayhallo, sayAName, sayhallo}
set handler_parameters to {{}, {&quot;hubi&quot;}, {}}

repeat with i from 1 to count of handler_names
  set current_handler to item i of handler_names
  set current_handler_parameter to item i of handler_parameters
  if current_handler_parameter is {} then
    current_handler()
  else
    current_handler(current_handler_parameter)
  end if
end repeat


on sayhallo()
  say &quot;hallo&quot;
  return true
end sayhallo

on sayAName(aname)
  say aname
  return true
end sayAName</code>
									</pre></p><p>Das besondere daran ist, dass der Verlauf des Skripts eigentlich nur über den Inhalt der Handler-Namen in der zu Anfang definierten Liste gesteuert wird. Die Parameter sind alle zentral in einem Parameter-Record gespeichert und das war es... der Rest läuft über eine Repeat-Schleife, die nötigenfalls die Parameter beim Funktionsaufruf weglässt.</p> <br />Das ist hier nur ein simples Beispiel, macht aber hoffentlich klar, dass ein so strukturierter Aufbau gerade bei größeren AppleSkripts den Wartungsaufwand um einiges vereinfachen kann. Ok, ist eigentlich nur eine andere Schreibweise und macht vermutlich nur dann Sinn, wenn es eine große Anzahl von Handlern gibt, die mit den gleichen Datensatz etwas anstellen, dann erspart es einem Tip-Arbeit und macht das Skript übersichtlicher.<p>Ich hätte da noch eine andere Idee, wenn quasi eine sehr große Anzahl von Handlern laufen muss und man sich die Tiparbeit für die handler-Liste ersparen möchten, könnte man den Code auch als Text abspeichern, diesen über eine Routine auslesen lassen, und daraus dann den eigentlichen AppleScript-Code mit der Handler-Liste erstellen lassen. Diese dann als AppleScript-Datei abspeichern und wiederum über das Skript ausführen lassen. Hat irgendwie etwas schweinisch biologisches an sich ;-)<br /> Vielleicht hat ja sonst noch jemand eine kreative Idee, wie man in AppleScript Code formschön und übersichtlich programmieren kann.</p>]]></content:encoded> <wfw:commentRss>http://hubionmac.com/wordpress/archives/3095/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Database Caching 6/12 queries in 0.009 seconds using disk: basic
Object Caching 599/602 objects using disk: basic

Served from: hubionmac.com @ 2012-05-19 14:29:45 -->
