IP Phone: Difference between revisions

From Medien Wiki
Line 31: Line 31:
set safariWasRunning to true
set safariWasRunning to true
else
else
tell application "Safari"
tell application "Safari" to activate
activate
delay 0.5
end tell
end if
end if
tell application "Safari" to open location "https://telefon.uni-weimar.de/webdialer/Webdialer"
set theNumber to value of e
set theNumber to value of e
set amtsholung to true
set amtsholung to true
Line 68: Line 66:
set theNumber to "0" & theNumber as text
set theNumber to "0" & theNumber as text
end if
end if
--the following fades out iTunes if it's playing, inspired by Jeroen van der Waal http://dougscripts.com/itunes/
if appIsRunning("iTunes") then
if appIsRunning("iTunes") then
tell application "iTunes" to if player state is playing then set iTunesWasPlaying to true
tell application "iTunes" to if player state is playing then set iTunesWasPlaying to true
if iTunesWasPlaying then
if iTunesWasPlaying then
tell application "iTunes" to pause
tell application "iTunes"
set oldVolume to sound volume
repeat with i from oldVolume to 0 by -1
set sound volume to i
delay 0.01
end repeat
pause
set sound volume to oldVolume
end tell
end if
end if
end if
end if
tell application "Safari"
tell application "Safari"
open location "https://telefon.uni-weimar.de/webdialer/Webdialer"
-- 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 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.5
delay 0.5
Line 86: Line 92:
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
delay 8
--tell application "Safari"
tell application "Safari"
-- quit
quit
--end tell
end tell
--end if
end if
end tell
end tell
return true
return true