It is currently May 3rd, 2024, 1:41 am

Command line plugin?

Share and get help with Plugins and Addons
RedK
Posts: 12
Joined: March 18th, 2012, 10:28 pm

Command line plugin?

Post by RedK »

I'm currently working on plugin (C#) that can receive command line output and send input to it in real-time. Basically there is one problem. I can't programmatically detect when console application starts to wait for user input (i was lead to believe that is impossible).
So, i see 3 options right now:
1. Disable further input capabilities until applications has exited. So the plugin basically will work like "Run..." in Windows, but, with real-time output to rainmeter skin.
2. Make user to decide when the input is needed, basing on output info. (not a preferred option, as for me).
3. No one need this half working ****, go home and stop bothering people.

P.S.
For real-time update i use this scheme: Application creates new line of output text => Plugin through API updates Measure that will show output => Measure updates its text via requesting it from plugin => New output line is displayed in the measure. Is this scheme ok with rainmeter, cause some console application may produce a lot of output lines in a little time-frame?
User avatar
JoBu
Posts: 271
Joined: February 16th, 2011, 12:46 am
Location: California

Re: Command line plugin?

Post by JoBu »

Certainly not 3! I'd love to use this, can't wait to see where it goes. Thanks for your work!
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Command line plugin?

Post by poiru »

RedK wrote:For real-time update i use this scheme: Application creates new line of output text => Plugin through API updates Measure that will show output => Measure updates its text via requesting it from plugin => New output line is displayed in the measure. Is this scheme ok with rainmeter, cause some console application may produce a lot of output lines in a little time-frame?
Yes, but you need to remember that Update/GetString will be called only on each update cycle (usually every second).
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Command line plugin?

Post by santa_ryan »

The only way I see this working is to have your plugin parse a file that has some sort of syntax telling the plugin what to "expect" ("expect" is a unix automation platform that works in this fashion) from the stdout stream and what to send in response. Having regexp built in would be nice.

Run "...": Execute this program
Expect "...": Expect this as output
Send "...": Send this as input
End: Terminates the program started by the previous run command.

RegExp Off Example:

Code: Select all

run "blah blah blah"
expect "Select option"
send "1"
expect "Confirm"
send "Y"
expect "Operation Finished"
end
RegExp On Example:

Code: Select all

run "blah blah blah"
expect "Select option: \d\. .*, \d\. .*, or \d\. .*" 
send "1"
expect "Confirm"
send "Y"
expect "Operation Finished"
end
You'd basically make your own scripting language for rainmeter.

And, getting more complex, you could add "Goto" statements to create functions and if then else statements.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
RedK
Posts: 12
Joined: March 18th, 2012, 10:28 pm

Re: Command line plugin?

Post by RedK »

To: santa_ryan

If i understand right, your idea is that my plugin must have file with settings ("Run", "Expect", etc) for every program it may run. Yes this will definitely work... if i were doing Rainmeter shell for some particular console application, which is not the case.

btw just yesterday i was told about this "expect" library, and currently digging into it.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Command line plugin?

Post by santa_ryan »

Well what ARE you trying to do? I assumed you were trying to automate a console app because of what you said in option 2.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
RedK
Posts: 12
Joined: March 18th, 2012, 10:28 pm

Re: Command line plugin?

Post by RedK »

santa_ryan wrote:Well what ARE you trying to do? I assumed you were trying to automate a console app because of what you said in option 2.
Oh, sorry, i understand your confusion and it's totally my fault. You see, after my first post i finally decided to do as i say in option 2, and after that i saw your post. :oops:
RedK
Posts: 12
Joined: March 18th, 2012, 10:28 pm

Re: Command line plugin?

Post by RedK »

UPDATE

Last version: 0.5.3.0

Known glitches: output is not perfect and some tweaking may be done in future. For instance, if program writes text pretty fast without ending the line, this line may not be captured and showed, example: when you launch "systeminfo" there is constantly updating line that shows what is loading now, my plugin won't show this line at all. There might be slight delay in displaying unfinished lines.

Notes:
-After you launch console application and till it works, all further input (what you type in TextInput) will be treated as input to that program.
-If you launch program that has GUI, plugin won't capture console IO from it, and you are free to launch another program.
-Plugin on exit don't automatically close program currently working in it. (there is !bang for it).

Plugin variables: (currently all variables have default variables and not required to be set on plugin start)
-Type=string (Type: string. Accepted values: "string". Def value: "string");
-PathAndArguments= (Type: string. Contains "[file name/command] [arguments]". Preferable left empty in the beginning. In simple: here goes line form InputText plugin. Def value: "");
-pureCMD= (Type: string. Accepted values: "true", "false". If true, when start of a new program occurs PathAndArguments are ignored, "cmd.exe" will start instead. Def value: "false");
-LinesToShow = (Type: number. Accepted values: 1-100. Determent how much of text lines will be showed in Meter. Take notice that possible Meter line wrapping capabilities are not taken into account. Note, all lines are stored inside plugin till it quits, or "cls" command was received. Def value: 10);
-OutputMeasureName= (Type: string. Contains name of a Meter that will be used to show text via !bang from my plugin. Bang plugin uses: "!SetOption [OutputMeasureName] Text [answer string]". I left empty !Band won't occur. Def value: "");
-IdleMessage= (Type: string. Message that will be shown on program normal exit. Def value "");

Bangs:
"KillEmAll" - Kill working process and all his children's.

Commands:
"cls" - Clear all received lines in plugin memory.
"debug" - show some inside variables.

P.S.
Plugin was developed and tested under Windows7 x64. Working ability in other OS was not confirmed.
And of course: You install and use this plugin at your own risk. I do not take any responsibility for any harm it may do to any kind of your property. (not that i'm implying it can do any harm)

P.P.S.
If you have any: questions, suggestions, bug reports. Feel free to post them here.


Here is last version of plugin and little example skin.
cmdWrapper.zip
cmdWrapper Moved here: http://rainmeter.net/forum/viewtopic.php?f=18&t=12038
You do not have the required permissions to view the files attached to this post.