setting "autofresh", 0 -> not working as expected?

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

setting "autofresh", 0 -> not working as expected?

Post by highend »

Latest beta...

Configuration | Tree and List | List | Always show folder sizes
in on

I'm sending two scripts to XY via WM_COPYDATA shortly after another

The first one is a query script to get a few infos from XY (which view, selected files, etc).
It's first line is:

Code: Select all

setting "autorefresh", 0;

The second script builds a menu and it uses this block:

Code: Select all

"_Initialize" setting "autorefresh", 0;
But foldersizes are autorefreshed a milisecond before the menu pops up...

The effect can be seen in this gif animation:
GIF.gif
Only turning "Configuration | Refresh, Icons, History | Auto-Refresh | Auto-refresh"
off helps...
To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: setting "autofresh", 0 -> not working as expected?

Post by TheQwerty »

I don't have the time to explore but two initial thoughts:

1) When the first script finishes executing XY restores the state of AutoRefresh - could this be triggering the refresh? (Works as intended but not ideal for your uses.)

2) Similarly, does XY treat the conclusion of "_Initialize" as the end of the script and restore the setting then before proceeding with the rest of the script? (Possible bug.)

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: setting "autofresh", 0 -> not working as expected?

Post by highend »

Thanks, TheQwerty!

1.) Is the case, reenabling autorefresh (because the script is finished) automatically triggers a refresh...

Code: Select all

    setting "autorefresh", 0;
    status "test";
Scripts finishes, the list autorefreshes...

So a solution like storing the current state of autorefresh in a permanent variable, set it to off permanently in the first script and at the end of the second put the stored setting in place -> If autorefresh was on before it will now refresh again, same behavior

Any workaround available?
One of my scripts helped you out? Please donate via Paypal

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: setting "autofresh", 0 -> not working as expected?

Post by TheQwerty »

SC Get supports Auto-Refresh (#480) so as you mentioned you can store and restore the state.

I think that's the only workaround right now.

If your scripts don't trigger a location (or tab) change you could probably get by just enabling Suspend Auto-Refresh and be lazy about restoring its state - that might even be a better option in the off chance your script doesn't complete or XY does not restore auto-refresh. However, you cannot currently determine its state and the only way to enable it is via CID/button which will both perform a toggle so that's no good.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: setting "autofresh", 0 -> not working as expected?

Post by highend »

SC Get supports Auto-Refresh (#480) so as you mentioned you can store and restore the state.
Yeah, that's what I tried. In the moment you set it back to it's last value (that you've stored in a permanent variable) and assuming it was on before -> Autorefresh happens

The script doesn't do anything to modify the list pane and it doesn't switch (goto) anywhere so the autorefresh after it has ended is unnecessary but there doesn't seem to be a way to avoid that (atm)...

Even worse: When restoring the last autorefresh state any status "..."; command outputs are immediately overwritten through the following autorefresh...
One of my scripts helped you out? Please donate via Paypal

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: setting "autofresh", 0 -> not working as expected?

Post by TheQwerty »

Manual Sorting will Suspend Auto-Refresh - but again toggle with no easy state detection.

It looks like SortByList will also quietly suspend auto-refreshing so you could try this very ugly hack:

Code: Select all

// Store the current sort order - unfortunately we cannot get secondary sorting as well.
$s = Get('Sort');

// Sort the current list by the current list.
SortByList ListPane(), '|';

// Whatever you want to do...
Status 'hello';
Echo 'modify something in the current folder to see it not refresh';

// Restore the original primary sort order.
SortBy GetToken($s, 1, ','), GetToken($s, 2, ',');
I'm not sure how to get XY out of the "SortByList" mode but restoring the original sort order seems to work.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: setting "autofresh", 0 -> not working as expected?

Post by highend »

Very creative but way too ugly :ninja:

Thanks for your input!
One of my scripts helped you out? Please donate via Paypal

Post Reply