new info property for get()

Features wanted...
Post Reply
highend
Posts: 14733
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

new info property for get()

Post by highend »

Hi,

I'm planning on creating a (hopefully) interesting external addon to XY.

What I'd need XY to support it: Beeing able to return if a script is currently executed (or not).

So a:
get("ScriptState")
or
get("ScriptRunning")

with 1 (running) | 0 (not running) as return values would be nice...

Tia,
Highend
One of my scripts helped you out? Please donate via Paypal

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: new info property for get()

Post by Marco »

I hope I'm wrong, but being XY single-threaded I fear that there's no way for a SC command to work while there's another script running.
Have you tried executing some time consuming script in XY and see if XY still responds promptly to wm_copydata messages?
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

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

Re: new info property for get()

Post by highend »

Mh... that's true...

Don, are there any other possibilites? One that I could think of is: a variable that could be displayed in the title bar... Ok, not pretty but at least something I could work with...
One of my scripts helped you out? Please donate via Paypal

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

Re: new info property for get()

Post by TheQwerty »

Marco wrote:I hope I'm wrong, but being XY single-threaded I fear that there's no way for a SC command to work while there's another script running.
Based on how Don fixed this bug it seems it is possible for two scripts to be "running" at once. Of course, maybe one has to be stopped for it to work.

To be honest, I cannot say I'm totally comfortable with having multiple scripts running concurrently given that the majority of scripts rely on assumptions and knowing XY's current state. They're tied to the UI a bit too much for me. :?

One wish I've had for a while now but haven't fully fleshed out or formally made is a way to mark script files as trusted, which would let XY ignore Stepping Mode if enabled and just run the script. Maybe it makes sense to expand this to include a bit of a permissions model. (ie. Allow this script to run in background, without stepping, download/load resources from the Internet.) Something to consider while I wait for a good time to spring this on Don. ;)


On the actual issue...
highend wrote:a variable that could be displayed in the title bar...
Changing the titlebar seems the most promising. Considering that scripts really aren't meant to run in the background, I'd say it would make a lot of sense for XY to append " - Running Script..." to the title bar when one is running. This could even be taken a step further to include the initial script's caption/file.

You could technically get close to this today (abuse aliases, <get alias titlebar>, goto('@titlebar=running');) but you have to trigger a refresh of the titlebar which I think only happens on location changes. Plus you have the problem of resetting it when the script is cancelled, stopped, or ends unexpectedly.

Some other possibilities:
Perhaps a lock file could be created whenever a script is running and removed when it isn't? Again, technically you could do that yourself by adjusting/wrapping your scripts, but you still have the problem of reliably unlocking.

Not sure what you're working on, but maybe you would be fine with the assumption that if the computer is idle then a script probably isn't running?

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

Re: new info property for get()

Post by highend »

I don't want XY to execute two scripts at once (until there isn't any threading...). I'd like to get the status to be able to postpone the execution of any scripts through my tool until "the other running" script has finished.

It will execute any user script so taking care for lock files (created through user written scripts) is a bit out of my hand ;(

I'm working on a tool that would allow users to quickly add scripts to a user definable timer (by date, every x minutes/hours, etc.).

E.g. for maintenance tasks or anything else that needs to be done on specific dates or reoccurring timers.

Not every task is stressful on a modern pc and even if I'd monitor XYplorer and XYcopy for cpu consumption it wouldn't let me validate if it's a script or a user that does these things...
One of my scripts helped you out? Please donate via Paypal

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

Re: new info property for get()

Post by TheQwerty »

highend wrote:It will execute any user script so taking care for lock files (created through user written scripts) is a bit out of my hand ;(
The idea there was you wrap the user scripts with a script that does this. I agree it's clunky.
highend wrote:I'm working on a tool that would allow users to quickly add scripts to a user definable timer (by date, every x minutes/hours, etc.).
I thought so. ;)
highend wrote:Not every task is stressful on a modern pc and even if I'd monitor XYplorer and XYcopy for cpu consumption it wouldn't let me validate if it's a script or a user that does these things...
I wasn't suggesting you monitor CPU consumption but more likely polling GetLastInputInfo. Again it's not ideal and I still believe having XY append "Running Script..." to the title is most promising.

klownboy
Posts: 4451
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7462 at 100% 2560x1440

Re: new info property for get()

Post by klownboy »

TheQwerty wrote:Based on how Don fixed this bug it seems it is possible for two scripts to be "running" at once
I noticed in the past getting the error message "Desc: Form already displayed; can't show modally". Thinking back I believe I was stepping through some multi-level menu type script. There was no error message unless scripting step mode was "ON". Maybe it wouldn't be too difficult for Don to detect a running script and provide feedback, 0 or 1 as highend requested.

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

Re: new info property for get()

Post by highend »

The idea there was you wrap the user scripts with a script that does this. I agree it's clunky.
I guess it would be possible (although you would have to forward things like get("trigger") and stuff like this
into the script inside the "script container") but no, way too much work.
GetLastInputInfo
Another option but the most elegant solution would be: Threading... File managers are (for me) tools that support
me on doing repeating / tedious tasks. Running multiple scripts at once is the way to go.
Don said, that he has something in the pipeline but he didn't mention where ;)
One of my scripts helped you out? Please donate via Paypal

Post Reply