Skip to content

Commit

Permalink
Add several schemes for launching an app.
Browse files Browse the repository at this point in the history
  • Loading branch information
BarkyTheDog committed Jan 11, 2015
1 parent 78bc66e commit 2642d2d
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 18 deletions.
1 change: 1 addition & 0 deletions LaunchHardCodedScript.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tell application "TextEdit" to runtell application "TextEdit" to activate
Expand Down
4 changes: 4 additions & 0 deletions LaunchParameterizedScript.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
on launch_app(user_message)
tell application user_message to run
tell application user_message to activate
end launch_app
53 changes: 53 additions & 0 deletions LauncherApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
objects = {

/* Begin PBXBuildFile section */
66118B5F1A62D094000C75E8 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66118B5E1A62D094000C75E8 /* Carbon.framework */; };
66118B631A62D1D7000C75E8 /* LaunchParameterizedScript.applescript in Sources */ = {isa = PBXBuildFile; fileRef = 66118B621A62D1D7000C75E8 /* LaunchParameterizedScript.applescript */; };
66F652F61A6191AE00BC460D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F652F51A6191AE00BC460D /* AppDelegate.m */; };
66F652F81A6191AE00BC460D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F652F71A6191AE00BC460D /* main.m */; };
66F652FA1A6191AE00BC460D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 66F652F91A6191AE00BC460D /* Images.xcassets */; };
66F652FD1A6191AF00BC460D /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 66F652FB1A6191AF00BC460D /* MainMenu.xib */; };
66F653091A6191AF00BC460D /* LauncherAppTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F653081A6191AF00BC460D /* LauncherAppTests.m */; };
66F6531A1A61942300BC460D /* LauncherViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F653181A61942300BC460D /* LauncherViewController.m */; };
66F6531B1A61942300BC460D /* LauncherViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 66F653191A61942300BC460D /* LauncherViewController.xib */; };
66F653351A62060C00BC460D /* LaunchWithSystemCall.c in Sources */ = {isa = PBXBuildFile; fileRef = 66F653331A62060C00BC460D /* LaunchWithSystemCall.c */; };
66F653381A62CADE00BC460D /* LaunchHardCodedScript.applescript in Sources */ = {isa = PBXBuildFile; fileRef = 66F653371A62CADE00BC460D /* LaunchHardCodedScript.applescript */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -27,6 +31,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
66118B5E1A62D094000C75E8 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
66118B621A62D1D7000C75E8 /* LaunchParameterizedScript.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; path = LaunchParameterizedScript.applescript; sourceTree = SOURCE_ROOT; };
66F652EF1A6191AE00BC460D /* LauncherApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LauncherApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
66F652F31A6191AE00BC460D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
66F652F41A6191AE00BC460D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand All @@ -40,13 +46,17 @@
66F653171A61942300BC460D /* LauncherViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LauncherViewController.h; sourceTree = "<group>"; };
66F653181A61942300BC460D /* LauncherViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LauncherViewController.m; sourceTree = "<group>"; };
66F653191A61942300BC460D /* LauncherViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LauncherViewController.xib; sourceTree = "<group>"; };
66F653331A62060C00BC460D /* LaunchWithSystemCall.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = LaunchWithSystemCall.c; sourceTree = "<group>"; };
66F653341A62060C00BC460D /* LaunchWithSystemCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LaunchWithSystemCall.h; sourceTree = "<group>"; };
66F653371A62CADE00BC460D /* LaunchHardCodedScript.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; path = LaunchHardCodedScript.applescript; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
66F652EC1A6191AE00BC460D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
66118B5F1A62D094000C75E8 /* Carbon.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -65,6 +75,7 @@
children = (
66F652F11A6191AE00BC460D /* LauncherApp */,
66F653051A6191AF00BC460D /* LauncherAppTests */,
66F653211A61CBB600BC460D /* Frameworks */,
66F652F01A6191AE00BC460D /* Products */,
);
sourceTree = "<group>";
Expand All @@ -81,6 +92,7 @@
66F652F11A6191AE00BC460D /* LauncherApp */ = {
isa = PBXGroup;
children = (
66F653361A62CACD00BC460D /* Scripts */,
66F652F41A6191AE00BC460D /* AppDelegate.h */,
66F652F51A6191AE00BC460D /* AppDelegate.m */,
66F652F91A6191AE00BC460D /* Images.xcassets */,
Expand All @@ -89,6 +101,8 @@
66F653171A61942300BC460D /* LauncherViewController.h */,
66F653181A61942300BC460D /* LauncherViewController.m */,
66F653191A61942300BC460D /* LauncherViewController.xib */,
66F653331A62060C00BC460D /* LaunchWithSystemCall.c */,
66F653341A62060C00BC460D /* LaunchWithSystemCall.h */,
);
path = LauncherApp;
sourceTree = "<group>";
Expand Down Expand Up @@ -119,6 +133,23 @@
name = "Supporting Files";
sourceTree = "<group>";
};
66F653211A61CBB600BC460D /* Frameworks */ = {
isa = PBXGroup;
children = (
66118B5E1A62D094000C75E8 /* Carbon.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
66F653361A62CACD00BC460D /* Scripts */ = {
isa = PBXGroup;
children = (
66118B621A62D1D7000C75E8 /* LaunchParameterizedScript.applescript */,
66F653371A62CADE00BC460D /* LaunchHardCodedScript.applescript */,
);
name = Scripts;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -129,6 +160,7 @@
66F652EB1A6191AE00BC460D /* Sources */,
66F652EC1A6191AE00BC460D /* Frameworks */,
66F652ED1A6191AE00BC460D /* Resources */,
66118B5B1A62CC79000C75E8 /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -214,12 +246,31 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
66118B5B1A62CC79000C75E8 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "osacompile -d -o LaunchHardCodedScript.scpt LaunchHardCodedScript.applescript\nosacompile -d -o LaunchParameterizedScript.scpt LaunchParameterizedScript.applescript";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
66F652EB1A6191AE00BC460D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
66F6531A1A61942300BC460D /* LauncherViewController.m in Sources */,
66F653381A62CADE00BC460D /* LaunchHardCodedScript.applescript in Sources */,
66F653351A62060C00BC460D /* LaunchWithSystemCall.c in Sources */,
66118B631A62D1D7000C75E8 /* LaunchParameterizedScript.applescript in Sources */,
66F652F81A6191AE00BC460D /* main.m in Sources */,
66F652F61A6191AE00BC460D /* AppDelegate.m in Sources */,
);
Expand Down Expand Up @@ -408,6 +459,7 @@
66F6530E1A6191AF00BC460D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
66F6530F1A6191AF00BC460D /* Build configuration list for PBXNativeTarget "LauncherAppTests" */ = {
isa = XCConfigurationList;
Expand All @@ -416,6 +468,7 @@
66F653111A6191AF00BC460D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
1 change: 1 addition & 0 deletions LauncherApp/LaunchHardCodedScript.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tell application "TextEdit" to runtell application "TextEdit" to activate
Expand Down
27 changes: 27 additions & 0 deletions LauncherApp/LaunchWithSystemCall.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// LaunchWithSystemCall.cpp
// LauncherApp
//
// Created by Philip Schneider on 1/10/15.
// Copyright (c) 2015 Code From Above, LLC. All rights reserved.
//

#include "LaunchWithSystemCall.h"
#include <stdlib.h>

void launchWithSystemCall(const char * const app)
{
if (!app)
return;

char scriptCode[256];
sprintf(scriptCode, "tell application \\\"%s\\\" to run\n\
tell application \\\"%s\\\" to activate",
app, app);

char commandLine[256];
sprintf(commandLine, "osascript -e \"%s\"", scriptCode);

int result = system(commandLine);

}
16 changes: 16 additions & 0 deletions LauncherApp/LaunchWithSystemCall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// LaunchWithSystemCall.h
// LauncherApp
//
// Created by Philip Schneider on 1/10/15.
// Copyright (c) 2015 Code From Above, LLC. All rights reserved.
//

#ifndef __LauncherApp__LaunchWithSystemCall__
#define __LauncherApp__LaunchWithSystemCall__

#include <stdio.h>

void launchWithSystemCall(const char * const app);

#endif /* defined(__LauncherApp__LaunchWithSystemCall__) */
Loading

0 comments on commit 2642d2d

Please sign in to comment.