How do you password protect an application using applescript?

Answer:
for example, to password protect safari, copy this into applescript editor and change where it says --password--.

display dialog "Please enter password to access the Internet." default answer "" buttons {"enter"} default button 1
set theResult to text returned of the result
if theResult is "--password--" then
display dialog "Thank you" buttons {"Continue to Internet"} default button 1
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Window" of menu "File" of menu bar 1
end tell
end tell
else if theResult is not "--password--" then
beep 2
end if
end
end

hope it helps!
First answer by S73575. Last edit by S73575. Contributor trust: 0 [recommend contributor recommended]. Question popularity: 4 [recommend question].