(Re-)Launching CPM from within BBEdit

For those of us who go back and forth between editing the code with CPM and BBEdit, the following bash-file can be used as a unix-script in BBEdit to (re)launch whatever project is currently active in CPM. I've bound it also to cmd-R, and it seems to work well.

It allows you to deploy CPM for what it currently is brilliant for (asset management, file-gathering and Corona launching), while using BBedit for code editing (until maybe the next CPM release ;-)).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
 
CPM_PATH="/Applications/Corona Project Manager"
 
# In order for the simulator relaunch to work, "Enable access for assistive devices" must be selected in System Preferences > Universal Access.
 
osascript <<- APPLESCRIPT
 
        on appIsRunning(appName)
                tell application "System Events" to (name of processes) contains appName
        end appIsRunning
 
        on selectAppMenuItem(app_name, menu_name, menu_item)
                 try
                 -- bring the target application to the front
                        tell application app_name
                                 activate
                        end tell
                        tell application "System Events"
                                tell process app_name
                                        tell menu bar 1
                                                tell menu bar item menu_name
                                                        tell menu menu_name
                                                                click menu item menu_item
                                                        end tell
                                                end tell
                                        end tell
                                end tell
                        end tell
                        return true
                        on error error_message
                        return false
                end try
        end selectAppMenuItem
 
        if appIsRunning("Corona Project Manager") then
                selectAppMenuItem("Corona Project Manager","Project","Launch")
        else
                tell application "Terminal"
                do script "$CPM_SIM_PATH $BB_DOC_PATH"
                end tell
        end if
 
APPLESCRIPT

Hey FrankS.

Any chance you would make something like this for Fraise (formerly known as smultron) ?

Sorry - no can do...

However, that script may also work with TextWrangler (free BBedit "lite")... but I haven't tried.

Cheers, FrankS.

Heh no probs, was worth asking :)

Keep up the good work, you are certainly coming up with some great stuff here.

The script works fine in TextWrangler

Thank you

views:1573 update:2011/10/12 9:17:43
corona forums © 2003-2011