It is currently April 25th, 2024, 3:15 pm

Enable/Disable Internet

Get help with creating, editing & fixing problems with skins
User avatar
1690Cat
Posts: 23
Joined: September 27th, 2012, 3:02 pm

Enable/Disable Internet

Post by 1690Cat »

Hi.
Is it possible to Enable and Disable your Ethernet Internet connection.I'm running win 8.1 os.
What i'm looking for is an alternative way to use a button to enable/disable without a window popping up
like i get with the following bit of code below.

[Icon1]
Meter=Image
ImageName=Net.png
x=0
y=0
LeftMouseUpAction=["shell:ConnectionsFolder"]

Any help would be much appreciated...
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Enable/Disable Internet

Post by balala »

Based on this question, you could try the followings:
1. Add the Var=1 variable to the [Variables] section.
2. Add the following measure:

Code: Select all

[MeasureSet]
Measure=Calc
Formula=#Var#
IfCondition=(MeasureSet=0)
IfTrueAction=[netsh interface set interface "Local Area Connection" DISABLED]
IfFalseAction=[netsh interface set interface "Local Area Connection" ENABLED]
DynamicVariables=1
3. Replace the LeftMouseUpAction option of the [Icon1] meter with the following one: LeftMouseUpAction=[!SetVariable Var "(1-#Var#)"][!UpdateMeasure "MeasureSet"].
I'm not sure if this could help, but maybe it worth a try.
User avatar
1690Cat
Posts: 23
Joined: September 27th, 2012, 3:02 pm

Re: Enable/Disable Internet

Post by 1690Cat »

Hi Balala,thanks for answering my post.Tried what you gave me but unfortunately all that happens is a black box appears and goes again.
which says (No more data is available)

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
Var=1

[MeasureSet]
Measure=Calc
Formula=#Var#
IfCondition=(MeasureSet=0)
IfTrueAction=[netsh interface set interface "Local Area Connection" DISABLED]
IfFalseAction=[netsh interface set interface "Local Area Connection" ENABLED]
DynamicVariables=1

[MeterBG]
Meter=Image
ImageName=SideBar.png
x=0
y=0

[MeterIcon1]
Meter=Image
ImageName=Net.png
x=26
y=60
LeftMouseUpAction=[!SetVariable Var "(1-#Var#)"][!UpdateMeasure "MeasureSet"]

Anyway thanks for trying Balala..
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Enable/Disable Internet

Post by jsmorley »

It's not quite that simple, as your interface may well not be (in fact probably isn't) called "Local Area Connection".

You might try

ipconfig /release

To release all network connections, thus "disabling" the internet.

and

ipconfig /renew

to reconnect.

You might use the RunCommand plugin to execute the shell commands, so you don't have to get the command window popup.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Enable/Disable Internet

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
State=1

[MeasureToggle]
Measure=Calc
Formula=#State#
IfCondition=MeasureToggle=0
IfTrueAction=[!CommandMeasure MeasureTurnOff "Run"]
IfFalseAction=[!CommandMeasure MeasureTurnOn "Run"]
Disabled=1
UpdateDivider=-1
DynamicVariables=1

[MeasureTurnOff]
Measure=Plugin
Plugin=RunCommand
Parameter=ipconfig /release
State=Hide

[MeasureTurnOn]
Measure=Plugin
Plugin=RunCommand
Parameter=ipconfig /renew
State=Hide

[MeasureNetwork]
Measure=Plugin
Plugin=SysInfo
SysInfoType=LAN_CONNECTIVITY
SysInfoData=Best
IfCondition=MeasureNetWork = -1
IfTrueAction=[!SetOption MeterWAN Text "No Network"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterWAN Text "Network OK"][!UpdateMeter *][!Redraw]

[MeasureInternet]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
SysInfoData=Best
IfCondition=MeasureInternet = -1
IfTrueAction=[!SetOption MeterLAN Text "No Internet"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterLAN Text "Internet OK"][!UpdateMeter *][!Redraw]

[MeterWAN]
Meter=String
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1

[MeterLAN]
Meter=String
Y=5R
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1

[MeterToggle]
Meter=String
Y=10R
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Toggle
DynamicVariables=1
LeftMouseUpAction=[!EnableMeasure MeasureToggle][!SetVariable State "(1-#State#)"][!UpdateMeasure "MeasureToggle"]
GIF.gif
You do not have the required permissions to view the files attached to this post.
User avatar
1690Cat
Posts: 23
Joined: September 27th, 2012, 3:02 pm

Re: Enable/Disable Internet

Post by 1690Cat »

Hi JSMorley, You were right about interface not being called Local Area Connection all it says is Network with the hardwares name Realtek.
But that code you wrote with RunCommand plugin works like a dream!, so i thank you JSMorley nice job..
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Enable/Disable Internet

Post by jsmorley »

1690Cat wrote:Hi JSMorley, You were right about interface not being called Local Area Connection all it says is Network with the hardwares name Realtek.
But that code you wrote with RunCommand plugin works like a dream!, so i thank you JSMorley nice job..
Glad to help.
Predator73
Posts: 6
Joined: October 25th, 2020, 1:59 pm

Re: Enable/Disable Internet

Post by Predator73 »

Hi everyone, if possible I ask for help to be able to make it work on windows10 and rainmeter 4.4, the network and internet status works but the Toggle button does not work. Thank you very much for helping....
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Enable/Disable Internet

Post by balala »

Predator73 wrote: October 25th, 2020, 4:11 pm Hi everyone, if possible I ask for help to be able to make it work on windows10 and rainmeter 4.4, the network and internet status works but the Toggle button does not work. Thank you very much for helping....
The Toggle button in jsmorley's code does work for me, just checked it. I'm on windows 10 v2004.
What the "Toggle button does not work" mean? No change when you click it? Internet is not disabled? Or you can't click it?
Predator73
Posts: 6
Joined: October 25th, 2020, 1:59 pm

Re: Enable/Disable Internet

Post by Predator73 »

Network ok, Internet Ok, but when I click on Toggle it doesn't change the status ....