Jump to content

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


Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

@ 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?

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

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

×
×
  • Create New...