Monday, November 20, 2017

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

HippoMan
Member
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:

UpdateSystemActivity(OverallAct);


Is there a way to do this?

I tried this, but it failed:

|UpdateSystemActivity|(|OverallAct|)


Thanks in advance.

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


Filed under: call, Core-Services, function

Offline

 

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

HippoMan
Member
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;
@end


Then, I wrote its implementation in Util.m:

#import "Util.h"

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


Then, I add this line to my AppDelegate script:

Applescript:

property Util : class "Util" of current application

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

Applescript:

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.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)