Jump to content

Recommended Posts

Posted (edited)

I am writing a script that will detect when headphones are plugged into/unplugged from my laptop so that I can mute/unmute the master volume when these events occur.  The audio driver provides a tooltip notification in the system tray when a plug/unplug event occurs.  Maddeningly, it does not provide a mechanism to mute/unmute based on this event.

I have used Window Info to get the class and title of the popup tooltip.  However, when I try to use this information in WinExists or WinWaitActive, the window is never found.  I have written a test script using WinList to enumerate all windows and that tooltip never appears in the active window list.

Here is the script I am trying to run for now on my Windows 8 laptop.  The message box never fires.

The other threads I have found regarding this issue make it seem like this should be pretty straightforward.  Anyone have any pointers or advice?

$windowtitle = "[TITLE:You just plugged a device into the audio jack.;CLASS:tooltips_class32]"
$windowtext = ""
 
Do
   If WinExists($windowtitle, $windowtext) Then
      MsgBox(0,"Unplugged","The headphones were unplugged.")
   EndIf
Until 0 = 1
 
And here is the Window Info:
 
Screenshot%202014-03-11%2017.22.29.jpg
Edit: The image is hosted on my Dropbox and  doesn't appear to work inline, but you should be able to open it in a new window/tab.  Sorry.
Edited by TheRydad
Posted (edited)

Try Opt("WinSearchChildren", 1) and see if it makes a difference. Also, add a sleep in your do loop so your cpu won't be overloaded.

Edit:spelling

Edited by this-is-me
Who else would I be?
Posted

Thanks.  I thought I remembered a setting like that, but couldn't remember what it was.  Unfortunately, it didn't work in this instance.  I'll keep trying, though...

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...