IP Phone: Difference between revisions

From Medien Wiki
mNo edit summary
mNo edit summary
Line 4: Line 4:
* [http://voicemail.uni-weimar.de Voicemail]
* [http://voicemail.uni-weimar.de Voicemail]


Dieses script in <tt>~/Library/Address Book plugins/</tt> legen:
== Kontextmenü in OS X Adress Book ==
Um über ein Klick den im OS X Adressbuch geöffneten Kontakt anzuwählen kann folgendes AppleScript verwendet werden, es kann als <tt>Call with IP Phone.scpt</tt> in <tt>~/Library/Address Book plugins/</tt> gelegt werden.


<source lang="applescript">
<source lang="applescript">
on findReplace(findText, replaceText, sourceText)
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to findText
set sourceText to text items of sourceText
set AppleScript's text item delimiters to replaceText
set sourceText to "" & sourceText
set AppleScript's text item delimiters to ASTID
return sourceText
end findReplace
using terms from application "Address Book"
using terms from application "Address Book"
on action property
on action property
Line 21: Line 32:
on perform action for p with e
on perform action for p with e
set ABPhoneNumber to words of "+49 3643 58-3871"
set ABPhoneNumber to ABPhoneNumber as string
set theNumber to findReplace("+49", "0", ABPhoneNumber)
set thePhoneNumber to "0" & (value of e as string)
set theNicePhoneNumber to "0" & theNumber
 
tell application "Safari"
tell application "Safari"
Line 34: Line 42:
delay 1
delay 1
tell application "Safari"
tell application "Safari"
do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & thePhoneNumber & "'" in document 1
do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & theNicePhoneNumber & "'" in document 1
-- do JavaScript "document.forms['loginForm'].elements['dial'].click()" in document 1
do JavaScript "document.forms['loginForm'].elements['dial'].click()" in document 1
end tell
end tell
end tell
end tell
Line 44: Line 52:


[[Category:Cisco]]
[[Category:Cisco]]
[[Category:AppleScript]]
[[Category:Automation]]

Revision as of 14:37, 13 May 2011

Kontextmenü in OS X Adress Book

Um über ein Klick den im OS X Adressbuch geöffneten Kontakt anzuwählen kann folgendes AppleScript verwendet werden, es kann als Call with IP Phone.scpt in ~/Library/Address Book plugins/ gelegt werden.

on findReplace(findText, replaceText, sourceText)
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to findText
	set sourceText to text items of sourceText
	set AppleScript's text item delimiters to replaceText
	set sourceText to "" & sourceText
	set AppleScript's text item delimiters to ASTID
	return sourceText
end findReplace

using terms from application "Address Book"
	on action property
		return "phone"
	end action property
	
	on action title for p with e
		return "mit IP Phone wählen"
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set ABPhoneNumber to words of "+49 3643 58-3871"
		set ABPhoneNumber to ABPhoneNumber as string
		set theNumber to findReplace("+49", "0", ABPhoneNumber)
		set theNicePhoneNumber to "0" & theNumber
		
		tell application "Safari"
			activate
			open location "https://telefon.uni-weimar.de/webdialer/Webdialer"
			delay 1
			tell application "Safari"
				do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & theNicePhoneNumber & "'" in document 1
				do JavaScript "document.forms['loginForm'].elements['dial'].click()" in document 1
			end tell
		end tell
		return true
	end perform action
end using terms from