Jump to content

Printer Manager


Nine
 Share

Recommended Posts

@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

@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.

Link to comment
Share on other sites

@Nine Is this the right version?

I will check the rest later.

Thank you.

taurus905

image.png.a1be5c8a9c87020a7abc7383709d430f.png

"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

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

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

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

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

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 :)

Link to comment
Share on other sites

  • 2 weeks later...

Added this UDF the wiki 🙂

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...