emendelson Posted June 29, 2012 Share Posted June 29, 2012 I'm working on a script that will use some freeware software to create a PDF file and then print it to the default printer (or a printer selected by the user). In order to do this correclty, I need to get the default page size (typically letter in North America or A4 elsewhere) of the current printer. Is this possible through WMI or the registry? I've spent a lot of time searching for the answer and haven't found it. Alternatively, I suppose I could check whether the system is set up for North America or Europe by testing for the DOS codepage, in this registry entry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\Nls\Codepage\OEMCP If it yields 437, then the system is setup for North America, if not, elsewhere, but I'd prefer a more direct method, and will be grateful for any help. Link to comment Share on other sites More sharing options...
Zedna Posted June 29, 2012 Share Posted June 29, 2012 Look at WMI - Win32_Printerhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa394363%28v=vs.85%29.aspx Property: CurrentPaperType Data type: string Access type: Read-only Type of paper the printer is using. Must be expressed in the form specified by the ISO/IEC 10175 Document Printing Application (DPA), which is summarized in Appendix C of RFC 1759 (Printer MIB). example of use for Win32_PrinterFunc GetDefaultPrinter() Local $result,$strComputer,$np,$colEvents $result = '' $strComputer = "." $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootcimv2") $colEvents = $objWMIService.ExecQuery _ ("Select * From Win32_Printer Where Default = TRUE");TRUE $np = 0 For $objPrinter in $colEvents $result = $objPrinter.DeviceID Next Return $result EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
emendelson Posted June 29, 2012 Author Share Posted June 29, 2012 Thank you for that. Unfortunately, if I replace "DeviceID" with anything that indicates paper sizes or types, I get an empty result. I've tried "CurrentPaperType" and "DefaultPaperType", and they both say nothing. Am I doing anything wrong? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now