Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1418

Help: Rainmeter Skins • Re: NowPlaying & VLC-Media Player

$
0
0
:rosegift: Sorry, I didn't mean to sound rude :oops: . I also understand that we can't try every single media player and then find a solution. I would like to see your solution for the VLC media player. :great:
Yeah, no worries, it wasn't about being rude, just some rhetorical joke about working for something that might not be used at all (I avoid that in principle for efficiency reasons). After all, you couldn't have known I built this skin since I didn't know either that I'd build it until after posting that longer explanation above. ;-)

Skin:
AppTitle_1.0.0.rmskin
Preview:
AppTitle.jpg
Code:
- ...\@Resources\Macros\AppTitle.au3 (compiled to AppTitle.exe with AutoIt; if your AV doesn't like the .exe, you can compile it yourself):

Code:

#NoTrayIcon#include <WinAPI.au3>#include <SendMessage.au3>AutoItSetOption("WinTitleMatchMode", -2)Func SendBang($Bang)  Local Const $hWnd = WinGetHandle("[CLASS:RainmeterMeterWindow]")  If $hWnd Then    Local Const $iLen = StringLen($Bang) + 1    Local Const $pMem = DllStructCreate("wchar[" & $iLen & "]")    Local Const $pCds = DllStructCreate("dword;dword;ptr")    Local Const $WM_COPYDATA = 0x004A    DllStructSetData($pMem, 1, $Bang)    DllStructSetData($pCds, 1, 1)    DllStructSetData($pCds, 2, ($iLen * 2))    DllStructSetData($pCds, 3, DllStructGetPtr($pMem))    _SendMessage($hWnd, $WM_COPYDATA, 0, DllStructGetPtr($pCds))  EndIfEndFuncFunc GetResult()  Local $aReg = $CmdLine[1], $aAct = $CmdLine[2], $aSep = $CmdLine[3], $aInt = $CmdLine[4]  Do    Local $wHan = WinGetHandle("[REGEXPTITLE:(?i)" & $aReg & "]"), $sOut = "" & $aSep    If IsHWnd($wHan) Then $sOut = WinGetTitle($wHan) & $aSep    SendBang(StringReplace($aAct, "$Output", $sOut))    Sleep($aInt)  Until $aInt < 0EndFuncGetResult()
- ...\AppTitle.ini (the main skin):

Code:

[Variables]Delay=250Regex="^.*VLC media player$"Action=[!SetVariable Output ""$Output"" ""#CURRENTCONFIG#""]Separator="#CRLF#"Interval=1000Output=[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1---Measures---[Update]Measure=CalcUpdateDivider=-1OnUpdateAction=[!CommandMeasure GetWin "Kill"][!Delay #Delay#][!CommandMeasure GetWin "Run"][GetWin]Measure=PluginPlugin=RunCommandProgram="#@#Macros\AppTitle.exe"Parameter=""#Regex#" "#Action#" "#Separator#" "#Interval#""OutputType=ANSIUpdateDivider=-1[Opened]Measure=StringString="#Output#"RegExpSubstitute=1Substitute="- VLC media player#Separator#$":""DynamicVariables=1[RunApp]Measure=PluginPlugin=RunCommandProgram=C:\Program Files\VideoLAN\VLC\vlc.exe Parameter=https://stream.sunshine-live.de/2000er/mp3-192/stream.sunshine-live.de/play.m3uState=HideOutputType=ANSIUpdateDivider=-1---Styles---[Texts]X=200Y=10RW=400SolidColor=32,32,32,128FontColor=255,255,255,255FontEffectColor=0,0,0,255Padding=5,5,5,5FontSize=12AntiAlias=1ClipString=2StringAlign=CenterStringEffect=Shadow---Meters---[RunAppButton]Meter=StringMeterStyle=TextsY=0rSolidColor=255,32,32,128Text=Run AppLeftMouseUpAction=[!CommandMeasure RunApp "Run"][GetWinButton]Meter=StringMeterStyle=TextsSolidColor=32,255,32,128Text=Get WinLeftMouseUpAction=[!UpdateMeasure Update][OpenedDetail]Meter=StringMeterStyle=TextsFontSize=14MeasureName=Opened
Details:
- Delay controls how long after killing the potential previous instance of AppTitle.exe the potential new instance is ran
- Regex is the regular expression pattern used to match the application title in AppTitle.exe
- Action is the bang used by AppTitle.exe to send back its application title output to the current skin as a variable named Output
- Separator is just in case some multiline output is one day needed
- Interval is how often in milliseconds AppTitle.exe will send back to the current skin its application title output
- Output is the variable where the application title sent by AppTitle.exe will be stored in the skin
- [Update] kills killing any potential previous instance of AppTitle.exe before the potential new instance is ran
- [GetWin] runs AppTitle.exe with the variable parameters (this only needs to happen once per skin loading session as the .exe is resident)
- [Opened] receives the #Output# value sent by AppTitle.exe to the skin, and substitutes to leave only the playing info
- [RunApp] runs VLC with the list parameter (you can use any way to run VLC here, minimized, hidden or command line, it doesn't matter)
- [RunAppButton] triggers running VLC (optional, since you can run it from outside the skin too)
- [GetWinButton] triggers running AppTitle.exe safely by killing any potential previous instance of it (optional, since this happens at skin load anyway)
- [OpenedDetail] displays the playing info from [Opened] (I let the Substitute unchanged so you can also see when VLC is running without playing)
Notes:
- AppTitle.exe doesn't update anything as per Action, so [Opened] and [OpenedDetail] will get #Output# via their periodic section update
- if you want to add other bangs to Action, you should use the ""#CURRENTCONFIG#"" last parameter too, so that bangs will get to the current skin
- the skin's Update doesn't depend on Interval or viceversa, so you can send data from AppTitle.exe at a different rate than how often the skin updates
- one can send anything that AutoIt can retrieve to the skin, by editing what's stored in $sOut in the first 2 lines after Do from AppTitle.au3; one can also do anything with what's received in the skin, via the parameters passed to AppTitle.exe; for conveniency, if Interval is -1 the .exe will perform just one Do...Until loop and exit afterwards in case a one time run without being resident in memory is desired from the .exe (this is how I built my own unreleased "window spy" skin called "Window Message Helper" that I used to investigate the properties of the VLC window I mentioned earlier in the longer explanation post; the screenshot shows a previous version of AppTitle.ini, which is why the playing info isn't displayed there):
VLC Info Window Spy.jpg
This skin is still unreleased simply because I didn't find the time / mood to sort the otherwise arbitrarily ordered window list I send back to the skin and pass the currently scrolled window name or class to the WindowMessage plugin in order to control the said window, otherwise is fully functional as "just" a window spy skin.

Statistics: Posted by Yincognito — Yesterday, 8:07 pm



Viewing all articles
Browse latest Browse all 1418

Trending Articles