It is currently March 28th, 2024, 9:11 pm

Update measure within a command batch

Get help with creating, editing & fixing problems with skins
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Update measure within a command batch

Post by Bananorpion »

(Yes, this is exactly the same topic I posted on another section, given that I'm not sure now it was the right one to begin with.)

Here's the trick: I created a File Explorer skin, using mostly Fileview plugin, as well as Webparser. At some point, I'm using a measure to find a path in another file, to set the new path on the current skin. But I can't do it all within a single command.
More clear with the code, I think (I removed anything unrelated with the bug, it won't work like this of course.)

Code: Select all

[MeasurePath]
Measure=Plugin
Plugin=FileView
FinishAction=[!WriteKeyValue #CURRENTSECTION# Path "[MeasurePath]"][!Update]

[MeasureExplorer1Path]
Measure=Plugin
Plugin=WebParser

[MeasureExplorer1PathChild]
Measure=Plugin
Plugin=WebParser
URL=[MeasureExplorer1Path]

[MeterTitle]
Meter=STRING
MouseScrollUpAction=[!WriteKeyValue MeasurePath Path "[MeasureExplorer1PathChild]"][!Refresh]
MouseScrollDownAction=[!CommandMeasure MeasureExplorer1Path Update][[!CommandMeasure MeasureExplorer1PathChild Update]]


It mostly works: the scroll down updates the necessary values, and the scroll up writes the new value. But if I try to do the whole thing within a single command, it does not work, because (I guess, I haven't looked into the source code 'cause C++ scares me) the whole batch of command is already prepared before the measures update, so the command, even after the measures update, still uses the former value.
So, is there a workaround? So I can do something like

Code: Select all

MouseScrollUpAction=[!CommandMeasure MeasureExplorer1Path Update][[!CommandMeasure MeasureExplorer1PathChild Update]][!WriteKeyValue MeasurePath Path "[MeasureExplorer1PathChild]"][!Refresh]
(I can't really post the full skin here to test it, unless asked to, because it is huge and requires several @include files.)
Last edited by Bananorpion on May 16th, 2017, 3:18 pm, edited 1 time in total.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Update measure within a command batch

Post by Brian »

If I am understanding your post/problem correctly, I think you may have a threading issue.

Webparser and FileView both use threads to do the 'work' so that Rainmeter does not hang while waiting for the results of those measures. So when you fire a bang to update a webparser measure followed by a !Refresh bang....chances are that the webparser measure hasn't finished yet before the skin is refreshed.

You may need a design overhaul with what you are trying. While not sure, I suspect you really don't need a full !Refresh of your skin to accomplish your goal. You can dynamically set variables via the !SetVariable bang, or dynamically change options via the !SetOption bang. In most cases, using those 2 bangs followed by a !UpdateMeasure/!UpdateMeter and a !Redraw is all that is needed - instead of just refreshing the skin which kills all threads for that skin, destroys the skin, then rebuilds it.

Without seeing your code, its hard to give you a precise solution.

-Brian

PS - A couple of more things. #1) I don't think you need a !Update bang in your FinishAction. It would be better to just update the measures/meters that are affected and then do a !Redraw. #2) Child webparser measures cannot be updated, only the parent measure (which forces its children to be updated).
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: Update measure within a command batch

Post by Bananorpion »

The !Refresh is my mistake, I should have removed it from the code I posted, it is actually used for irrelevant parts of the skin, but the problem appeared before I used it. (Same thing for the !Update)
I tried both !SetVariable and !SetOption, but the problems remains. I'm not sure this might be a "slow update" problem, because the double scroll (up down) technique works in less time than the update is set to (even works with Update=-1)

To me, the problem is that I can't find out a way to automate several commands with updates between them, or force an update of the measure BEFORE next commands start. Only way I can think of would be starting a timer and executing the following batch of command after some time (enough to be sure the webparser measure has updated. It comes from a local file, so it's almost instantaneous anyway)

Here is a functional version of the skin to get a better picture. (I removed some features, comments or used-once-only variables 'cause it's very long, and added the necessary variables from other files, thus there might be useless remaining parts, but it works on its own.)

(I also edited the URL from MeasureExplorer1Path if there needs to test, so it can be tested from the same directory.)
(I removed the update of the child measure, since it's useless)

Code: Select all

[Rainmeter]
BackgroundMode=2
SolidColor=#Click#
OnRefreshAction=[#RefreshPathExplorer#][#RefreshInputDefaultValue#][!Update]

[Metadata]
Name=Explorer 2
Author=Bananorpion
Information=Dynamic skin. Displays as text the current path, and the first eight items of the directory. Mouse left click on the title: opens the current directory in the file explorer. Mouse right click on the title: reloads the skin. Mouse left click on an item: updates path if the item is a directory, opens via default explorer command if the item is a file. Mouse right click on an item: opens default explorer context menu. Mouse scroll up/down on the item list: goes one up/down in the current directory file index. Mouse scroll left/right on the item list: goes eight up/down in the current directory file index. Mouse left click on the path: opens an input box to select a new path. Mouse scroll up, then down on the title: copies and pastes the path from the skin Explorer 1 in place of the path from the current skin.
Version=1.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
IconsPath=#@#Icons\Explorer 2\

;;;;;;;;;;;;; to be removed

RefreshPathExplorer=!SetOption Title LeftMouseUpAction """explorer.exe "[MeasurePath]"""
RefreshInputDefaultValue=!SetOption MeasureInput DefaultValue "[MeasurePath]"
InputFontSize=11
FontSize16M=16
FontSize11M=11
MainFont=Consolas
ExplorerFont=Consolas
Click=0,0,0,1
White=255,255,255,255
BaseBlack=0,0,0
Black=#BaseBlack#,255
BlackA200=#BaseBlack#,200
GoldenLight=248,218,118,255

;;;;;;;;;;;;; to be removed

[MeasurePath]
Measure=Plugin
Plugin=FileView
Path=C:\
FinishAction=[!WriteKeyValue #CURRENTSECTION# Path "[MeasurePath]"][#RefreshPathExplorer#][#RefreshInputDefaultValue#][!Update]

[MeasureInput]
Measure=Plugin
Plugin=InputText
X=[Path:X]
Y=[Path:Y]
H=50
W=450
FontFace=#InputFont#
FontSize=#InputFontSize#
ClipString=1
SolidColor=#BlackA200#
FontColor=#GoldenLight#
Command1=[!WriteKeyValue MeasurePath Path "$UserInput$"][#RefreshPathExplorer#][#RefreshInputDefaultValue#][!Refresh]

[MeasureExplorer1Path]
Measure=Plugin
Plugin=WebParser
;URL="file://#ROOTCONFIGPATH#Explorer 1\Explorer 1.ini"
URL="file://#CURRENTPATH#test"
RegExp=[^s]Path=(.*)
CodePage=1252
ForceReload=1

[MeasureExplorer1PathChild]
Measure=Plugin
Plugin=WebParser
URL=[MeasureExplorer1Path]
StringIndex=1
RegExpSubstitute=1
Substitute="\r":""

[Title]
Meter=STRING
MeterStyle=TitleMeter
FontColor=#White#
FontFace=#MainFont#
FontSize=#FontSize16M#
StringStyle=Bold
AntiAlias=1
Text="Explorer"
MouseOverAction=[!SetOption #CURRENTSECTION# SolidColor #Black#][!SetOption #CURRENTSECTION# FontColor #GoldenLight#][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# SolidColor #Click#][!SetOption #CURRENTSECTION# FontColor #White#][!UpdateMeter #CURRENTSECTION#][!Redraw]
RightMouseUpAction=[!Refresh]
;;; problem is down here
MouseScrollUpAction=[!WriteKeyValue MeasurePath Path "[MeasureExplorer1PathChild]"][!Refresh]
MouseScrollDownAction=[!CommandMeasure MeasureExplorer1Path Update]
;;; problem is up here
UpdateDivider=-1

[Path]
Meter=STRING
MeterStyle=PathMeter
MeasureName=MeasurePath
X=0R
Y=0
H=50
W=460
FontFace=#ExplorerFont#
FontSize=#FontSize11M#
FontColor=#GoldenLight#
ClipString=1
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure "MeasureInput" "ExecuteBatch 1"]
UpdateDivider=-1
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: Update measure within a command batch

Post by Bananorpion »

Asking again if anyone knows a trick I didn't find.
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: Update measure within a command batch

Post by Bananorpion »

Last try :(
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5383
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Update measure within a command batch

Post by eclectic-tech »

Bananorpion wrote:Last try :(
The code you posted is not complete enough for anyone to try to test. It does not show the directory list...
crippled.png
That makes it difficult to understand your problem or offer any help. :confused:

You might consider posting your entire package, so someone can see what it does or doesn't do the way you want...
You do not have the required permissions to view the files attached to this post.
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: Update measure within a command batch

Post by Bananorpion »

eclectic-tech wrote:The code you posted is not complete enough for anyone to try to test. It does not show the directory list...

crippled.pngThat makes it difficult to understand your problem or offer any help. :confused:

You might consider posting your entire package, so someone can see what it does or doesn't do the way you want...

Mmh, I thought the directory list would be "too much information".
Attached the package with "everything" (excluding irrelevant skins or documents).
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5383
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Update measure within a command batch

Post by eclectic-tech »

If I understand, I believe you want to have Explorer 2 open with the current path of Explorer 1...

You can do that by adding a FinishAction in Explorer 2 [MeasureExplorer1Path] section.

Code: Select all

[MeasureExplorer1Path]
Measure=Plugin
Plugin=WebParser
URL="file://#ROOTCONFIGPATH#Explorer 1\Explorer 1.ini"
RegExp=[^s]Path=(.*)
CodePage=1252
ForceReload=1
FinishAction=[!SetOption MeasurePath Path "[MeasureExplorer1PathChild]"][!CommandMeasure MeasurePath Update][!UpdateMeasure MeasurePath][!UpdateMeter Path][!Redraw]

When [MeasureExplorer1Path] finishes reading the path from Explorer 1, it will set the path option in [MeasurePath] to Explorer 1 path, update the Fileview plugin, update the measure, update the string meter, and redraw.

So no matter where Explorer 2 path was when it was closed, when it is opened, it will read the current path of Explorer 1 and use that as it's path.

Hope this is what you were trying to do...

Aside: You have set a few command bangs as variables... I would recommend that you put your 'command' variables in brackets [], so you could combine them.

Edit: I meant to mention you have the parameters for !ActivateConfig and !DeactivateConfig incorrectly assigned; !ActivateConfig requires the config name AND the ini file to activate (you only set the config name), while the !DeactivateConfig does NOT need the name of the ini file, only the config name (but you supplied a ini file)...
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: Update measure within a command batch

Post by Bananorpion »

eclectic-tech wrote:If I understand, I believe you want to have Explorer 2 open with the current path of Explorer 1...

You can do that by adding a FinishAction in Explorer 2 [MeasureExplorer1Path] section.

Code: Select all

[MeasureExplorer1Path]
Measure=Plugin
Plugin=WebParser
URL="file://#ROOTCONFIGPATH#Explorer 1\Explorer 1.ini"
RegExp=[^s]Path=(.*)
CodePage=1252
ForceReload=1
FinishAction=[!SetOption MeasurePath Path "[MeasureExplorer1PathChild]"][!CommandMeasure MeasurePath Update][!UpdateMeasure MeasurePath][!UpdateMeter Path][!Redraw]

When [MeasureExplorer1Path] finishes reading the path from Explorer 1, it will set the path option in [MeasurePath] to Explorer 1 path, update the Fileview plugin, update the measure, update the string meter, and redraw.

So no matter where Explorer 2 path was when it was closed, when it is opened, it will read the current path of Explorer 1 and use that as it's path.

Hope this is what you were trying to do...
Not exactly: I want the paths to be synchronised only when I use a command, not always. But I think this could work if I change the functionality, and use a "sync/unsync" feature instead of a launcher, then I just have to pause or unpause [MeasureExplorer1Path]. Fine by me. Trying when I have some spare time. I consider the problem solved.
eclectic-tech wrote: Aside: You have set a few command bangs as variables... I would recommend that you put your 'command' variables in brackets [], so you could combine them.
'cause sometimes I have three or four commands in a row, and brackets (Different syntax coloring) help me see quickly where they start or end. (In another skin, I have 48 commands in a row)

eclectic-tech wrote:I meant to mention you have the parameters for !ActivateConfig and !DeactivateConfig incorrectly assigned; !ActivateConfig requires the config name AND the ini file to activate (you only set the config name), while the !DeactivateConfig does NOT need the name of the ini file, only the config name (but you supplied a ini file)...
Mmh, it's a long time since I implemented this, but activating and deactivating both fully work, I tested it right now to be sure. :/ Have you tried it?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5383
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Update measure within a command batch

Post by eclectic-tech »

The !ActivateConfig bangs in your skin all reported errors in the log...

You did not include the associated configs, but the errors mean they will not be activated.

!DeactivateConfig will work with, or without the IN file name, but it is not needed to work. :welcome: