I am opening the system preferences application from within my application. I also would like to set the the applications frame so it is aligned at the left side of my application. The problem is that I do not know how to access the applications frame property, or launch it at a specific point.
I am using NSWorkspace to launch it, then get an instance of NSRunningApplication which I hope can be used to manipulate the window.
-(void)openPreferencesAndSetFrame;
{
@try {
BOOL success = [[NSWorkspace sharedWorkspace] openFile:@"/System/Library/PreferencePanes/Localization.prefPane"];
if (success == YES)
{
NSArray *appArray = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.systempreferences"];
if ([appArray count] > 0)
{
NSRunningApplication *sysPrefApp = [appArray objectAtIndex:0];
//set frame here
}
}
} @catch (NSException *exception) {
NSLog(@"%@", [exception description]);
}
}
After some research, try and error I found the solution. As mentioned AppleScript is able to do the job.