Sign in to follow this  
Followers 0
vmitchell85

Selecting SysListView

3 posts in this topic

First off this is my first script and I have looked through the help as well as searched on the forums.

What I am trying to do is to create a script to install a network printer. I haven't had too many issues that I couldn't figure out but my current issue is selecting the driver to use. I need to select HP on the left list view and then the Laserjet 8150 on the right. I got the ID codes and everything but it wouldn't select. Here is my code, I can post screenshots if needed.

Thanks in advance for your assistance.

; Open Run
Send("#r")
; Open Printers
WinWaitActive("Run")
Send("control printers")
Send("{ENTER}")
; Wait for Printer window
WinWaitActive("Printers and Faxes")
; Open Add Printer
Send("{ALTDOWN}")
Send("f")
Send("a")
Send("{ALTUP}")
; Wait for the window to open
WinWaitActive("Add Printer Wizard")
; Hit Next
Send("!n")
; Uncheck auto add
ControlCommand( "Add Printer Wizard", "&Automatically detect and install my Plug and Play printer", 4665, "UnCheck")
; Hit Next
Send("!n")
; Select Create New Port
ControlCommand( "Add Printer Wizard", "&Create a new port:", 4558, "Check")
; Select TCP/IP
ControlCommand( "Add Printer Wizard", "", 4557, "SelectString", 'Standard TCP/IP Port')
; Hit Next
Send("!n")
; Wait for the window to open
WinWaitActive("Add Standard TCP/IP Printer Port Wizard")
; Hit Next
Send("!n")
; Enter IP Address 10.6.28.131
Send("10.6.28.131")
; Hit Next
Send("!n")
; Hit Finish
Send("{ENTER}")
; Message to wait for printer lists to appear
MsgBox(16, "ATTENTION!", "Click OK when the printer lists have appeared!")
WinWaitActive("Add Printer Wizard")
; Navigate to SysListView ID 1580
Send("{TAB}")
Send("{TAB}")
; Select HP from list
ControlCommand( "Add Printer Wizard", "", 1580, "SelectString", 'HP')

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

First you can start the wizard directly...

; http://vb.mvps.org/tips/shellcpl.txt
run("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter")

Then I would switch from send() to controlsend() functions (use Au3Info.exe to find the correct values for the listviews).

Edit: And btw, system listview can only be accessed with the correct output arch, meaning you've got a 64bit windows, then you'll have to compile the script in 64bit and vice versa.

Edited by KaFu

Share this post


Link to post
Share on other sites

That worked perfectly... Thanks a TON!

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