Friday, July 20, 2018

#1 2009-09-14 07:49:17 am

Registered: 2008-09-18
Posts: 114

Invoking a Core Services function?

I'm brand new to ASOC. I've read the tutorials and as much of the documentation as I can find, but I still don't know how to do something fairly basic.

I would like to make a Core Services function call from AppleScript within my ASOC app. Here's an example of a Core Services function that I want to invoke:


Is there a way to do this?

I tried this, but it failed:


Thanks in advance.

Last edited by HippoMan (2009-09-14 10:47:41 am)

Filed under: call, Core-Services, function



#2 2009-09-14 10:23:22 am

Registered: 2008-09-18
Posts: 114

Re: Invoking a Core Services function?

Well, I figured out an indirect way of doing this.

First, I created a utility class in a file called Util.h:

#import <Cocoa/Cocoa.h>

@interface Util : NSObject {}
+(int) updateActivity;

Then, I wrote its implementation in Util.m:

#import "Util.h"

@implementation Util
+(int) updateActivity {
    return UpdateSystemActivity(OverallAct);

Then, I add this line to my AppDelegate script:


property Util : class "Util" of current application

And finally, I can then call the function inside of this AppDelegate as follows:


Util's updateActivity()

This seems to work, but I'd still like to know if there's a way to make a direct call to that Core Services function from the ASOC AppleScript code, without having to create that auxiliary class.

Thanks again in advance.



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)