It is currently March 28th, 2024, 7:04 pm

RunCommand

Share and get help with Plugins and Addons
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - Beta (0.0.1.0)

Post by moshi »

moshi wrote:an OnChangeAction wont help in the scenario i have in mind, as the value (success or error) might not change, but still something new has happened.
ok, i was able to work around this and use an OnChangeAction.

what i do is adding a date program (there is a program from the UNXUtils that also displays seconds) at the end of the batch file. with a few regular epression substitutes it is working ok.

but i still think this is far too complicated. (and to be honest i have no idea how to find a nicer solution for that)
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand - Beta (0.0.1.1)

Post by Brian »

Version 0.0.1.1 Beta is now available here: http://rainmeter.net/forum/viewtopic.php?p=92974#p92974

moshi wrote:my biggest problem with it right now is that i can not use the value of a measure with a FinishAction.

With the Webparser plugin i can do things like:

Code: Select all

[MeasureEvi]
Measure=Plugin
Plugin=Plugins\WebParser.dll
...
FinishAction=["someapplication.exe" "[MeasureEvi]"]
would be cool if RunCommand could do the same.
This version should (hopefully) help with this problem. The problem before was the thread that ran the program would still be "locked" when trying to run the FinishAction, so if you referenced the same measure within the FinishAction, sometimes it would not work correctly.

-Brian
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - Beta (0.0.1.1)

Post by moshi »

very cool. works great for me so far.
it seems this has also helped with the problem of not catching output. i do not see it happpen as much as before. (and what i do to test it is probably a very rare scenario, who needs the same command ran eight times anyways).

and skins obviously feel faster now.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - Beta (0.0.1.1)

Post by moshi »

just thoughts:

a Command to close a program launched from a RunCommand measure would be nice. so there would be no need for a second measure to run taskkill.

i think Commands to change states are not a good idea. while features are great in general, i expect too many incompatibilities with that.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand - Beta (0.0.1.2)

Post by Brian »

Version 0.0.1.2 Beta is now available here: http://rainmeter.net/forum/viewtopic.php?p=92974#p92974

moshi wrote:a Command to close a program launched from a RunCommand measure would be nice. so there would be no need for a second measure to run taskkill.
Done. The "Close" command will attempt to close the program properly - meaning it may ask the user to close or not. The "Kill" command will close the program without notice.


FYI - I may change the minimum Rainmeter version requirement of the plugin to the first Rainmeter 3.1 beta since some changes to how plugins use the log have been made. Obviously I won't do that until the first Rainmeter 3.1 beta has been released (which might not be for a week or so).

-Brian
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - Beta (0.0.1.2)

Post by moshi »

Brian wrote:Done. The "Close" command will attempt to close the program properly - meaning it may ask the user to close or not. The "Kill" command will close the program without notice.
very nice. i was expecting some problems with that, like closing all instances, closing last instance, etc.
but no ... so far everything works as it should. :)

so the only feature left, that i personally would like, are some OnError101Action, OnError102Action, ..., actions. so there can be more feedback than just the log.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - WIP (0.0.0.2)

Post by moshi »

Brian wrote: The next version will also close any program that is running if the skin and/or Rainmeter is closed. This should fix any hidden programs from running beyond the scope of the skin or Rainmeter itself.

i noticed that after a refresh of a skin, i can run the same command again and do not get an error message (try the notepad one from your example skin without a timeout). cpu use increases dramatically of course.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand - Beta (0.0.1.2)

Post by Brian »

moshi wrote:i noticed that after a refresh of a skin, i can run the same command again and do not get an error message (try the notepad one from your example skin without a timeout).
We sort of touched on this earlier when discussing the closing of programs when the skin unloads (or Rainmeter itself), and I think we both agreed that this should only happen when in the "Hide" state. http://rainmeter.net/forum/viewtopic.php?p=93192#p93192

There is no real solution to this as the once the skin is closed, there is no way to "save" any valid internal process information for the plugin to associate at a later time. I could write the information to a file (ie. Rainmeter.data), but if the skin isn't loaded for some time (hour, day, week), the process information could be valid for another (incorrect) process.

It is probably best to close the program with the "Close" command during a "OnCloseAction" in these cases.

moshi wrote:cpu use increases dramatically of course.
This will be fixed in the next version. Basically the problem is the thread that runs the command uses a loop to check if data is ready to be read. I have tested some "wait" functions that consume considerably less CPU time and have gotten some good results. Look for a new beta tomorrow.

moshi wrote:so the only feature left, that i personally would like, are some OnError101Action, OnError102Action, ..., actions. so there can be more feedback than just the log.
I am still mulling over the proper way to do this. Right now there is 7 error messages possible (2 of them very rare), and I am deciding which ones would warrant an action.

-Brian
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: RunCommand - Beta (0.0.1.2)

Post by moshi »

Brian wrote:We sort of touched on this earlier when discussing the closing of programs when the skin unloads (or Rainmeter itself), and I think we both agreed that this should only happen when in the "Hide" state. viewtopic.php?p=93192#p93192

There is no real solution to this as the once the skin is closed, there is no way to "save" any valid internal process information for the plugin to associate at a later time. I could write the information to a file (ie. Rainmeter.data), but if the skin isn't loaded for some time (hour, day, week), the process information could be valid for another (incorrect) process.

It is probably best to close the program with the "Close" command during a "OnCloseAction" in these cases.
in what i was trying to say it doesn't really matter whether a program is hidden or not.

usually when you try to start a program a second time, you get a 101 error.

if you refresh the skin though, you do not get this error and the program can be launched a second time, or a third time after an other refresh.
a OnCloseAction has no effect here as it is not executed on a refresh.
a OnRefreshAction doesn't help either as you would just get a 102 error.

this is a serious flaw in my opinion as a refresh can happen any time, be it only from using the RainFile file picker from an other skin.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand - Beta (0.0.1.3)

Post by Brian »

Version 0.0.1.3 Beta is now available here: http://rainmeter.net/forum/viewtopic.php?p=92974#p92974

moshi wrote:in what i was trying to say it doesn't really matter whether a program is hidden or not.

usually when you try to start a program a second time, you get a 101 error.

if you refresh the skin though, you do not get this error and the program can be launched a second time, or a third time after an other refresh.
a OnCloseAction has no effect here as it is not executed on a refresh.
a OnRefreshAction doesn't help either as you would just get a 102 error.

this is a serious flaw in my opinion as a refresh can happen any time, be it only from using the RainFile file picker from an other skin.
I changed the behavior a little bit on this version. Previously, if the Timeout value was reached (if defined), then the program would terminate immediately like the Kill command. This really isn't correct behavior since the user should be asked if they want to close the program. So starting in version "0.0.1.3", if a Timeout value has been reached, the program will attempt to exit cleanly (eg. like the Close command). Of course if the program is in the Hide state, it is terminated via the Kill command.

The same thing thing goes for when the skin is unloaded (or Rainmeter is exited). Since we are associating a program with a skin, it only makes sense to attempt to close that program if the skin is unloaded. Even if the program cancels the close of the program, the plugin no longer associates with the program anymore. Also, I incorrectly assumed that Rainmeter would make a new "window" on refresh, but it doesn't - it just uses the same window while unloading the plugin and re-loading it (ie. all the plugin data is lost).

So basically:
Pre-0.0.1.3: If the Timeout is reached, the program terminates via Kill. If the program is still running when the skin closed, it was only terminated via Kill if in the Hide state. If the skin was refreshed, the program still ran like nothing happened.

0.0.1.3+: If the Timeout is reached, the program terminates via Close unless hidden, then via Kill. If the program is still running when the skin closed or refreshed, it terminates via Close unless hidden. If any program prevents itself from closing (like cancelling any changes in Notepad), the plugin will not keep running and stop expecting any output (the Kill or Close commands should no longer work either).

CPU usage when the program is running should be greatly diminished with this version.

-Brian