Monday, February 8, 2010

Hacking the Print Function (Flash)

Printing in Flash without the dialog box is not a trivial issue. It can mainly be done in the following methods:

1. Having a wrapper around the SWF (by programs such as Zinc and SWFKit)
2. Hacking the Registry in the Operating System
3. Automatic clicking, such as auto-hot-key
4. Javascript clicking

I tried all four methods, and here are the results:

Method 1 works the best, the codes for using method #1 is really just:
FlashPlayer.showPrintDlg = false;
(this is in FFishScript which is SWFKit's language)

Method 2 does not work (at least for vista) which is what the Kiosk OS is on.

Method 3 does not work too. At least for me.

Method 4 works, but I don't actually launch my print function from within the SWF mode. I launch it in projector mode. The codes for Javascript method is:

<script language="JavaScript">
function printit() {
window.print();
}
</script>

Testing

<script language='VBScript'>
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>

No comments: