It is currently December 6th, 2022, 1:15 pm

Connected Bluetooth device (RegExpSubstitute)

Get help with creating, editing & fixing problems with skins
User avatar
StArL0rd84
Posts: 398
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Connected Bluetooth device (RegExpSubstitute)

Post by StArL0rd84 »

tass_co wrote: September 25th, 2022, 9:29 pm Can you try and write the result?

26.09.2022 - 00.27.47-About Rainmeter.png

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
OnRefreshAction=[!CommandMeasure mBluetoothDevicePairing "run"]
AccurateText=1

[Metadata]
Name=
Author=
Information=
Version=
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
BluetoothDevicePairing=#@#BluetoothDevicePairing.exe
; https://github.com/PolarGoose/BluetoothDevicePairing

[mBluetoothDevicePairing]
Measure=Plugin
Plugin=RunCommand
Program=#BluetoothDevicePairing#
Parameter=discover
OutputType=ANSI
DynamicVariables=1
UpdateDivider=-1

[MeaStr]
Measure=String
String=[mBluetoothDevicePairing]
RegExpSubstitute=1
Substitute="#CRLF#":"",".*\|Connected\|(.*)\s|.*":"\1","(..)$":"","\s+$":""
DynamicVariables=1

[MeterString]
Meter=String
MeasureName=MeaStr
X=0
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
SolidColor=0,0,0,255
AntiAlias=1
Text=Output: %1
DynamicVariables=1


I'm getting a somewhat different result even though our skins are the same, word for word.
output3.png
The following shortened my result down, but only to next Connected:

Code: Select all

Substitute="#CRLF#":"",".*\|Connected\|(.*)\|\|\s.*":"\1","(..)$":"","\s+$":""
output5.png
What I think is happening is I'm getting two connected because how some headsets connect with a separate microphone channel. idk.
so that confuses the substitute
output4.png
You do not have the required permissions to view the files attached to this post.
Last edited by StArL0rd84 on September 26th, 2022, 5:05 pm, edited 1 time in total.
User avatar
tass_co
Posts: 429
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Connected Bluetooth device (RegExpSubstitute)

Post by tass_co »

StArL0rd84 wrote: September 26th, 2022, 4:42 pm I'm getting a somewhat different result even though our skins are the same, word for word.
output3.png
The problem is caused by having more than 1 connected device. Can you try the code below?
I'm not sure, I have only one bluetooth device, you have to tell me the results.

Code: Select all

Substitute="#CRLF#":"",".*\|Connected\|(.*)\s|.*\|Connected\|(.*)\s|.*\|Connected\|(.*)\s|.*":"\1#CRLF#\2#CRLF#\3"
ps:Resolves 3 connected devices.For more you should add to ".*\|Connected\|(.*)\s|"
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
StArL0rd84
Posts: 398
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Connected Bluetooth device (RegExpSubstitute)

Post by StArL0rd84 »

tass_co wrote: September 26th, 2022, 4:53 pm The problem is caused by having more than 1 connected device. Can you try the code below?
I'm not sure, I have only one bluetooth device, you have to tell me the results.

Code: Select all

Substitute="#CRLF#":"",".*\|Connected\|(.*)\s|.*\|Connected\|(.*)\s|.*\|Connected\|(.*)\s|.*":"\1#CRLF#\2#CRLF#\3"
ps:Resolves 3 connected devices.For more you should add to ".*\|Connected\|(.*)\s|"
I'm sorry, but that didn't work.
To make it easier for you to test, I made a new test skin that parses a text file with my results.
BtDiscoveryTEST_1.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
StArL0rd84
Posts: 398
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Connected Bluetooth device (RegExpSubstitute)

Post by StArL0rd84 »

I might have stumbled over a workaround here.
I'm outputting a textfile with RunCommand, and parsing it with Webparser.
Makes the substitute a whole lot simpler.

Code: Select all

[mBluetoothDevicePairing]
Measure=Plugin
Plugin=RunCommand
Program=#BluetoothDevicePairing#
Parameter=discover
OutputType=ANSI
OutputFile=#@#TestFile.txt
DynamicVariables=1
UpdateDivider=-1
FinishAction=[!UpdateMeasure MeasureText][!UpdateMeter *][!Redraw]

[MeasureText]
Measure=WebParser
Url=file://#@#TestFile.txt
RegExp="(?siU)Connected\|(.*)\|\s"
Substitute="Connected":"","|":"","":"BlueTooth"
DynamicVariables=1

[MeterString]
Meter=String
MeasureName=MeasureText
X=0
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
SolidColor=0,0,0,255
AntiAlias=1
Text=Output: %1
DynamicVariables=1
User avatar
tass_co
Posts: 429
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Connected Bluetooth device (RegExpSubstitute)

Post by tass_co »

StArL0rd84 wrote: September 26th, 2022, 5:54 pm I might have stumbled over a workaround here.
I'm outputting a textfile with RunCommand, and parsing it with Webparser.
Makes the substitute a whole lot simpler.

Code: Select all

[mBluetoothDevicePairing]
Measure=Plugin
Plugin=RunCommand
Program=#BluetoothDevicePairing#
Parameter=discover
OutputType=ANSI
OutputFile=#@#TestFile.txt
DynamicVariables=1
UpdateDivider=-1
FinishAction=[!UpdateMeasure MeasureText][!UpdateMeter *][!Redraw]

[MeasureText]
Measure=WebParser
Url=file://#@#TestFile.txt
RegExp="(?siU)Connected\|(.*)\|\s"
Substitute="Connected":"","|":"","":"BlueTooth"
DynamicVariables=1

[MeterString]
Meter=String
MeasureName=MeasureText
X=0
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
SolidColor=0,0,0,255
AntiAlias=1
Text=Output: %1
DynamicVariables=1
I'll work on it and get back. I don't have time right now. Sorry
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
balala
Rainmeter Sage
Posts: 14765
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Connected Bluetooth device (RegExpSubstitute)

Post by balala »

What about something like this?

Code: Select all

[MeasureText]
Measure=WebParser
Url=file://#@#TestFile.txt
RegExp=(?siU)^(.*)$
RegExpSubstitute=1
Substitute="^(.*)\n":"#CRLF#","-":"",".*\|Connected\s*\|(.*)\|.*\n":"\1#CRLF#",".*\|Paired\s*\|(.*)\|.*\n":"",".*\|\s*\|(.*)\|.*\n":""
User avatar
StArL0rd84
Posts: 398
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Connected Bluetooth device (RegExpSubstitute)

Post by StArL0rd84 »

balala wrote: September 26th, 2022, 6:45 pm What about something like this?

Code: Select all

[MeasureText]
Measure=WebParser
Url=file://#@#TestFile.txt
RegExp=(?siU)^(.*)$
RegExpSubstitute=1
Substitute="^(.*)\n":"#CRLF#","-":"",".*\|Connected\s*\|(.*)\|.*\n":"\1#CRLF#",".*\|Paired\s*\|(.*)\|.*\n":"",".*\|\s*\|(.*)\|.*\n":""
A test for tomorrow, thanks.
User avatar
balala
Rainmeter Sage
Posts: 14765
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Connected Bluetooth device (RegExpSubstitute)

Post by balala »

StArL0rd84 wrote: September 26th, 2022, 6:49 pm A test for tomorrow, thanks.
Ok, please let me know how it works when tested...
User avatar
StArL0rd84
Posts: 398
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Connected Bluetooth device (RegExpSubstitute)

Post by StArL0rd84 »

balala wrote: September 26th, 2022, 6:45 pm What about something like this?

Code: Select all

[MeasureText]
Measure=WebParser
Url=file://#@#TestFile.txt
RegExp=(?siU)^(.*)$
RegExpSubstitute=1
Substitute="^(.*)\n":"#CRLF#","-":"",".*\|Connected\s*\|(.*)\|.*\n":"\1#CRLF#",".*\|Paired\s*\|(.*)\|.*\n":"",".*\|\s*\|(.*)\|.*\n":""
output6.png
Only getting a line break from that
You do not have the required permissions to view the files attached to this post.
User avatar
tass_co
Posts: 429
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Connected Bluetooth device (RegExpSubstitute)

Post by tass_co »

StArL0rd84 wrote: September 27th, 2022, 2:25 pm output6.png
Only getting a line break from that
There is something wrong.
Actually, the code that balala wrote works.
Please install the skin file below and try again!
Code works for me.
(Webparser is update to every 10 sec + Left Button run BT)
GIF 27.09.2022 17-51-26.gif
BtDiscovery_2.0.rmskin

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
OnRefreshAction=[!CommandMeasure mBluetoothDevicePairing "run"]

[Variables]
BluetoothDevicePairing=#@#BluetoothDevicePairing.exe

[mBluetoothDevicePairing]
Measure=Plugin
Plugin=RunCommand
Program=#BluetoothDevicePairing#
Parameter=discover
OutputType=ANSI
OutputFile=#@#TestFile.txt
DynamicVariables=1
UpdateDivider=-1
FinishAction=[!UpdateMeasure MeasureText][!UpdateMeter *][!Redraw]

[MeasureText]
Measure=WebParser
Url=file://#@#TestFile.txt
RegExp=(?siU)^(.*)$
RegExpSubstitute=1
Substitute="^(.*)\n":"#CRLF#","-":"",".*\|Connected\s*\|(.*)\|.*\n":"\1#CRLF#",".*\|Paired\s*\|(.*)\|.*\n":"",".*\|\s*\|(.*)\|.*\n":"","Start discovering devices for 10 seconds":"","^#CRLF#":""
UpdateRate=10

[MeterString]
Meter=String
MeasureName=MeasureText
X=0
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=16
StringEffect=Shadow
SolidColor=0,0,0,255
AntiAlias=1
Text=Output: %1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure mBluetoothDevicePairing "run"]
You do not have the required permissions to view the files attached to this post.
I don't know where i going from here, but i promise it won't be boring... :great: