Sign in to follow this  
Followers 0
ChristopherPaine

New - Script for installing duplex printer

4 posts in this topic

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"
WinWaitActive($WT)
ControlClick($WT, "", 3510, "left", "1", 227, 40)
ControlClick($WT, "", 4558, "left", "1", 227, 40)
WinWaitActive($WT)
ControlCommand($WT, "", "[CLASS:ComboBox;INSTANCE:1]", "ShowDropDown")
ControlCommand($WT, "", "[CLASS:ComboBox;INSTANCE:1]", "SelectString", '192.168.1.27_mccay')
AutoItSetOption("SendKeyDelay",  22)
Send("{ENTER}!N")
;Here is where the problem is, this is the "Install the printer driver" section
WinWaitActive($WT)
ControlClick($WT, "", "[CLASS:SysListView32; INSTANCE:1]", "left", "1", 35, 55)
SEnd("A")
;This ensures the top of the list is selected, so that when Canon is typed, it will find it
Sleep(1000)
ControlClick($WT, "", "[CLASS:SysListView32; INSTANCE:1]", "left", "1", 35, 55)
SEnd("Canon")

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

SEnd("{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}")
;Again, this is a mechanism for ensuring that the top of the list is reached before typing the name of the printer.
Sleep(100)
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("!N")
WinWaitActive($WT)
Send("!U!N")
WinWaitActive($WT)
Send("6065_mccay Back-to-Back (Two Sided)!N")
WinWaitActive($WT)
WinWaitActive($WT, "Printer sharing")
Send("!O!N")
;Turns off printer sharing (No, and next, respectively)
WinWaitActive($WT)
;This ensures the printer is not made default
If ControlCommand ($WT,"", 9020, "IsChecked", "") = 1 Then
  ControlCommand ($WT,"", 9020, "Uncheck", "")
EndIf
Send("!F")

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
Name:
Advanced (Class): [CLASS:SysListView32; INSTANCE:1]
ID: 1580
Text:
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!

Cheers,

C

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 "192.168.1.27_mccay" /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  
Followers 0