Popular Post Nine Posted October 14, 2023 Popular Post Share Posted October 14, 2023 (edited) In this topic, it was mentioned by @mLipok that it could be doable to manage printers with winspool.drv DLL. It was enough to get my attention on it. I do not remember seeing any UDF gathering all those functions. Func _PRNT_GetDefaultPrinter() Func _PRNT_SetDefaultPrinter($sPrinter) Func _PRNT_OpenPrinter($sName) Func _PRNT_ClosePrinter($hPrinter) Func _PRNT_GetPrinterInfo($hPrinter, $bGlobal, $bRAW = False) Func _PRNT_SetPrinterInfo($hPrinter, $iProp, $iValue, $bGlobal) Func _PRNT_EnumPrinters() Func _PRNT_IsValidDevmode($tDevMode) Func _PRNT_EnumJobs($hPrinter) Version 2023-10-17 *added new functions _PRNT_IsValidDevmode and _PRNT_EnumJobs Version 2023-10-15 * solved a problem where garbage collector would destroy $tDevMode after a while on return of _PRNT_GetPrinterInfo There is a multitude of other functions that could be part of this UDF, but I have decided to stop here and see how you like it. If you have comments or suggestions, they are always welcome. Printer_UDF.zip Edited October 17, 2023 by Nine AutoBert, robertocm, mLipok and 3 others 4 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
taurus905 Posted October 14, 2023 Share Posted October 14, 2023 @Nine Thank you for the nice looking UDF with an example script to run. I didn't look closely at this, but wanted to show you the error I received by running the script: Line 17 ConsoleWrite($tDevMode.Duplex & @CRLF) ConsoleWrite($tDevMode^ ERROR Error: Variable must be of type "Object". Also: Printer_UDF.au3"(62,28) : error: missing separator character before keyword. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Andreik Posted October 14, 2023 Share Posted October 14, 2023 Use without fear @error macro to see what function (before line 17) failed and why. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Nine Posted October 14, 2023 Author Share Posted October 14, 2023 @taurus905 You seems to have an old version of AutoIt. If the duplex component of the DevMode structure is absent, that could explain your issue. So print out $tagDEVMODE so we can identify if it's missing. And check all @error that you can intercept like @Andreik rightly told you. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
taurus905 Posted October 14, 2023 Share Posted October 14, 2023 @Nine Is this the right version? I will check the rest later. Thank you. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
taurus905 Posted October 15, 2023 Share Posted October 15, 2023 I guess I don't know how to troubleshoot this. @error doesn't get triggered even after adding it below each line before this: Example.au3" (22) : ==> Variable must be of type "Object".: ConsoleWrite($tDevMode.Duplex & @CRLF) ConsoleWrite($tDevMode^ ERROR My "WinAPIGdi.au3" is datestamped 9/14/2022 and is 200kb Global Const $tagDEVMODE = 'wchar DeviceName[32];ushort SpecVersion;ushort DriverVersion;ushort Size;ushort DriverExtra;dword Fields;short Orientation;short PaperSize;short PaperLength;short PaperWidth;short Scale;short Copies;short DefaultSource;short PrintQuality;short Color;short Duplex;short YResolution;short TTOption;short Collate;wchar FormName[32];ushort Unused1;dword Unused2[3];dword Nup;dword Unused3;dword ICMMethod;dword ICMIntent;dword MediaType;dword DitherType;dword Reserved1;dword Reserved2;dword PanningWidth;dword PanningHeight' I am curious if there is something wrong with my install. Thanks for any help. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Andreik Posted October 15, 2023 Share Posted October 15, 2023 5 hours ago, taurus905 said: Printer_UDF.au3"(62,28) : error: missing separator character before keyword. There is a missing space in line 62 of the UDF If @error Or Not $aRet[0]Then Return SetError(1) should be If @error Or Not $aRet[0] Then Return SetError(1) When the words fail... music speaks. Link to comment Share on other sites More sharing options...
taurus905 Posted October 15, 2023 Share Posted October 15, 2023 3 minutes ago, Andreik said: There is a missing space in line 62 of the UDF I saw that and fixed it before. Same issue. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Andreik Posted October 15, 2023 Share Posted October 15, 2023 The other error is related to this line from _PRNT_GetPrinterInfo() Local $tDevMode = DllStructCreate($tagDEVMODEex, $tPointer.pDevMode) If $tPointer.pDevMode is null the creation of this structure fails. You can check this by adding If @error Then MsgBox(0,'Error', @error & @CRLF & $tPointer.pDevMode) right after and you'll probably see error 3 and 0x00000000. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
taurus905 Posted October 15, 2023 Share Posted October 15, 2023 How can this work for others and not for me? Example.au3"(17,71) : error: $tPointer: undeclared global variable. If @error Then MsgBox(0,'Error', @error & @CRLF & $tPointer.pDevMode) taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Nine Posted October 15, 2023 Author Share Posted October 15, 2023 Ok I just found a problem with the garbage collector. Since $tDevMode is part of another structure ($tBuff), it will get destroy after a little while after return, so I needed to create a perm $tDevmode before return. New version available “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted October 17, 2023 Author Share Posted October 17, 2023 Added support to two new functions, new version available argumentum and mLipok 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
water Posted October 30, 2023 Share Posted October 30, 2023 Added this UDF the wiki 🙂 argumentum 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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