Initial Problem: some files won’t delete on my computer, I need to frequently run “sudo rm -R” from terminal. So I built an applescript that can launch with a key command, and it works:
tell application "Finder" to set selection_POSIX to quoted form of (POSIX path of the (selection as alias))
do shell script "rm -R " & selection_POSIX with administrator privileges
The only problem now is that when I trigger the above applescript from Keyboard Maestro (the program I use to launch applescripts via key commands), the SecurityAgent window asking for my password comes up deactivated/background in Yosemite. This means I need to use the mouse to click on it instead of just typing my password straight away.
Solutions I’ve tried:
telling SecurityAgent to activate (tried both before and after shell script)
telling System events to tell process SecurityAgent to set frontmost to true (again, tried before and after)
running the shell script from within a tell System Events block, and using an ignoring application responses block to tell SecurityAgent to activate - in case it’s a parallel processing issue.
For some reason, I just can’t get that password request window to come up activated when triggered from a keystroke. Any ideas?
Model: MacBook Air
Browser: Safari 600.7.12
Operating System: Mac OS X (10.10)