Jump to content

Recommended Posts

Posted

I'm trying to print a document (pdf) to a printer, but I need to change the paperbin. I can print with adobe reader (commandline).

I searched this forum and saw the print udf, wich enabled me to change the default printer, but not the paperbin for a specific printer.

Through some goog'ling I found a code for VBA, and I wondered if this could be done with AutoIT

Private Declare Function DeviceCapabilities Lib "winspool.drv" Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, ByVal dev As Long) As Long

Function GetBinNames() As Variant

Dim iBins As Long

Dim ct As Long

Dim sNamesList As String

Dim sNextString As String

Dim sPort As String

Dim sCurrentPrinter As String

Dim vBins As Variant

'Get the printer & port name of the current printer

sPort = Trim$(Application.Printer.Port)

sCurrentPrinter = Trim$(Application.Printer.DeviceName)

'Find out how many printer bins there are

iBins = DeviceCapabilities(sCurrentPrinter, sPort, _

DC_BINS, ByVal vbNullString, 0)

'Set the string to the right size to hold all the bin names

'24 chars per name

sNamesList = String(24 * iBins, 0)

'Load the string with the bin names

iBins = DeviceCapabilities(sCurrentPrinter, sPort, _

DC_BINNAMES, ByVal sNamesList, 0)

'Set the array of bin names to the right size

ReDim vBins(0 To iBins - 1)

For ct = 0 To iBins - 1

'Get each bin name in turn and assign to the next item in the array

sNextString = Mid(sNamesList, 24 * ct + 1, 24)

vBins(ct) = Left(sNextString, InStr(1, sNextString, Chr(0)) - 1)

Next ct

'Return the array to the calling routine

GetBinNames = vBins

End Function

Posted

I couldn't set the paperbin directly, so I've had to use the printui.dll and then set the drawer with the gui.

perhaps it could be done using the Canon Printer SDK(We have a canon printer, but we don't have the SDK).

Run ('rundll32 printui.dll,PrintUIEntry /e /n "' & $printername )
    WinWaitActive ( $printertitle , ""  )
    $ctrl = ControlGetHandle($printertitle,"","SysTabControl321")
    _GUICtrlTab_ClickTab($ctrl, 2, "left", False, 10);Tabbladnummer ° 2 ===
    WinWaitActive ( $printertitle , "Paper Source"  )
    ControlCommand($printertitle,"Paper Source","ListBox1","SelectString", $lade)
    Sleep(100)
    ControlClick($printertitle,"Paper Source","Button17")
    Sleep(100)
    ControlClick($printertitle,"Paper Source","Button15")
    Sleep(100)

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
  • Recently Browsing   0 members

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