Rodolfo99 Posted September 3, 2019 Share Posted September 3, 2019 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}") Link to comment Share on other sites More sharing options...
Rodolfo99 Posted September 3, 2019 Author Share Posted September 3, 2019 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 comment Share on other sites More sharing options...
Nine Posted September 3, 2019 Share Posted September 3, 2019 (edited) 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 September 3, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Earthshine Posted September 3, 2019 Share Posted September 3, 2019 windows updates already do this work. why bother? My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Rodolfo99 Posted September 3, 2019 Author Share Posted September 3, 2019 Thank you. I'll try because my solution is for machine deployment and the driver installed by default is not working for some characteristics in the network device. Thank you for the advice for the code too. I'm testing now and i'll tell you something tomorrow. Link to comment Share on other sites More sharing options...
Rodolfo99 Posted September 4, 2019 Author Share Posted September 4, 2019 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 comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now