How to keep the application turned on / in the foreground while the script is running?

I use Applescript to automate application deployment with Xcode 4. For this, I use System Events to click menu items on the menu bar. Everything works for me, but with one quirk. If the user clicks elsewhere while my script is running, this Xcode 4 window comes out of the foreground, my whole script fails. Is there a way to get Xcode in the foreground from my script?

Now, if only Xcode 4 was at least as scriptable as Xcode 3, I would not have to resort to GUI automation.

0
source share
3 answers

mcgrailm James Bedford. " ..." , . , "Run without building".

:

tell application id "com.apple.dt.Xcode"
    activate
end tell
tell application "System Events"
    tell process "Xcode"
            repeat until sheet 1 of window 2 exists
                    click menu item "Edit Scheme…" of menu "Product" of menu bar item "Product" of menu bar 1
                    tell application "Xcode"
                            activate
                            beep
                    end tell
            end repeat
            tell sheet 1 of window 2
                    set destination to pop up button 2 of group 1
                    click destination
                    set target to "iPad 4.3 Simulator"
                    click menu item target of destination menu 1
                    set buildConfig to pop up button 3 of group 2
                    click buildConfig
                    click menu item "Debug" of menu 1 of buildConfig
                    click button "OK"
            end tell
            tell application "Xcode"
                    activate
                    beep
            end tell
            tell application id "com.apple.dt.Xcode"
                    activate
            end tell
            click menu item "Run Without Building" of menu 1 of menu item "Perform Action" of menu "Product" of menu bar item "Product" of menu bar 1
    end tell
end tell
0

activate click, , . . , , , , , script!

script , , , , , - : " script?" ! "... , :" !" script . .

+1

- , , gui, , , , ,

+1

All Articles