TheCurrent 0 Posted April 4, 2011 (edited) AM trying to convert this code that retrieves printer papernames ans sizes from vb6 to autoit Dim paperNumbers() As Integer, paperSizes() As POINTAPI lPaperCount = DeviceCapabilities(Printer.DeviceName, Printer.Port, DC_PAPERNAMES, ByVal vbNullString, 0) ReDim numPaper(1 To lPaperCount) sPaperNamesList = String(64 * lPaperCount, 0) ' Get paper names lPaperCount = DeviceCapabilities(Printer.DeviceName, Printer.Port, DC_PAPERNAMES, ByVal sPaperNamesList, 0) ' Get matching paper numbers ReDim paperNumbers(1 To lPaperCount) lPaperCount = DeviceCapabilities(Printer.DeviceName, Printer.Port, DC_PAPERS, paperNumbers(1), 0) ReDim paperSizes(1 To lPaperCount) lPaperCount = DeviceCapabilities(Printer.DeviceName, Printer.Port, DC_PAPERSIZE, paperSizes(1), 0) For lCounter = 1 To lPaperCount sNextString = Mid(sPaperNamesList, 64 * (lCounter - 1) + 1, 64) sNextString = Left(sNextString, InStr(1, sNextString, Chr(0)) - 1) List2.AddItem paperNumbers(lCounter) & vbTab _ & Format(paperSizes(lCounter).x / 254, "0.00") & " x " _ & Format(paperSizes(lCounter).y / 254, "0.00") _ & " inch" & vbTab & sNextString Next lCounter The auto it version Dim $numPaper[$lPaperCount[0]] $lPaperCount = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERSIZE, "str", DllStructGetPtr($paperSizes), "ptr", 0) Dim $OutPut For $lCounter = 1 To $lPaperCount-1 $sNextString = StringMid($sPaperNamesList, 64 * ($lCounter - 1) + 1, 64) $sNextString = stringLeft($sNextString, StringInStr($sNextString, Chr(0),1,1,1) - 1) $OutPut &= $paperNumbers($lCounter) & @Tab $OutPut &= StringFormat("%10.2f",$paperSizes($lCounter).x / 254) & " x " $OutPut &= StringFormat("%10.2f",$paperSizes($lCounter).y / 254) & " inch" & @tab & $sNextString @CRLF Next I don't het anything in my output. $paperSizes is suppose to be and array of points (x,y) retrieved from the dllcall Edited April 4, 2011 by oghenez Share this post Link to post Share on other sites
jvanegmond 306 Posted April 7, 2011 #include <Array.au3> $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer",Default,48) For $objPrinter In $colInstalledPrinters $arr = $objPrinter.PrinterPaperNames _ArrayDisplay($arr, $objPrinter.Name) Next Check out this too: http://stackoverflow.com/questions/5549476/dllcall-autoit-partially-getting-results github.com/jvanegmond Share this post Link to post Share on other sites
water 2,391 Posted April 7, 2011 (edited) If your printers are network printers managed by a spool server you can get a lot of information about the print queues using my AD UDF, function _AD_ListPrintQueues and _AD_GetObjectProperties. Edited April 7, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
TheCurrent 0 Posted April 7, 2011 #include <Array.au3> $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer",Default,48) For $objPrinter In $colInstalledPrinters $arr = $objPrinter.PrinterPaperNames _ArrayDisplay($arr, $objPrinter.Name) Next Check out this too: http://stackoverflow.com/questions/5549476/dllcall-autoit-partially-getting-results I tried this, but it dosen't return the actual paper sizes. it returns series of 1s. the paper sizes is suppose to be Xmm x Ymm #include <Array.au3> $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer",Default,48) For $objPrinter In $colInstalledPrinters $arr = $objPrinter.PaperSizesSupported _ArrayDisplay($arr, $objPrinter.Name) Next Share this post Link to post Share on other sites
TheCurrent 0 Posted April 7, 2011 (edited) help me get the names & sizes here, but am left with the papernumbers, please help me with the struct, thats where i get confusedin vb6 i can do thisDim paperNumbers() As Integerand pass it to the api like this' Get paper names lPaperCount = DeviceCapabilities(Printer.DeviceName, Printer.Port, DC_PAPERNAMES, ByVal sPaperNamesList, 0) ' Get matching paper numbers ReDim paperNumbers(1 To lPaperCount) lPaperCount = DeviceCapabilities(Printer.DeviceName, Printer.Port, DC_PAPERS, paperNumbers(1), 0)in autoit i did thisbut get the result posted at the buttom of that post Edited April 7, 2011 by TheCurrent Share this post Link to post Share on other sites
jvanegmond 306 Posted April 7, 2011 (edited) I tried this, but it dosen't return the actual paper sizes. it returns series of 1s. the paper sizes is suppose to be Xmm x Ymm #include <Array.au3> $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer",Default,48) For $objPrinter In $colInstalledPrinters $arr = $objPrinter.PaperSizesSupported _ArrayDisplay($arr, $objPrinter.Name) Next Yes, you need to translate the numbers yourself which is quite a simple job. Paper sizes is described on the page I linked you at: http://msdn.microsoft.com/en-us/library/aa394363(v=vs.85).aspx For example I see my printer supports 8 which is A3. I know that it is 297x420 so I would make this code: Switch $paperSizeType Case 8 Return "A3 (297mm x 420mm)" EndSwitch The solution is not as good as the one MrMitchell gave you in the other thread, but when you say you "have been doing this for four days now by myself" doing this would mean that you were done 3 days ago. Edited April 7, 2011 by Manadar github.com/jvanegmond Share this post Link to post Share on other sites
TheCurrent 0 Posted April 7, 2011 what i meant by "have been doing this for four days now by myself" is that i have been trying to do it myself without successBy the way, how do i pass an array or int to dllcall and retrieve the result?i tried this$result = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERNAMES, "str", Chr(0), "long", 0) ;Create all the structures to retrieve the necessary values $NumberStruct = "" For $i = 1 To $result[0] $NumberStruct &="int;" Next $NumberStruct = StringTrimRight($NumberStruct, 1) $pNumberStruct = DllStructCreate($NumberStruct) ;Get paper Numbers $result1 = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERS, "ptr", DllStructGetPtr($pNumberStruct), "long", 0) For $i = 1 To $result[0] ConsoleWrite(DllStructGetData($pNumberStruct, $i) & @CRLF) Nexti got thisexpandcollapse popup196609 327684 524295 4325385 11534511 11665585 11796659 11927733 12058807 12189881 12320955 12452029 12583103 12714177 12845251 12976325 13107399 13238473 13369547 2147418317 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0which is not complete or somthing. what am i doing wrong? Share this post Link to post Share on other sites