AppleScript-Code zu HTML

7/02/2011

Hm, ich dachte ich hätte das Ding schon mal hier gepostet, kann es aber selber nicht mehr finden. Die CodeBoxes die ich hier und z.B. im AppleScript-Forum einbaue, erstelle ich über ein Skript, welches (ganz abartig) GUI-Skripting und Text-Edit verwendet, um den entsprechenden HTML-Code zu generieren. Auf diese Weise geht es aber recht schnell. Dabei sind 2 Vorkehrungen zu treffen:

Read the rest of this article »
1 Comment

Addressbuch: Einzelne vCards exportieren

6/02/2011
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 "Address Book"

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 "Address Book"

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

2 Comments

Adressbuch: Wer war noch einmal Frida Henkemeier?

6/02/2011

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.

Read the rest of this article »
2 Comments

Kleine dynamische Video-Seite

5/02/2011
Ein Doppelklick und fertig ist die Webseite mit einer kleinen Auswahl von Video-Files... war mal eine fixe Idee... hier für's Archiv
No Comments

URL Encoding in AppleScript

22/01/2011

Ich hatte da eine Perl-Zeile die mir einen String "url-encoded", nur funktionierte dieser "do shell script"-Aufruf nicht in Filemaker (wissen die Götter wie die AppleScript dort ausführen). Auf jeden Fall waren das Filemaker zuviele Sonderzeichen in dem Befehl und es kam nur Murks dabei raus. Und weil ja so viele schöne Skript-Sprachen auf dem Mac schon vorinstalliert sind hier meine Top 3 Aufrufe fürs URL-Encoding unter AppleScript (Platz 1 funktioniert dann auch, wenn er in Filemaker ausgeführt wird):

Read the rest of this article »
No Comments

AppleScript: Excel -> Photoshop

20/01/2011

Von Zeit zur Zeit muss ich mal in Photoshop Video-Tafeln setzen. Die Daten hierfür kommen meistens aus Excel und werden natürlich per AppleScript in eine Vorlage übertragen =)
Das Skript sollte sowohl mit Photoshop Elements als auch mit der nicht abgespeckten Version funktionieren.

Read the rest of this article »
No Comments

Protected: Mactechnews Gallerie Downloader

14/01/2011

This post is password protected. To view it please enter your password below:

No Comments

AppleScript: CDFinder

14/01/2011

Es musste ja mal so kommen, dass ich auch mal den CDFinder skripte. Aber es war nicht wirklich ein Vergnügen. Es werden zwar einige Befehle angeboten, nur wenn man mal das Suchergebnis einer manuell durchgeführte Suche verskripten möchte... Nun, CDFinder steht Apple Mail in nichts nach (Stichwort outgoing messages).
Also mein Ziel war folgendes: Ich wollte in CDFinder mein Musik-Share nach Titel durchsuchen und dann auf Knopfdruck die Original-Datei einer Datei aus dem Suchergebnis in einen bestimmten Ordner kopieren. So eine Funktion (kopiere Original in Ordner XY) fände ich sogar recht naheliegend bei eine Katalog-Software :-/). Nun sei es drum, ich konnte also nun leider nicht auf die Auswahl im Ergebnisfenster zugreifen, also auch nicht den "complete path" auslesen, wenn das Skript nicht auch die Suche selbst durchführt. Deshalb musste wieder mal GUI-Scripting als Lösung herhalten, öffne die Info, lese Text-Feld XY aus und baue dir daraus einen Datei-Pfad zum kopieren... und kopiere! Nun das Skript auf einen Shortcut...(cmd + J ist noch frei)
Darf ich vorstellen, mein erstes CDFinder Skript:

Read the rest of this article »
No Comments

AppleScript + JavaScript Tutorial mit Video

7/01/2011
Meine Güte ist mir langweilig. AppleScript StepByStep mit Video und Quellcode...
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

tell application "Safari"

activate

open location "http://www.heise.de/newsticker/"

set mysearch to text returned of (display dialog "Meldungen anzeigen die ... enthalten:" default answer "")

tell document 1

set mylinks to do JavaScript "

var myoutput = new Array();

for (var i=0;i<document.links.length;i++){

if (document.links[i].text.indexOf('" & mysearch & "')>-1 && document.links[i].href.indexOf('/newsticker/meldung/')>-1) {

myoutput.push(document.links[i].href)

}

}

myoutput

"

repeat with mylink in mylinks

my makeNewTab()

do JavaScript "document.location='" & mylink & "'"

end repeat

end tell

end tell


on makeNewTab()

tell application "Safari" to activate

tell application "System Events"

tell process "Safari"

keystroke "t" using command down

end tell

end tell

delay 0.5

end makeNewTab

1 Comment

Microsoft Powerpoint: AppleScript für Preistafeln

7/11/2010
War eine Lösung für eine Preistafel bei einer Auktion, es geht von 8000 in 500er-Schritten bis zur letzten Folie. Es wird hierbei immer das erste und einzige Text-Feld auf der Folie gesetzt:
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

tell application "Microsoft PowerPoint"

tell active presentation

set thenumber to 8000

repeat with i from 1 to count of every slide

##content looks like this - >    8.500 €

set content of text range of text frame of shape 1 of slide i to (characters 1 through -4 of (thenumber as text) & "." & characters -3 through -1 of (thenumber as text) & " €") as text

set thenumber to thenumber + 500

end repeat

end tell

end tell

No Comments