MrWhite Posted November 9, 2008 Posted November 9, 2008 (edited) Hi all,I'm trying to disable and re-enable a specific audio device on my PC. I'm doing this, as the PC tends to "forget" this device and does not send sound to it under certain circumstances.The code works well up to the point where I try to de-activate the device through the menu of the device manager.If I run through the motions by hand, the "Aktionen" menu contains ca. 7 entries, one of them being "De-activate".If the code runs, in most cases the menu doesn't show the expected content, but only a single entry "Hilfe" (i.e. Help). The expected item in the tree view is selected, but the menu behaves, as if NO entry is selected. Here's the code:#RequireAdmin #include-once #Include <GuiTreeView.au3> Const $deviceManager = "Geräte-Manager" ; Open Device Manager If Not WinExists($deviceManager) Then Run(@ComSpec & " /c " & 'devmgmt.msc', "", @SW_HIDE) Else WinActivate($deviceManager) EndIf WinWaitActive($deviceManager) ; Select the device in the device manager $hTree = ControlGetHandle($deviceManager, "", "[Class:SysTreeView32;Instance:1]") ControlFocus($deviceManager, "", $hTree) $hRoot = _GUICtrlTreeView_GetFirstItem($hTree) $hAudio = _GUICtrlTreeView_GetItemByIndex($hTree, $hRoot, 1) _GUICtrlTreeView_SelectItemByIndex($hTree, $hAudio, 2) ; This is just in case that the menu needs some time to initialize Sleep(1000) ; What I need now is to de-activate the device by sending Alt-T e and re-activate ; it by sending Alt-T t ;$result = ControlSend($deviceManager, "", $hTree, "!te") Send("!t"); I've left out sending e to visualize the "broken" menu ; both variants don't work consistently - see screenshotI'm running Vista 64 bit and Auto IT v3.2.12.1 according to the help file.Thanks for any hints.Best regards. Edited November 9, 2008 by MrWhite
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