Sign in to follow this  
Followers 0
skoota

Scripting Windows XP Device Manager

7 posts in this topic

Hello All,

I am a new user to AutoIt, and need to design a script which will open the Windows XP Device Manager, expand the "Mice and other pointing devices" device type (in the tree view), and open the properties for a device titled "USB Human Interface Device". I am able to open the Device Manager using the following code:

; Open the Device Manager
Run(@ComSpec & " /c " & 'devmgmt.msc', "", @SW_HIDE)

; Wait for Device Manager window to become active
WinWaitActive("Device Manager")

However, after this point I am stuck. Using AutoIt Window Info, it seems that the Device Manager tree view is a SysTreeView control and does not have a control id (see the screen shot below). So, I am unsure how I can control this SysTreeView? If anyone has any suggestions on how to control the SysTreeView, and open the properties of the "Mice and other pointing devices" > "USB Human Interface Device" I would greatly appreciate your suggestions.

Thanks,

Matt

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

In XP, once the device manager is open, send a "{TAB}" to highlight the first item on the list then send "mice" and that will take you to the "mice and other pointing devices".

Send the numeric keypad "+" sign and that will expand the branch. Use the same techniques to move to "USB Human Interface Device"

I haven't looked, but I'm sure this would also be scriptable using the some of the listview specific functions.

What do you want to once you get there?

Change a setting? View the information? Delete an item?

Edited by ResNullius

Share this post


Link to post
Share on other sites

#Include <GuiTreeView.au3>

ShellExecute('devmgmt.msc')

WinWaitActive("Device Manager")

$hTree = ControlGetHandle("Device Manager", "", "[Class:SysTreeView32;Instance:1]")

$hItem = _GUICtrlTreeView_FindItem($hTree, "USB Human Interface Device")
_GUICtrlTreeView_SelectItem($hTree, $hItem, $TVGN_CARET)

; Focus treeview and Send Enter
ControlFocus("Device Manager", "", $hTree)
ControlSend("Device Manager", "", $hTree, "{ENTER}")

Exit


"be smart, drink your wine"

Share this post


Link to post
Share on other sites
Devcon is your friend

Share this post


Link to post
Share on other sites

I would first like to thank everyone who provided feedback. In particular, thanks to Siao to the fantastic segment of code which accomplished exactly what I needed.

I have now encountered another issue. I am attempting to automate the installation of a Bluetooth device (mobile phone). I have gotten AutoIt to automate up until the window where you need to select the device to add. The devices are being displayed within a SysListView32, in a graphical format rather than pure list (see the screen shot below), and I can't figure out how to select the device by name from the list. It is essential that the device is selected by name, as other computers may have multiple Bluetooth devices listed (rather than just one) so I can't simply say select the first device in the list.

So, in a nutshell, I need AutoIt to select the "K800i" device by name, and click the "Next" button (which becomes enabled once the device is selected).

Any help would be greatly appreciated.

Thanks,

Matt

post-33895-1206760023_thumb.jpg

Share this post


Link to post
Share on other sites

Hi All,

Don't worry, figured this one out myself. This can be done with the following code:

; Find K800i Device
$deviceIndex = ControlListView("Add Bluetooth Device Wizard", "", 1031, "FindItem", "K800i")
; Select K800i Device
ControlListView("Add Bluetooth Device Wizard", "", 1031, "Select", $deviceIndex)
; Click NEXT button
;send("!n")

Share this post


Link to post
Share on other sites

Devcon is your friend

You are the Man!!!, this is something I've been looking for.

The AutoIT community ROCKS, you guy (and gals) are always so much help.

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