I wrote a script that checks if users are navigating certains web pages.
To accomplish such task, I wrote something like this:
repeat
delay 60
tell application "Safari"
verifications
if verification is true then quit
end tell
end repeat
(at bottom is the full code)
The idea is to quit Safari if user is navigating certain pages, identified by its name or its URL.
To avoid users to stop the checking actions, it was necessary:
to set the compiled script as a background applications (with Drop Script Backgrounder)
to set the compiled application as startup item
to deny permision to user to change its startup items (via Parental Control)
to deny permision to execute Activity Monitor (via Parental Control)
It works fine, quitting Safari and Explorer if the user is visiting pages like e-messenger, elchat and so on.
BUT. the overall speed of the machine is poor (specially printing on a networked printer and saving on a file server) or using QuarkXPress
I suppose that delay xx is not the best solution.
Does someone know a better solution.
Thanks in advance
The full code working fine:
repeat
delay 60
set denegados to {"chat", "messenger", "meebo"}
try
tell application "System Events"
-- Para Safari
if "Safari" is in name of the processes then
set salirSafari to "NO"
tell application "Safari"
if (count of windows) > 0 then
repeat with v from 1 to count of windows
if not modal of window v then
repeat with d from 1 to count of denegados
if item d of denegados is in name of window v or item d of denegados is in URL of document of window v then
beep 2
activate
display dialog "No hay que chatear." & return & "Safari se va a cerrar." buttons {"OK"} default button 1 with icon stop giving up after 3
quit application "Safari"
set salirSafari to "SI"
end if
if salirSafari = "SI" then exit repeat
end repeat
end if
if salirSafari = "SI" then exit repeat
end repeat
end if
end tell
end if
-- Para Explorer
set salirExplorer to "NO"
if "Internet Explorer" is in name of the processes then
tell application "Internet Explorer"
set ventanas to ListWindows
if (count of ventanas) > 0 then
repeat with v from 1 to count of ventanas
set info to GetWindowInfo item v of ventanas as string
repeat with d from 1 to count of items of denegados
if item d of denegados is in item 1 of info or item d of denegados is in item 2 of info then
beep 2
Activate
display dialog "No hay que chatear." & return & "Explorer se va a cerrar." buttons {"OK"} default button 1 with icon stop giving up after 3
quit application "Internet Explorer"
set salirExplorer to "SI"
end if
if salirExplorer = "SI" then exit repeat
end repeat
if salirExplorer = "SI" then exit repeat
end repeat
end if
end tell
end if
end tell
on error
-- nada
end try
run me
end repeat