I have an AppleScript that automatically opens SelfControl.app to help avoid distractions when I want to be working. The script is very similar to automate an Internet content filter, and it is automatically launched by iCal at a set time.
The problem is that when the script runs, the window opens on the screen, and if I'm in the middle of typing something, then my typing interferes with the dialog box for entering the password, and the script fails.
How can I get the script to run independently from the user's activity? In other words, how can I run the script without showing the user the GUI evidence that the script is running?
Below is a snippet of code.
myPass are defined earlier in the script:
set myTime to … set myPass to … tell application "SelfControl" to activate tell application "System Events" tell process "SelfControl" tell slider of window "SelfControl" to set value to myTime click button "Start" of window "SelfControl" end tell tell window 1 of process "SecurityAgent" with timeout of 15 seconds repeat set tryAgain to false try set value of text field 2 of scroll area 1 of group 1 to myPass on error delay 1 set tryAgain to true end try if not tryAgain then exit repeat end repeat click button 2 of group 2 end timeout end tell end tell