views:

676

answers:

2

I need to write an add-on/plugin for IE 6/7 that will intercept any Javascript print() call and automatically print the page on the default printer, bypassing the standard print dialog. Unfortunately I know very little about Windows or IE programming (I come from the land of Cocoa), so I'm at a bit of a loss as to where to begin. I think I want to write a BHO, but I'm not sure. Any help is much appreciated.

I have discovered a way to achieve this effect in VBScript that resides on the webpage (overriding the Print function), so if it's as simple as wrapping that code in some sort of plugin, that would be ideal.

Thanks!

A: 

Try this.

if(navigator.appName == "Microsoft Internet Explorer"){
  var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
  document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
  PrintCommandObject.ExecWB(6, 2);
  PrintCommandObject.outerHTML = "";
} else {
  window.print();
}

But it does not work in Windows XP SP2 (and Windows Server 2003 SP1 or above).

scunliffe
That's the same as the VBScript I have. I need an add-on.
Rich Catalano
A: 

I wrote and activex control for this years ago.

And it was three two code.

SendKeys( cntrl + P )
SendKeys( enter )
Chad Grant