kAXPositionAttribute and kAXSizeAttribute
kAXPositionAttribute and kAXSizeAttribute
- Subject: kAXPositionAttribute and kAXSizeAttribute
- From: spiderlama <email@hidden>
- Date: Thu, 19 Jul 2007 12:31:58 +1000
Gday all,
I'm trying to read kAXPositionAttribute and kAXSizeAttribute (using
the accessibility framework) from the Dock, directly into a NSRect.
I've tried with CFPoint and CFSize but this makes little difference
to the results. I know that I have the correct AXUIElementRef, and
getting other attributes works correctly. Below is some resultant
output, and code.
NSRect output:
2007-07-19 12:24:21.040 Listener[1903] Position: (0.000000, nan)
2007-07-19 12:24:21.042 Listener[1903] Size: 0.000000 x 0.000000
CFPoint and CFSize output:
2007-07-19 11:59:06.446 Listener[1708] Position: (0.000000, 0.000000)
2007-07-19 11:59:06.447 Listener[1708] Size: 0.000000 x -1.875000
Stripped code is below:
- (void) applicationDidFinishLaunching: (NSNotification *)
aNotification {
pid_t dockPid = 138; // manually
dock = AXUIElementCreateApplication(dockPid); // attach to dock process
NSArray *array; // get dock container (the juicy attributes)
AXUIElementCopyAttributeValue(dock, kAXChildrenAttribute,
(CFTypeRef*)&array);
dock = (AXUIElementRef)[array objectAtIndex: 0]; // set dock container
[self doSomething];
}
- (void) doSomething {
NSRect rect; // dock rect
AXUIElementCopyAttributeValue(dock, kAXPositionAttribute, (CFTypeRef
*)&rect.origin);
AXUIElementCopyAttributeValue(dock, kAXSizeAttribute, (CFTypeRef *)
&rect.size);
NSLog(@"Position: (%f, %f)", rect.origin.x, rect.origin.y);
NSLog(@"Size: %f x %f", rect.size.width, rect.size.height);
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden