Jump to content
Sign in to follow this  

New - Script for installing duplex printer

Recommended Posts


Hello everyone. I've spent some time reading and I have been looking for ways to improve a script I have for installing new Canon printers we have at the office. I am having trouble in Windows 7 as sometimes, it takes a great deal of time for the list of printers to populate in the Add Printer Wizard and the script runs like a train straight past this, leading to some unwanted outcomes.

While on most workstations the script seems to run well, I find it is very difficult to manipulate the SysListView32 boxes, and even with specific information garnered from the AutoIT window tool, I am not able to simply have it pick out "Canon" as the manufacturer, and "Canon iR-ADV 6055/6065 UFR II" as the printer.

Here is the code for the Windows 7 script for adding the two-sided printing:

Window information:

Posted Image

Run("RUNDLL32 PRINTUI.DLL,PrintUIEntry /il")
$WT = "Add Printer"
ControlClick($WT, "", 3510, "left", "1", 227, 40)
ControlClick($WT, "", 4558, "left", "1", 227, 40)
ControlCommand($WT, "", "[CLASS:ComboBox;INSTANCE:1]", "ShowDropDown")
ControlCommand($WT, "", "[CLASS:ComboBox;INSTANCE:1]", "SelectString", '')
AutoItSetOption("SendKeyDelay",  22)
;Here is where the problem is, this is the "Install the printer driver" section
ControlClick($WT, "", "[CLASS:SysListView32; INSTANCE:1]", "left", "1", 35, 55)
;This ensures the top of the list is selected, so that when Canon is typed, it will find it
ControlClick($WT, "", "[CLASS:SysListView32; INSTANCE:1]", "left", "1", 35, 55)

;Now we click over to the right panel, where the printers are listed
ControlClick($WT, "", "[CLASS:SysListView32; INSTANCE:3]", "left", "1", 35, 55)
AutoItSetOption("SendKeyDelay",  0)

;Again, this is a mechanism for ensuring that the top of the list is reached before typing the name of the printer.
ControlClick($WT, "", "[CLASS:SysListView32; INSTANCE:3]", "left", "1", 35, 55)
SEnd("Canon iR-ADV 6055/6065 UFR II")
;Overall, this works pretty well. I would just like to know if there is something better

Send("6065_mccay Back-to-Back (Two Sided)!N")
WinWaitActive($WT, "Printer sharing")
;Turns off printer sharing (No, and next, respectively)
;This ensures the printer is not made default
If ControlCommand ($WT,"", 9020, "IsChecked", "") = 1 Then
  ControlCommand ($WT,"", 9020, "Uncheck", "")

Some extra window information as well

>>>> Window <<<<
Title: Add Printer
Class: NativeHWNDHost
Position: 486, 201
Size: 628, 458
Style: 0x96C80080
ExStyle: 0x00040100
Handle: 0x0000000000280BA2
>>>> Control <<<<
Class: SysListView32
Instance: 1
ClassnameNN: SysListView321
Advanced (Class): [CLASS:SysListView32; INSTANCE:1]
ID: 1580
Position: 38, 194
Size: 200, 113
ControlClick Coords: 47, 54
Style: 0x5021085D
ExStyle: 0x00000204
Handle: 0x00000000004507EC

I have only used AutoIT for a couple weeks now and I find it extremely useful. Anything that you can tell me that would help me use it better would be greatly appreciated!



Share this post

Link to post
Share on other sites

You could try installing it silently. That would reduce your script to one line of code.

RunWait(@ComSpec & ' /c rundll32 printui.dll,PrintUIEntry ; add switches and parameters here then rest of code

For a list of the switches & examples on how to use them:


#include <ByteMe.au3>

Share this post

Link to post
Share on other sites

That might work really well, I am not sure how to pick out a Canon printer for that, will I need to know the .inf file that it uses when it installs?

Will try a few things and find out.

Share this post

Link to post
Share on other sites

Thank you! This works very well:

rundll32 printui.dll,PrintUIEntry /if /b "6065_mccay Back-to-back (Two Sided)" /f "%windir%infntprint.inf" /r "" /m "Canon iR-ADV 6055/6065 UFR II"

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.