It is currently March 28th, 2024, 10:53 am

How actions work in Rainmeter

General topics related to Rainmeter.
Post Reply
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

How actions work in Rainmeter

Post by death.crafter »

Recently Yincognito and I had a raging conversation on how bangs are executed in a Action with multiple bangs. Well it was more of a one sided assumed conversation from me :oops:

Here is the thread:https://forum.rainmeter.net/viewtopic.php?f=14&t=37759

But now that we are here, I would like to know how actions work in Rainmeter.

So let we have a action say:

Code: Select all

LeftMouseUpAction=[!Log "1"][!Log "2"][!Delay 2000][!SetVariable Color "FF0000"][!UpdateMeter SomeMeter][!Redraw]
So how this bang will be processed by Rainmeter.

Main questions are:

1. How the bangs are parsed?

2. In what manner they are executed. E.g. they wait for the previous bang to be completed, or they get executed irrespective of completion of previous action?

3. In multi action bangs, is each bang parsed right before execution or all of the bangs are parsed once and then executed one by one?

Thanks in advance,
death.crafter
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: How actions work in Rainmeter

Post by Brian »

death.crafter wrote: June 25th, 2021, 8:54 pm So how this bang will be processed by Rainmeter.
Just to be clear, this is a series of bangs, not just 1 bang. I know you already know this, but the concept might be confusing to some people.


Actions are parsed bang by bang. Starting at the beginning of the string, once the parser finds a complete bang, it is executed, and in most cases returns to parse the next bang.

The only exception is the !Delay bang (as eluded to in the linked thread in your post). Once the delay bang is parsed, it sends the remaining defined bangs (declared after the delay bang sequentially) to a timing function that sends the remaining bangs back to the action parser after the defined delay.

Another perceived exception is a bang that executes another thread (like RunCommand or ActionTimer can do). The bang itself runs sequentially in the bang sequence, but the thread might do "other" bangs that execute later.

death.crafter wrote: June 25th, 2021, 8:54 pm In multi action bangs, is each bang parsed right before execution or all of the bangs are parsed once and then executed one by one?
Yes, this is correct.

-Brian
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: How actions work in Rainmeter

Post by death.crafter »

Brian wrote: June 26th, 2021, 8:21 am Just to be clear, this is a series of bangs, not just 1 bang. I know you already know this, but the concept might be confusing to some people.


Actions are parsed bang by bang. Starting at the beginning of the string, once the parser finds a complete bang, it is executed, and in most cases returns to parse the next bang.

The only exception is the !Delay bang (as eluded to in the linked thread in your post). Once the delay bang is parsed, it sends the remaining defined bangs (declared after the delay bang sequentially) to a timing function that sends the remaining bangs back to the action parser after the defined delay.

Another perceived exception is a bang that executes another thread (like RunCommand or ActionTimer can do). The bang itself runs sequentially in the bang sequence, but the thread might do "other" bangs that execute later.




Yes, this is correct.

-Brian
Thank you for your explanation Brian. Really appreciate it.

But you left out one question. The second one. So say I have, [!SetVariable XX "1"][!UpdateMeter XX][!Redraw].

So will [!UpdateMeter XX] wait for !SetVariable XX "1"'s completion? Or it will execute even if due to some reason the previous bang was not executed in proper time?
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: How actions work in Rainmeter

Post by Brian »

death.crafter wrote: June 26th, 2021, 8:31 am But you left out one question. The second one. So say I have, [!SetVariable XX "1"][!UpdateMeter XX][!Redraw].
I did answer it indirectly.
Brian wrote: June 26th, 2021, 8:21 am Actions are parsed bang by bang. Starting at the beginning of the string, once the parser finds a complete bang, it is executed, and in most cases returns to parse the next bang.
death.crafter wrote: June 26th, 2021, 8:31 am So will [!UpdateMeter XX] wait for !SetVariable XX "1"'s completion?
Yes, each bang is executed in order and the next bang is not even parsed until the previous bang has finished executing.

death.crafter wrote: June 26th, 2021, 8:31 am Or it will execute even if due to some reason the previous bang was not executed in proper time?
No. All bangs always execute in order and wait for the previous bang to complete. Again, its possible that a threaded plugin (such as ActionTimer) to "send" bangs from a different thread and the main Rainmeter thread might not "see" it in the order it was sent. If you have played with ActionTimer enough, you may find yourself in a situation where a bang was "skipped" or "dropped" because Rainmeter was busy doing something else.

-Brian
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: How actions work in Rainmeter

Post by death.crafter »

Brian wrote: June 26th, 2021, 8:45 am I did answer it indirectly.






Yes, each bang is executed in order and the next bang is not even parsed until the previous bang has finished executing.




No. All bangs always execute in order and wait for the previous bang to complete. Again, its possible that a threaded plugin (such as ActionTimer) to "send" bangs from a different thread and the main Rainmeter thread might not "see" it in the order it was sent. If you have played with ActionTimer enough, you may find yourself in a situation where a bang was "skipped" or "dropped" because Rainmeter was busy doing something else.

-Brian
I see. Thanks again Brian for taking your time to explain.
Post Reply