• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Extraction of Information from Apple System Profiler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extraction of Information from Apple System Profiler


  • Subject: Re: Extraction of Information from Apple System Profiler
  • From: Nathan Day <email@hidden>
  • Date: Thu, 20 Dec 2001 23:03:38 +1030

This is pretty much cut straight out out of a one of my own projects with some small changes, you have to include Carbon. I haven't found a way to do this sort of thing yet using straight Cocoa. Email me if you can not get it to work. I have a whole set of classes for compiling and executing apple scripts including sending apple events to them which I could send to you if you want.

+ (id)compileExecuteString:(NSString *) aString
{
OSAID theResultID;
AEDesc theResultDesc = { typeNull, NULL },
theScriptDesc = { typeNull, NULL };
id theResultObject = nil;

if( (AECreateDesc( typeChar, [aString cString], [aString cStringLength], &theScriptDesc) == noErr) && (OSACompileExecute
( [AppleScriptObject OSAComponent], &theScriptDesc, kOSANullScript, kOSAModeNull, &theResultID) == noErr ) )
{
if( OSACoerceToDesc( [AppleScriptObject OSAComponent], theResultID, typeWildCard, kOSAModeNull, &theResultDesc ) == noErr )
{
if( theResultDesc.descriptorType == typeChar )
{
theResultObject = [NSString stringWithAEDesc:&theResultDesc];
AEDisposeDesc( &theResultDesc );
}
}
AEDisposeDesc( &theScriptDesc );
if( theResultID != kOSANullScript )
OSADispose( [AppleScriptObject OSAComponent], theResultID );
}

return theResultObject;
}

+ (ComponentInstance)OSAComponent
{
static ComponentInstance theComponent = NULL;

if( !theComponent )
{
theComponent = OpenDefaultComponent( kOSAComponentType, kAppleScriptSubtype );
}
return theComponent;
}

@implementation NSString (AEDescCreation)

/*
* + stringWithAEDesc:
*/
+ (id)stringWithAEDesc:(const AEDesc *)aDesc
{
NSData * theTextData;

theTextData = [NSData dataWithAEDesc: aDesc];

return ( theTextData == nil ) ? nil : [[[NSString alloc]initWithData:theTextData encoding:NSMacOSRomanStringEncoding] autorelease];
}

@end


On Tuesday, December 18, 2001, at 07:18 AM, Cynthia Copenhagen wrote:

I am new at Cocoa and am trying to figure out how I can get strings out of
some of the fields in the Apple System Profiler.

The Apple Script goes something like:

tell application "Apple System Profiler"
get system version as text
end tell

What I am not sure of is how to go through a Cocoa script to call the
AppleScript command.

I have looked everywhere for an example and have read about scripting in the
documentation.

Could someone please tell me where I can find an example?


References: 
 >Extraction of Information from Apple System Profiler (From: Cynthia Copenhagen <email@hidden>)

  • Prev by Date: AutoreleasePool mechanics
  • Next by Date: Crash, and crash again
  • Previous by thread: Extraction of Information from Apple System Profiler
  • Next by thread: Desktop fusion
  • Index(es):
    • Date
    • Thread