Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have set the Box SimpleShare app to start at login, but the app launches its preferences pane right after it loads its icon in the menu bar. Setting it to start in “hidden” mode in System Preferences > Users & Goups > Login Items doesn’t change that behavior.

I tried to create an AppleScript, saved as an app, to launch the SimpleShare app at login and hide the pref pane, but it doesn’t work as expected.

set tApp to "Box SimpleShare"
tell application tApp to launch
tell application "System Events"
    set visible of process "Box SimpleShare" to false
end tell

This launches the app but it does not close the Box SimpleShare preferences pane. What would be the proper code to do that?

Thank you in advance for your help!

Screenshot of the preferences window

share|improve this question
    
This might sound like a silly question, but humor me: have you tried closing the preferences window before quitting the application? Maybe you are just being bitten by Lion’s Resume function… –  kopischke May 8 '12 at 14:55
    
I see your point, kopi –  pause-n-loop May 8 '12 at 18:09
    
I see your point, kopi It has never been open before shutting down the machine. That's my point. Every day I have to close it manually to start working in a clean desktop. There isn't even a Saved Application State folder for it. Thank you. –  pause-n-loop May 8 '12 at 18:16
    
downloaded and tried it myself – a persistent little pest indeed (I can only imagine the box people consider it crucial you see your account data every time you start the app). Answer forthcoming. –  kopischke May 8 '12 at 19:13

1 Answer 1

up vote 0 down vote accepted

Box’s preference window is a particularly persistent one – not only does it insist on displaying every time the application is launched, it will re-open if closed before the app has finished its initialization sequence! However, with some GUI Scripting, it is possible to get rid of it. The following code will launch the application, wait for the preferences window to pop up and close it after a short delay (so it can complete its initialization sequence):

property timeOutMax : 5
property timeOutStep : 1
property boxLoadDelay : 2

set boxApp to "Box SimpleShare"
tell application boxApp to launch
set timeOutCounter to 0
tell application "System Events"
    tell process boxApp
        repeat while (window 1 of it exists) is false and timeOutCounter is less than timeOutMax
            delay timeOutStep
            set timeOutCounter to timeOutCounter + timeOutStep
        end repeat
        if window 1 of it exists then
            delay boxLoadDelay
            click (button 1 of window 1 of it)
        end if
    end tell
end tell

If the window re-opens on your system, set a higher value for boxLoadDelay. Also, if the script times out before the application has loaded, adjust the value for timeOutMax (and possibly for timeOutStep if you have to select a much higher timeout threshold).

share|improve this answer
    
Amazing! This works beautifully: Thank you very much for helping me to get rid of that pesky window: I just had to adjust the boxLoadDelay to 3 :-) tell kopischke to have A set A to "Wonderful Day" end tell –  pause-n-loop May 9 '12 at 11:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.