Jump to content
u01jmg3

How to write a registry entry when Windows Media Player is not running?

Recommended Posts

u01jmg3
HotKeySet("^``", "toggle_media_controls") ; Ctrl + `

While 1
    Sleep(100)
WEnd

If Not ProcessExists("wmplayer.exe") And RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then
    ; Disable autohide controls
    RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
EndIf

Func toggle_media_controls()
    Local $sVar = RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled")

    If ProcessExists("wmplayer.exe") Then
        If $sVar = 0 Then
            ; Enable autohide controls
            RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "1")
        Else
            ; Disable autohide controls
            RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
        EndIf
    EndIf
EndFunc

How do I amend this code so that without pressing a hotkey, after Windows Media Player is not running, the regkey above is set to 0?

My function and hotkey all work without issue

Share this post


Link to post
Share on other sites
u01jmg3

Use ProcessWaitClose

Thanks - how would I amend my code to use ProcessWaitClose? Do I need to create a new function? This is the section of code I've tried changing but when closing Windows Media Player, the registry key isn't being changed from 1 to 0.

If Not ProcessExists("wmplayer.exe") And RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then
    ; Disable autohide controls
    RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
EndIf

 

Share this post


Link to post
Share on other sites
Surya
HotKeySet("^``", "toggle_media_controls") ; Ctrl + `

While 1
    Sleep(100)
WEnd

If Not ProcessExists("wmplayer.exe") And RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then
    ; Disable autohide controls
    RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
EndIf

Func toggle_media_controls()
    Local $sVar = RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled")

    If ProcessExists("wmplayer.exe") Then
        If $sVar = 0 Then
            ; Enable autohide controls
            RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "1")
        Else
            ; Disable autohide controls
            RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
        EndIf
    EndIf
EndFunc

i think that in that script even when you close  windows media player the commands below wend wouldnt be executed because of the loop

so change the loop like this:

HotKeySet("^``", "toggle_media_controls") ; Ctrl + `

While 1
 If not ProcessExists("wmplayer.exe") then exitloop ;this is required to jump out of the loop to execute the next commands
WEnd

If Not ProcessExists("wmplayer.exe") And RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then
    ; Disable autohide controls
    RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
EndIf

Func toggle_media_controls()
    Local $sVar = RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled")

    If ProcessExists("wmplayer.exe") Then
        If $sVar = 0 Then
            ; Enable autohide controls
            RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "1")
        Else
            ; Disable autohide controls
            RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
        EndIf
    EndIf
EndFunc

 


No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Share this post


Link to post
Share on other sites
u01jmg3

@ Surya: thanks, this semi works.

The script doesn't run unless Windows Media Player is running. Once you get the script running, it closes when Windows Media Player is closed. Any way to fix these 2 things and have the script running/polling all the time so each time I open/close Windows Media Player, the script does its thing?

Share this post


Link to post
Share on other sites
Surya

here it is further modified:

While 1
If Not ProcessExists("wmplayer.exe") And RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then
    ; Disable autohide controls
    RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
Else
     RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "1")
EndIf
WEnd
Exit

If that doesnt suite your needs feel free to ask for another


No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Share this post


Link to post
Share on other sites
u01jmg3

Modified slightly so now works - thanks!

While 1
    If Not ProcessExists("wmplayer.exe") And RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then
        ; Disable autohide controls
        RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
    EndIf
    Sleep(100)
WEnd

 

Share this post


Link to post
Share on other sites
jguinch

I know it is solved, but like I said, you can also use ProcessWaitClose :

While 1
    ProcessWaitClose("wmplayer.exe")
    If RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0")
    Sleep(100)
WEnd

 

  • Like 1

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

  • Similar Content

    • PramodR
      By PramodR
      Hello,
      I have to execute below block of code in elevated previllage, as that particular wmic class will work only with admin previlage.
      i am getting out put when i launch autoit as administrator,  but i will not be able to launch autoit as admin in this particular case but my user have admin rights.
      is there any better way i can run those command as administrator.?
      tried below steps:
      i have tried #RequireAdmin but that creates a user prompt  Tried using Runas command but gives error as wrong username or password , stuck with that step.  
       
    • dwaynek
      By dwaynek
      traytip isn't working in windows 10. nothing happens when i use the Traytip command.
      here's a simple script i used:
      TrayTip("I'm a title", "I'm the message", 5) i tried changing the registry setting HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced ( which didn't have EnableBalloonTips) and creating a DWORD entry called EnableBalloonTips and setting it to 1 and logging off then back in. that did not resolve the problem.
      i'm running Windows 10 v1709 b16299.431
    • Jake_s
      By Jake_s
      Hi All, 
       
      I am a begginer in auto it. I am trying to build simple gui that will show me if for example notepad.exe process is currently running on the system. I have built something like this, but when I execute it shows me message boxes, but I want the results to show in gui. If you can help me start with this.
       
      Thanks
       
        #include <MsgBoxConstants.au3>
      #include <GUIConstantsEx.au3>

      ActiveProcess()

      Func ActiveProcess()
      GUICreate("Act")
               ProcessExists("wuauclt.exe")

             If ProcessExists("wuauclt.exe") Then
       MsgBox($MB_SYSTEMMODAL, "", "Windows Upates are running")
           Else
       MsgBox($MB_SYSTEMMODAL, "", "Windows Updates are not running")
       EndIf
         ;Notepad

               ProcessExists("notepad.exe")

               If ProcessExists("notepad.exe") Then
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is running")
              Else
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running")
      EndIf  
       
    • antonioj84
      By antonioj84
      Hi all to the forum guru and expert I am trying to  automate this. in the registry  I have the network profile name network 2 and network   I want to  change their  CATEGORY  to Private .  Can someone lead me in the right direction.
      Private is 1 and Public is 0
      #RequireAdmin Global $sHKLMRoot = @OSArch = "x64" ? "HKLM64" : "HKLM" RegWrite($sHKLMRoot &"\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\NewNetworks" ,'/v NetworkList /t REG_MULTI_SZ /d 00000000 /f') see  attached picture below
      Much appreaciate
       

×