Jump to content

Muting announcements in VLC Player


Go to solution Solved by BrewManNH,

Recommended Posts

Greetings,

I am trying to achieve the following (see description in code window below). If I remove the Do/Until loop, then the Window Title detection works fine and I get through to the message box. When I do use the Do/Until loop, as shown below, the code skips to the messagebox even though the VLC Player Window does not have the "Announcement" string in the title. Why does this occur?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         D

 Script Function:
    Mutes VLC Radio Announcements.
    
    1. Wait for a Window with a Title containing "Announcement" string.
    2. Upon window/string detection, activate the VLC Player Window and mute the sound via the VLC menus.
    3. Wait until there is no Window present with title containing the "Announcement" string.
        4. Activate the VLC Player Window and unmute the sound via the VLC menus.
    5. Loop to the beginning.

#ce ----------------------------------------------------------------------------

; Script Start
AutoItSetOption("WinTitleMatchMode",2)  ; Partial title match

While 1
   WinWait("Announcement", "")
   WinActivate("Announcement", "")
   Send("!a" & "{DOWN 6}" & "{ENTER}")  ; Press VLC mute via VLC menus
   MsgBox(0, "Test", "Mute Me!")
   Local $Mute=1    ; Mute enabled
   
   Do
      If Not WinExists("Announcement", "") Then
         $Mute=2    ; Mute disabled
      Else
         ContinueLoop
      EndIf
   Until $Mute=2
          
WEnd

Exit

Thanks in advance!

Link to comment
Share on other sites

You're telling the If statement to process the $mute = 2 if the window DOESN'T exist, so $mute will equal 2 as long as that window isn't there.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi,

How does the script make it through to the If statement? Shouldn't it wait on the following line?

  WinWait("Announcement", "")

WinWait function = Pauses execution of the script until the requested window exists.

 

Thanks

Link to comment
Share on other sites

  • Solution

Now you're mixing up what you asked in the first post. Are you having issues with the Do loop, as initially stated, or are you having issues with the WinWait? Do you by any chance have a window open that has the word Announcement in it anywhere? Such as calling your script Announcement.au3, and editing it in Scite?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi,

Sorry for the confusion :) You're spot on for my script having the string "Announcement" in it and thus undesirably triggering the WinWait. Thanks for your help!

Below is the final script that works.

; Script Start
AutoItSetOption("WinTitleMatchMode",2)  ; Partial title match

While 1
   WinWait("Announcement", "")
   WinActivate("Announcement", "")
   Send("!a" & "{DOWN 6}" & "{ENTER}")  ; Press VLC mute via VLC menus
   Local $Mute=1    ; Mute enabled
   
   Do
      If Not WinExists("Announcement", "") Then
         Send("!a" & "{DOWN 6}" & "{ENTER}")    ; Press VLC mute via VLC menus
         $Mute=2    ; Mute disabled
      Else
         ContinueLoop   ; Continue Do Loop Until Announcement string disappears from window title
      EndIf
   Until $Mute=2
          
WEnd
Link to comment
Share on other sites

I'm glad you got it working. Wait until you have a script called the same as a program you're trying to run with a Run command and you have thousands of instances of it running the same program over and over until your computer crashes. Been there, done that, have the T-shirt.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...