It is currently April 26th, 2024, 1:57 pm

Send GET request on click shape?

Get help with creating, editing & fixing problems with skins
stfnsn
Posts: 5
Joined: January 27th, 2019, 4:50 pm

Send GET request on click shape?

Post by stfnsn »

Hi,
I need 2 buttons ( basic circle shapes) to send GET request to 2 specific URLs after I click. So:
button1 onClick will send GET request to url1
button2 onClick will send GET request to url2

This is what I have for now, but it doesn't work:

Code: Select all

[parserOn]
Measure = Plugin
Plugin = RunCommand
Program = PowerShell.exe
Parameter = (Invoke-WebRequest -Uri 'https://xxxxx')
OutputType = ANSI

[parserOff]
Measure = Plugin
Plugin = RunCommand
Program = PowerShell.exe
Parameter = (Invoke-WebRequest -Uri 'https://yyyyy')
OutputType = ANSI

[MeterOn]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOn
AntiAlias=1
LeftMouseUpAction=[!Log "on"]
LeftMouseUpAction=[!UpdateMeasure "parserOn"][!Redraw]

[MeterOff]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOff
AntiAlias=1
LeftMouseUpAction=[!UpdateMeasure "parserOff"][!Redraw]
LeftMouseUpAction=[!Log "off"]
x=200
y=0
Idea here was to trigger measure block on meter click. Mybe there is better way to achieve what I wanted.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Send GET request on click shape?

Post by balala »

stfnsn wrote: January 31st, 2019, 2:03 pm I need 2 buttons ( basic circle shapes) to send GET request to 2 specific URLs after I click. So:
button1 onClick will send GET request to url1
button2 onClick will send GET request to url2
Are you absolutely positive that invoking PowerShell is absolutely needed? Because I'd do this without a such procedure.
For example:

Code: Select all

[MeasureParent]
Measure=WebParser
UpdateRate=900
Url=https://xxxxx
RegExp=(?siU) ...

[MeterOn]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOn
AntiAlias=1
LeftMouseUpAction=[!Log "on"]
LeftMouseUpAction=[!SetOption MeasureParent URL "https://xxxxx"][!SetOption MeasureParent RegExp "..."][!UpdateMeasure "MeasureParent"][!CommandMeasure "MeasureParent" "Update"]

[MeterOff]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOff
AntiAlias=1
LeftMouseUpAction=[!SetOption MeasureParent URL "https://yyyyy"][!SetOption MeasureParent RegExp "..."][!UpdateMeasure "MeasureParent"][!CommandMeasure "MeasureParent" "Update"]
LeftMouseUpAction=[!Log "off"]
x=200
y=0
Just take care that you probably will have to change the RegExp options based on the current address, set by the first !SetOption bangs above.
If you can't figure out how to make this to work, please post some URLs and what you would like to get from each.
Maybe I am mistaken, but at a first look, this is how I'd make this.
stfnsn
Posts: 5
Joined: January 27th, 2019, 4:50 pm

Re: Send GET request on click shape?

Post by stfnsn »

@balala

I don't need anything from URL content, I need just to send GET request so service can trigger action. I can't give you full URL because it has secret token. It's IFTTT webhook:

Code: Select all

https://maker.ifttt.com/trigger/variable1/with/key/xxxxxxxxx/

Code: Select all

https://maker.ifttt.com/trigger/variable2/with/key/xxxxxxxxx/
I tested you script and not working. Can you update based on new info I wrote above?

Edit:
in a log file this shows up when I click on button:

Code: Select all

DBUG (17:24:21.019) : System: "Show desktop" has been detected.
DBUG (17:24:21.148) : System: "Show open windows" has been detected.
That two lines shows up if I click any of buttons. BUT, sometimes everything works fine and in Log I can see that URL has been fetched.
User avatar
khanhas
Posts: 40
Joined: October 26th, 2016, 5:00 pm

Re: Send GET request on click shape?

Post by khanhas »

Code: Select all

[MeterOn]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOn
AntiAlias=1
LeftMouseUpAction=[!Log "on"][!CommandMeasure parserOn Run][!Redraw]

[MeterOff]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOff
AntiAlias=1
LeftMouseUpAction=[!Log "off"][!CommandMeasure parserOff Run][!Redraw]
x=200
y=0
stfnsn
Posts: 5
Joined: January 27th, 2019, 4:50 pm

Re: Send GET request on click shape?

Post by stfnsn »

khanhas wrote: January 31st, 2019, 4:56 pm

Code: Select all

[MeterOn]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOn
AntiAlias=1
LeftMouseUpAction=[!Log "on"][!CommandMeasure parserOn Run][!Redraw]

[MeterOff]
Meter=Shape
Shape=Ellipse 50,50,50
MeasureName=parserOff
AntiAlias=1
LeftMouseUpAction=[!Log "off"][!CommandMeasure parserOff Run][!Redraw]
x=200
y=0
It worked! Thanks.