12,297
edits
Line 7: | Line 7: | ||
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. Voraussetzung für das Funktionieren des Scripts ist, dass man schon die Sicherheitszertifikate der Webdialer-URL mit Safari importiert hat und dass man in dort schon eingeloggt ist (Login muss beim [[SCC-Services|SCC]] beantragt werden). | 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. Voraussetzung für das Funktionieren des Scripts ist, dass man schon die Sicherheitszertifikate der Webdialer-URL mit Safari importiert hat und dass man in dort schon eingeloggt ist (Login muss beim [[SCC-Services|SCC]] beantragt werden). | ||
< | <syntaxhighlight lang="applescript"> | ||
-- AppleScript(+JavaScript) to dial phone numbers with a Cisco IP Phone from the Mac OS Address Book via the Webdialer URL | -- AppleScript(+JavaScript) to dial phone numbers with a Cisco IP Phone from the Mac OS Address Book via the Webdialer URL | ||
-- 2011 Max Neupert, Bauhaus-Universität Weimar with the help of the world wide web and Google | -- 2011 Max Neupert, Bauhaus-Universität Weimar with the help of the world wide web and Google | ||
Line 27: | Line 27: | ||
on perform action for p with e | on perform action for p with e | ||
set safariWasRunning to false | set safariWasRunning to false | ||
set iTunesWasPlaying to false | |||
if appIsRunning("Safari") then | if appIsRunning("Safari") then | ||
set safariWasRunning to true | set safariWasRunning to true | ||
Line 32: | Line 33: | ||
tell application "Safari" | tell application "Safari" | ||
activate | activate | ||
delay | delay 0.5 | ||
end tell | end tell | ||
end if | end if | ||
Line 66: | Line 67: | ||
-- the following line adds a 0 to get the outside line = “Amtsholung” | -- the following line adds a 0 to get the outside line = “Amtsholung” | ||
set theNumber to "0" & theNumber as text | set theNumber to "0" & theNumber as text | ||
end if | |||
if appIsRunning("iTunes") then | |||
tell application "iTunes" to if player state is playing then set iTunesWasPlaying to true | |||
if iTunesWasPlaying then | |||
tell application "iTunes" to pause | |||
end if | |||
end if | end if | ||
tell application "Safari" | tell application "Safari" | ||
Line 72: | Line 79: | ||
-- wait until page is completely loaded | -- wait until page is completely loaded | ||
-- taken from http://www.mactipper.com/2009/10/run-applescript-when-webpage-is-done.html | -- taken from http://www.mactipper.com/2009/10/run-applescript-when-webpage-is-done.html | ||
delay | delay 1 | ||
repeat until ((do JavaScript "document.readyState" in document 1) is "complete") | repeat until ((do JavaScript "document.readyState" in document 1) is "complete") | ||
delay 0. | delay 0.5 | ||
end repeat | end repeat | ||
delay 1 | |||
do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & theNumber & "'" in document 1 | do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & theNumber & "'" 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 | ||
if safariWasRunning is false then | --if safariWasRunning is false then | ||
--delay 8 | |||
--tell application "Safari" | |||
-- quit | |||
--end tell | |||
end if | --end if | ||
end tell | end tell | ||
return true | return true | ||
Line 94: | Line 101: | ||
tell application "System Events" to (name of processes) contains appName | tell application "System Events" to (name of processes) contains appName | ||
end appIsRunning | end appIsRunning | ||
</ | </syntaxhighlight> | ||
Known Bugs: | Known Bugs: |