npapibrowser-plugin

How to force the browser to maximize (like pressing F11) from an NPAPI plugin?


I have a scriptable NPAPI browser plugin.
I would like to expose a method to javascript "MaximizeBrowser",
that will cause the browser window to maximize (as if the user pressed F11 in the broswer).
Is there a way to achieve that?

The selected answer works (at least on Windows)!
Here is my code, in case someone needs:

// simulate F11 keyboard key press
keybd_event(VK_F11,MapVirtualKey(VK_F11,0),0,0); 
keybd_event(VK_F11,MapVirtualKey(VK_F11,0),KEYEVENTF_KEYUP,0); 

Solution

  • There's certainly no supported way using the NPAPI APIs, but depending on what OS you are targeting you could try using OS-level calls to simulate a keyboard event matching the browser's full-screen mode. That will of course be fragile since it depends on every browser you are targeting a) having a full screen mode, and b) never changing the shortcut.

    If your goal is to have your plugin content be full-screen, perhaps you should instead consider opening a full-screen window from your plugin, which is how other NPAPI plugins go full-screen.