Jump to content

Updating drivers automatically


Recommended Posts

Hi!

I'm trying to update Windows drivers from device manager, but when i arrive to the screen 'How do you want to search drivers?" with two options: Automatically or in the PC, the commands i've tried: Send, ControlSend don't work. When i close this windows manually and i open again it works, but i can't continue in the first time.

I call the updating button directly in the toolbar because other ways don't work as sending keys

The code is translated from spanish (Device Manager -> Administrador de dispositivos)

#RequireAdmin

#Include <GuiTreeView.au3>
#Include <MsgBoxConstants.au3>


;run device manager
Run("mmc devmgmt.msc")
WinWaitActive("Device Manager")

;get the right device
$hTree = ControlGetHandle("Device Manager", "", "[Class:SysTreeView32;Instance:1]")
$hItem = _GUICtrlTreeView_FindItem($hTree, "Intel(R) 82578 Gigabit Network Connection")
;select the right device
_GUICtrlTreeView_SelectItem($hTree, $hItem, $TVGN_CARET)

; Focus treeview and Send Enter and right-click and select uninstal
ControlFocus("Device Manager", "", $hTree)

ControlCommand("Device Manager","","ToolbarWindow321","SendCommandID",24) ; WORKS OK. OPEN THE WINDOWS TO UPDATING

; DON'T WORK

WinWaitActive("Updating drivers - Intel(R) 82578 Gigabit Network Connection","");
ControlSend("Updating drivers - Intel(R) 82578 Gigabit Network Connection","","Button4","{SPACE}");
Send("{SPACE}")

 

Noname.png

Link to post
Share on other sites

Working with the focus, opening the Updating Windows it seems to work. The menu of actions was incomplete until i click on the network driver, and i try it sending de mouseclick and moving with keyboard arrows.

Here is the code:

 

#RequireAdmin
#Include <GuiTreeView.au3>
#Include <MsgBoxConstants.au3>


;run device manager
Run("mmc devmgmt.msc")
WinWaitActive("Administrador de dispositivos")

;get the right device
$hTree = ControlGetHandle("Device Manager", "", "[Class:SysTreeView32;Instance:1]")
$hItem = _GUICtrlTreeView_FindItem($hTree, "Intel(R) 82578 Gigabit Network Connection")
;select the right device
_GUICtrlTreeView_SelectItem($hTree, $hItem, $TVGN_CARET)

; Focus treeview and Send Enter and right-click and select uninstal
ControlFocus("Device Manager", "", $hTree)
MouseClick($MOUSE_CLICK_LEFT)
ControlFocus("Device Manager", "", $hTree)
WinWait("Device Manager")
Send("{HOME}{DOWN}{DOWN}{DOWN}")
WinWait("Device Manager")
Send("!cz") ; Here is the keys in spanish version

WinWait("Update drivers - Intel(R) 82578 Gigabit Network Connection")
Send("{SPACE}")

WinWait("Update drivers - Intel(R) 82578 Gigabit Network Connection","Windows finali")
Send("{SPACE}")
WinClose("Device Manager")
Exit

 

 

Link to post
Share on other sites

This is working for me :

#RequireAdmin
#AutoIt3Wrapper_UseX64=y

#Include <GuiTreeView.au3>
#Include <MsgBoxConstants.au3>
#include <GuiTab.au3>

;run device manager
Run("mmc devmgmt.msc")
Local $hWnd = WinWait("[CLASS:MMCMainFrame]")
WinActivate ($hWnd)
WinWaitActive ($hWnd)

;get the right device
Local $hTree = ControlGetHandle($hWnd, "", "SysTreeView321")
Local $hItem = _GUICtrlTreeView_FindItem($hTree, "Realtek PCIe GBE Family Controller")
_GUICtrlTreeView_SelectItem($hTree, $hItem, $TVGN_CARET)

; Focus treeview and Send Enter and right-click and select uninstal
ControlFocus($hWnd, "", $hTree)
ControlSend($hWnd,"",$hTree,"{ENTER}") ; WORKS OK.

Local $hWnd2 = WinWait ("[CLASS:#32770]")
Local $hTab = ControlGetHandle($hWnd2, "", "SysTabControl321")
Local $iTab = _GUICtrlTab_FindTab ($hTab, "Pilote")
_GUICtrlTab_ClickTab ($hTab, $iTab)
Sleep (800)
ControlClick ($hWnd2, "", "Button2")
Local $hWnd3 = WinWait ("[CLASS:NativeHWNDHost]")
Local $hButton = ControlGetHandle ($hWnd3, "", "Button4")
ConsoleWrite ($hButton & @CRLF)
ControlClick ($hWnd3, "", $hButton)

ps. when posting code, use this tool.

Edited by Nine
Link to post
Share on other sites

Finally, I modified the focus to navigate with the arrows and it works well.

Thank you for the help!

 

The code is here:

#RequireAdmin
#Include <GuiTreeView.au3>
#Include <MsgBoxConstants.au3>


;run device manager
Run("mmc devmgmt.msc")
WinActive("Device Manager")
WinWaitActive("Device Manager")

;get the right device
$hTree = ControlGetHandle("Device Manager", "", "[Class:SysTreeView32;Instance:1]")
$hItem = _GUICtrlTreeView_FindItem($hTree, "Network Adapters")
;select the right device
_GUICtrlTreeView_SelectItem($hTree, $hItem, $TVGN_CARET)

; Focus treeview and Send Enter and right-click and select uninstal
ControlFocus("Device Manager", "", $hTree)
MouseClick($MOUSE_CLICK_LEFT)
;ControlFocus("Device Manager", "", $hTree)
WinWait("Device Manager")
Send("{HOME}{DOWN}{DOWN}{RIGHT}{RIGHT}")
WinWait("Device Manager")
Send("!cz")


WinWait("Update drivers - Intel(R) 82578 Gigabit Network Connection")
Send("{SPACE}")

WinWait("Update drivers - Intel(R) 82578 Gigabit Network Connection","Windows finali")
Send("{SPACE}")
WinClose("Device Manager")
Exit

 

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

    No registered users viewing this page.

×
×
  • Create New...