Mac中启动另一个程序并将窗口置于最前面

来源:互联网 发布:iface102考勤安装软件 编辑:程序博客网 时间:2024/05/22 01:23
12345678910111213141516
- (void)launchSoftWithBundleID:(NSString *)softPath{    NSBundle *softBundle = [NSBundle bundleWithPath:softPath];    NSString *bundleID = [softBundle bundleIdentifier];    //运行程序    NSTask *softTask = [[NSTask alloc] init];    [softTask setLaunchPath:softPath];    [softTask launch];    //得到运行的程序,并置于最前面    NSArray *array = [NSRunningApplication runningApplicationsWithBundleIdentifier:bundleID];    if ([array count] > 0)    {        NSRunningApplication *runningApp = [array objectAtIndex:0];        [runningApp activateWithOptions:NSApplicationActivateIgnoringOtherApps];    }}
0 0
原创粉丝点击