It is currently March 28th, 2024, 5:23 pm

This is a Network switcher anyway of improving?

Get help with creating, editing & fixing problems with skins
Post Reply
Not ≠
Posts: 5
Joined: November 29th, 2017, 5:28 am

This is a Network switcher anyway of improving?

Post by Not ≠ »

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1

[MeterLAN]
Meter=String
Text=Local area Network
X=0r
Y=0r
FontFace=Sansation Regular
FontSize=20
FontColor=255,255,255
Antialias=1
LeftMouseUpAction=["#@#Wi-Fi to Lan.exe"]

[MeterWIFI]
Meter=String
Text=Wireless Network
X=0r
Y=35r
FontFace=Sansation Regular
FontSize=20
FontColor=255,255,255
Antialias=1
LeftMouseUpAction=["#@#Lan to Wi-FI.exe"]
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: This is a Network switcher anyway of improving?

Post by balala »

dvo wrote:and btw the .exe file can better have no spaces in the name
I don't think it wouldn't work, since its path and name is included into quotations.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: This is a Network switcher anyway of improving?

Post by balala »

What do intrigue me in your code is I don't know how you make the skin to show one of the [MeterLAN] and [MeterWIFI] meters and hide the other. Or maybe this isn't the whole code? Maybe it has some not posted parts, too? Not clear at all.
And as dvo said, not having the Lan to Wi-FI.exe executable, I can't test. Maybe this app tells somehow the skin, which meter to be shown and which one to be hidden?
However if the posted code works, here is an improvement of it. I added a WiFiLan variable (into the [Variables] section) and based on its value, a Calc measure makes the appropriate settings. See I kept just one of the [MeterLAN] and [MeterWIFI] meters, naming it [MeterWiFiLAN]. I also replaced the Update option of the [Rainmeter] section with Update=-1, which makes the skin not being updated at all. This kind of mouse controlled skins, don't have to be necessary updated regularly, instead when you click, only the appropriate measures / meters should be updated. Or alternatively should be updated the whole skin - but I prefer to update just the needed sections.
When you click the only kept meter ([MeterWiFiLAN]), it changes the value of the WiFiLan variable, from 0 to 1, respectively vice-versa. Updating the [MeasureWiFiLan] measure, this sets the appropriate text for the [MeterWiFiLAN] string meter, through the IfTrueAction and IfFalseaction options and executes the Wi-Fi to Lan.exe executable, through the OnChangeAction option (which is executed every time the value of the measure changes).
So, here is my rewritten code:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1

[Variables]
WiFiLan=0

[MeasureWiFiLan]
Measure=Calc
Formula=#WiFiLan#
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!SetOption MeterWiFiLan Text "Local area Network"][!UpdateMeter "MeterWiFiLan"][!Redraw]
IfFalseAction=[!SetOption MeterWiFiLan Text "Wireless Network"][!UpdateMeter "MeterWiFiLan"][!Redraw]
OnChangeAction=["#@#Wi-Fi to Lan.exe"]
DynamicVariables=1

[MeterWiFiLAN]
Meter=String
X=0r
Y=0r
FontFace=Sansation Regular
FontSize=20
FontColor=255,255,255
Antialias=1
LeftMouseUpAction=[!SetVariable WiFiLan "(1-#WiFiLan#)"][!UpdateMeasure "MeasureWiFiLan"][!UpdateMeter "MeterWiFiLAN"][!Redraw]
DynamicVariables=1
If your skin has some sections you didn't post, maybe this code won't be good enough, having to be furtherly rewritten. Please let me know what is the situation.
Not ≠
Posts: 5
Joined: November 29th, 2017, 5:28 am

Re: This is a Network switcher anyway of improving?

Post by Not ≠ »

Well i im new to this but the exe is just a bat file that i converted but here it is

@echo 0ff

netsh interface set interface "Wi-Fi" Disable
timeout /5
netsh interface set interface "Ethernet" Enable

:end

the other one is legit the other way
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: This is a Network switcher anyway of improving?

Post by balala »

Not ≠ wrote:Well i im new to this but the exe is just a bat file that i converted
Sorry, I just discovered I've messed up a bit the things in my last code. Due to my (usual) inattention, I thought in both meters ([MeterLAN] and [MeterWIFI]) you've used the same .exe file. Now I see you didn't. Sorry...
Now, if those files are really .bat files, there is no reason to convert them to .exe. Leave them as .bat files. You can use the RunCommand plugin to run them hidden.
See the following code:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1

[Variables]
WiFiLan=0

[MeasureWiFiLan]
Measure=Calc
Formula=#WiFiLan#
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!SetOption MeasureRun Parameter "#@#Wi-Fi to Lan.bat"][!CommandMeasure "MeasureRun" "Run"][!SetOption MeterWiFiLan Text "Local area Network"][!UpdateMeter "MeterWiFiLan"][!Redraw]
IfFalseAction=[!SetOption MeasureRun Parameter "#@#Lan to Wi-Fi.bat"][!CommandMeasure "MeasureRun" "Run"][!SetOption MeterWiFiLan Text "Wireless Network"][!UpdateMeter "MeterWiFiLan"][!Redraw]
DynamicVariables=1

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
State=Hide

[MeterWiFiLAN]
Meter=String
X=0r
Y=0r
FontFace=Sansation Regular
FontSize=20
FontColor=255,255,255
Antialias=1
LeftMouseUpAction=[!SetVariable WiFiLan "(1-#WiFiLan#)"][!UpdateMeasure "MeasureWiFiLan"]
This time I leaved again just one single String meter ([MeterWiFiLAN]). The Text option of this meter is set again by the IfTrueAction and IfFalseAction options of the [MeasureWiFiLan] measure, based on the value of the WiFiLan variable. But this time I added a RunCommand plugin measure, which can run hidden the appropriate .bat file. Its Parameter option is set by the same options as the text option of the [MeterWiFiLAN] meter.
Please check this code and let me know how does it works.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: This is a Network switcher anyway of improving?

Post by balala »

dvo wrote:tested the bat file but it doesn't switch from wifi to lan or back again... :D
And if you try to use them from the command prompt? Do they work?
Not ≠
Posts: 5
Joined: November 29th, 2017, 5:28 am

Re: This is a Network switcher anyway of improving?

Post by Not ≠ »

wow that would work way better thanks for it guys, oh and i made them into icons and it works with my setup.[Mine rn](https://www.reddit.com/r/Rainmeter/comments/7gjr8g/first_try_hope_you_guys_like/)
Post Reply