Postadresse mit Tel und Fax aus Adressbuch in Zwischenablage

KinderReich

Mitglied
Thread Starter
Dabei seit
04.02.2009
Beiträge
97
Reaktionspunkte
0
Hallo,

gibt es ein einfaches Script (oder wie kann ich mir das erstellen?) mit dem ich den aufgerufenen Namen im Adressbuch samt Postadresse, Tel und Fax in die Zwischenablage kopiert bekomme? Diese Info möchte ich gern für einen Brief weiterverwenden. Ähnlicher Beitrag von mir auch schon hier (https://www.macuser.de/forum/thema/708407-Adresse-mit-Faxnummer-kopieren) ohne Lösung für mich.
 
Hallo,

ist als solches nicht schwierig und ich habe Dir ein Beispiel runter getippselt.
Siehe unten…

Viel Spass beim weiteren Basteln :)

Viele Grüße

Code:
--

tell application "Contacts"
	
	--
	
	set selectedItems to selection
	
	if ((count of selectedItems) is not 1) then
		
		return
		
	end if
	
	--
	
	set selectedItem to first item of selectedItems
	
	--
	
	set someText to ""
	
	set allLines to {}
	
	--
	
	set someText to name of selectedItem
	
	if (someText is not missing value) then
		
		copy someText to the end of allLines
		
	end if
	
	--
	
	set allAddresses to address of selectedItem
	
	if ((count of allAddresses) > 0) then
		
		--
		
		set firstAddress to item 1 of allAddresses
		
		--
		
		set someText to street of firstAddress
		
		if (someText is not missing value) then
			
			copy someText to the end of allLines
			
		end if
		
		--
		
		set someText to zip of firstAddress
		
		if (someText is not missing value) then
			
			copy someText to the end of allLines
			
		end if
		
		--
		
		set someText to city of firstAddress
		
		if (someText is not missing value) then
			
			copy someText to the end of allLines
			
		end if
		
		--
		
	end if
	
	--
	
	set AppleScript's text item delimiters to return
	
	--
	
	set someText to allLines as text
	
	-- 
	
end tell

--

if (length of someText < 1) then
	
	return
	
end if

--

set the clipboard to someText

--
 
oh, ich glaube ich habe den Mund zu voll genommen. Ich komme doch noch nicht ganz alleine klar.

Ich habe jetzt versucht, das Script anzupassen, aber .... da bin ich nicht weit gekommen. Könntest du vielleicht mir zeigen, wie ich das um die Tel, Fax und Email ergänzen kann?
 
Siehe unten…

Mußt noch die Labels definieren, wie Du sie im Adressbuch führst.

Viele Grüße

Code:
--

set configuration_address_index to 1

set configuration_phone_home_label to "home"

set configuration_phone_fax_label to "fax"

set configuration_email_home_label to "home"

--

tell application "Contacts"
	
	--
	
	set selectedItems to selection
	
	if ((count of selectedItems) is not 1) then
		
		return
		
	end if
	
	--
	
	set selectedItem to first item of selectedItems
	
	--
	
	set someText to ""
	
	set allLines to {}
	
	--	
	
	set someText to my getNameDescriptionFromPerson(selectedItem)
	
	if (someText is not missing value) then
		
		copy someText to the end of allLines
		
	end if
	
	--	
	
	set someText to my getAddressAtIndexFromPerson(configuration_address_index, selectedItem)
	
	if (someText is not missing value) then
		
		copy someText to the end of allLines
		
	end if
	
	--	
	
	set someText to my getPhoneWithLabelFromPerson(configuration_phone_home_label, selectedItem)
	
	if (someText is not missing value) then
		
		set someText to "T: " & someText
		
		copy someText to the end of allLines
		
	end if
	
	--	
	
	set someText to my getPhoneWithLabelFromPerson(configuration_phone_fax_label, selectedItem)
	
	if (someText is not missing value) then
		
		set someText to "F: " & someText
		
		copy someText to the end of allLines
		
	end if
	
	--	
	
	set someText to my getEmailWithLabelFromPerson(configuration_email_home_label, selectedItem)
	
	if (someText is not missing value) then
		
		set someText to "E: " & someText
		
		copy someText to the end of allLines
		
	end if
	
	--
	
	set AppleScript's text item delimiters to return
	
	--
	
	set someText to allLines as text
	
	-- 
	
end tell

--

if (length of someText < 1) then
	
	return
	
end if

--

set the clipboard to someText

--

return someText

--

on getNameDescriptionFromPerson(aPerson)
	
	--
	
	if (aPerson is missing value) then
		
		return missing value
		
	end if
	
	--
	
	set someText to name of aPerson
	
	--
	
	if ((length of someText) < 1) then
		
		return missing value
		
	end if
	
	--
	
	return someText
	
	--
	
end getNameDescriptionFromPerson

--

on getAddressAtIndexFromPerson(aIndex, aPerson)
	
	--
	
	if (aPerson is missing value) then
		
		return missing value
		
	end if
	
	--
	
	if (aIndex < 1) then
		
		return missing value
		
	end if
	
	--
	
	tell application "Contacts"
		
		--
		
		set allAddresses to address of aPerson
		
		if (aIndex ≤ (count of allAddresses)) then
			
			--
			
		else
			
			return missing value
			
		end if
		
		--
		
		set firstAddress to item aIndex of allAddresses
		
		--
		
		set someText to ""
		
		set allLines to {}
		
		--
		
		set someText to street of firstAddress
		
		if (someText is not missing value) then
			
			copy someText to the end of allLines
			
		end if
		
		--
		
		set someText to zip of firstAddress
		
		if (someText is not missing value) then
			
			--
			
			copy someText to the end of allLines
			
			--
			
			set someText to city of firstAddress
			
			if (someText is not missing value) then
				
				set someText to last item of allLines & " " & someText
				
				set last item of allLines to someText
				
			end if
			
			--
			
		else
			
			--
			
			set someText to city of firstAddress
			
			if (someText is not missing value) then
				
				copy someText to the end of allLines
				
			end if
			
			--
			
		end if
		
		--
		
		set someText to country of firstAddress
		
		if (someText is not missing value) then
			
			copy someText to the end of allLines
			
		end if
		
		--
		
	end tell
	
	--
	
	set AppleScript's text item delimiters to return
	
	--
	
	set someText to allLines as text
	
	--
	
	if ((length of someText) < 1) then
		
		return missing value
		
	end if
	
	--
	
	return someText
	
	--
	
end getAddressAtIndexFromPerson

--

on getPhoneWithLabelFromPerson(aLabel, aPerson)
	
	--
	
	if (aPerson is missing value) then
		
		return missing value
		
	end if
	
	--
	
	tell application "Contacts"
		
		--
		
		set someList to phones of aPerson
		
		--
		
	end tell
	
	--
	
	set someValue to my getValueFromListWithLabel(someList, aLabel)
	
	--
	
	return someValue
	
	--
	
end getPhoneWithLabelFromPerson

--

on getEmailWithLabelFromPerson(aLabel, aPerson)
	
	--
	
	if (aPerson is missing value) then
		
		return missing value
		
	end if
	
	--
	
	tell application "Contacts"
		
		--
		
		set someList to emails of aPerson
		
		--
		
	end tell
	
	--
	
	set someValue to my getValueFromListWithLabel(someList, aLabel)
	
	--
	
	return someValue
	
	--
	
end getEmailWithLabelFromPerson

--

on getValueFromListWithLabel(aList, aLabel)
	
	--
	
	if ((count of aList) < 1) then
		
		return missing value
		
	end if
	
	--
	
	tell application "Contacts"
		
		--
		
		repeat with nItem in aList
			
			--
			
			set someLabel to label of nItem
			
			if (someLabel is aLabel) then
				
				--
				
				set someValue to value of nItem
				
				if (length of someValue > 0) then
					
					return someValue
					
				end if
				
				--
				
			end if
			
			--
			
		end repeat
		
		--
		
	end tell
	
	--
	
	return missing value
	
	--
	
end getValueFromListWithLabel
 
Zurück
Oben Unten