Jump to content
Sign in to follow this  
MrWhite

Device manager - Odd menu behaviour

Recommended Posts

MrWhite

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 screenshot

I'm running Vista 64 bit and Auto IT v3.2.12.1 according to the help file.

Thanks for any hints.

Best regards.

post-42367-1226238294_thumb.jpg

Edited by MrWhite

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.