开发者

Using Accessibility API to find out the size and the origin for the Browser Window in a NPAPI plugin

开发者 https://www.devze.com 2023-01-26 11:20 出处:网络
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.

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消