Using Accessibility API to find out the size and the origin for the Browser Window in a NPAPI plugin
I've been making a plugin for browsers (Safari, Chrome, firefox) in MacOSX
What I try to do is using Accessibility API to find out the size and the origin for the Browser Window in my NPAPI plugin.
In Chrome, I can get what I want but In Safari, got a error code -25204
.
AXUIElementRef app = AXUIElementCreateApplication( browserProcessID );
AXUIElementRef frontWindow = NULL;
AXError err = AXUIElementCopyAttributeValue(
app, kAXMainWindowAttribute, (CFTypeRef *)&frontWindow );
if ( err != kAXErrorSuccess ) {
NSLog(@"%d", err);
return -1;
}
-25204
is 开发者_StackOverflowkAXErrorCannotComplete in AXError.h
But I do not know why.
Any comments will be welcome.
Thanks in advance.
Given your other question on this site I'm guessing what you are actually trying to accomplish is to find out where a plugin is on screen. All you need for that is to use NPN_ConvertPoint to find where the plugin's (0,0) is in screen coordinates. That will be much easier and much less fragile than trying to use accessibility (and will actually give you the right answer; with the accessibility you will have to make assumptions about window toolbar heights, which are variable).
精彩评论