It is currently September 29th, 2024, 7:22 pm

Reading commands

General topics related to Rainmeter.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Reading commands

Post by moshi »

just a proof of concept that one does not need 50 measures to without Lua.
i use 5 measures here, with the same functionality as the above skin two would be enough.

differences:
- this skin uses the subject of the mail as a password/trigger. this is just a trigger to execute what is in the mail content.
- you can define up to five commands in the [Variables] section, if no match is found it will execute what you have typed in the content of the mail.
- the skin cares about time. if you send multiple mails it will execute one after another, once.
- it keeps a log.

bad:
- quotes in the mail content will break it.

configuration is done in @RESOURCES\settings.txt, the log is in the same folder.


settings.txt:

Code: Select all

[Variables]
GmailUserName=johndoe
GmailPassword=password

MailUpdateRate=600

RemoteSenderAddress=john.doe@yahoo.com
RemoteSubject=IRSomeKindOfPassword

Command1Name=Calculator
Command1Action=calc.exe

Command2Name=Logoff
Command2Action=shutdown.exe -l

Command3Name=Calculator
Command3Action=calc.exe

Command4Name=Calculator
Command4Action=calc.exe

Command5Name=Calculator
Command5Action=calc.exe

regular.ini:

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Author=Alex Becherer
Name=Rainmeter Email Remote
Information=
Version=0.1
License=Creative Commons BY-NC-SA 3.0

[VariablesSettings]
@Include="#@#settings.txt"

[Variables]
LastID=booo

[MeasureTime]
Measure=Time
Format=%#c

[MeasureGetCommand]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=https://#GmailUsername#:#GmailPassword#@gmail.google.com/gmail/feed/atom
RegExp="(?siU)^(.*)$"
UpdateRate=#MailUpdateRate#
StringIndex=1
DecodeCharacterReference=1
DynamicVariables=1
RegExpSubstitute=1
Substitute='"':"€€€€","\r":"","\n":"","\t":"","^(.*)<id>#LastID#</id>.*$":"\1","^(.*)?":"\1-nada","^.*<entry><title>#RemoteSubject#</title>(.*?)<email>#RemoteSenderAddress#</email></author></entry>.*?$":"\1","^.*-nada$":"","^.*<summary>(.*)</summary>.*$":"\1","^#Command1Name#$":"#Command1Action#","^#Command2Name#$":"#Command2Action#","^#Command3Name#$":"#Command3Action#","^#Command4Name#$":"#Command4Action#","^#Command5Name#$":"#Command5Action#","€€€€":'"'
FinishAction=[!SetVariable Command "[MeasureGetCommand]"]

[MeasureGetID]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureGetCommand]
StringIndex=1
DecodeCharacterReference=1
DynamicVariables=1
RegExpSubstitute=1
Substitute='"':"€€€€","\r":"","\n":"","\t":"","^(.*)<id>#LastID#</id>.*$":"\1","^(.*)?":"\1-nada","^.*<entry><title>#RemoteSubject#</title>(.*?)<email>#RemoteSenderAddress#</email></author></entry>.*?$":"\1","^.*-nada$":"","^.*<id>(.*)</id>.*$":"\1"

[MeasureIsCommand]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureGetCommand]
StringIndex=1
DecodeCharacterReference=1
DynamicVariables=1
RegExpSubstitute=1
Substitute='"':"€€€€","\r":"","\n":"","\t":"","^(.*)<id>#LastID#</id>.*$":"\1","^(.*)$":"\1-nada","^.*<entry><title>#RemoteSubject#</title>(.*?)<email>#RemoteSenderAddress#</email></author></entry>.*?$":"\1","^.*-nada$":"","^(.+)$":"1","^$":"0"

[MeasureCalc]
Measure=Calc
Formula=([MeasureIsCommand])
DynamicVariables=1
IfEqualValue=1
IfEqualAction=[!WriteKeyValue WhatHappened Executed "#CRLF#[MeasureTime] - [MeasureGetCommand]" "#@#RainmeterEmailRemote.log"][!WriteKeyValue Variables LastID "[MeasureGetID]" "#CURRENTFILE#"][#Command#][!Refresh "#CURRENTCONFIG#"]

[MeterIRInvisible]
Meter=String



edit: left my email in the substitute. fixed
You do not have the required permissions to view the files attached to this post.
Randy21590
Posts: 10
Joined: August 17th, 2013, 5:38 pm

Re: Reading commands

Post by Randy21590 »

Question. I want to implement multiple commands. Do I add something like TriggerText2=hibernate, TriggerBang2=["shutdown.exe" -h] to the code? Or is there something more?

Ah, I didn't see moshi's code. Thank you!