Can I run a script without popping up a window?

Started by ubacher, July 27, 2017, 05:55:57 PM

Previous topic - Next topic

ubacher

I have at least one script which needs no output to the window whatsoever.
Writing to the log is the only output - and I could even do without it.

If one were to put the script into the header would it not run without having to put up any window i.e. any html code?
An empty body?

Why bother? I just think it might speed things up quite a bit.

Mario

All apps require a browser window - either an App Panel or the modal app window.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Quote from: ubacher on July 27, 2017, 05:55:57 PM
I have at least one script which needs no output to the window whatsoever.
Writing to the log is the only output - and I could even do without it.

If one were to put the script into the header would it not run without having to put up any window i.e. any html code?
An empty body?

Why bother? I just think it might speed things up quite a bit.

I'm 100% with you there ...

thrinn

I doubt there would be any speed improvement at all. Modern browser engines are quite capable regarding rendering and  JS execution. If you use a minimal html page without e.g. updating it for every file you process, the overhead is really negligible.

To "run" a JavaScript without a window is easier said than done: Normally, the JavaScript engine (which interprets and executes your code) is an integral part of the browser. I do not know how IMatch exactly works internally, of course, but I think the ability to understand JS is part of the Chromium framework and always linked to some kind of browser window: an app panel, in  IMatch terms.

It is like using JS on the server side in Web development: You need a separate JavaScript engine like node.js to be able to execute JS outside of a browser.

Thorsten
Win 10 / 64, IMatch 2018, IMA

ubacher

I think the desire to not put up a window has never been considered by the developers of Chromium etc. It is that
the way we use it is not really "normal"

So I just have to see the empty window pop up and disappear again.

Mario

The only solution for this would be invisible non-modal browser windows. But even invisible windows cause focus shifts and other side-effects which IMatch would need to handle somehow...

It is important to understand that you don't need to run your script in an App Panel or modal app window. You can also write your script to run outside of IMatch, e.g. by writing your script in Windows PowerShell, Python, Visual Basic, .NET, Perl, ...

Or, to retain your existing JavaScript code, wrap it so it can be run by Node.js. Node.js is a standardlone JavaScript engine without a browser (based on the same JavaScript engine as Chromium and Google Chrome). Node.js drives half of the Internet already, and makes it super-easy to write apps in JavaScript which don't need a browser.

Have a look at https://www.w3schools.com/nodejs/ for a start.

Again, if you want to write an app which has no UI and does neither need a modal window (to block the IMatch UI and prevent the user from interfering with your script) and your script does not produce any usable output so it should run in an app panel, chances are that your script should run outside of IMatch anyway. With IMatch 2017 you can do that, using the programming environment and language of your choice.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

I converted some if my scripts to python,which run outside of IMatch.
Works great!

I call the script from the favourites panel inside IMatch.

Carlo Didier

Quote from: ubacher on July 29, 2017, 10:39:24 AM
I think the desire to not put up a window has never been considered by the developers of Chromium etc. It is that
the way we use it is not really "normal"

Define "normal"  8)
For me, for automation tasks, it is normal.
I suppose this is by design for security reasons, so that a script on a webpage won't run invisibly without the user at least knowing that there is something going on, although I'm pretty sure a good hacker can find a way around that too ...

Mario

Chromium is a browser. If you want to run JavaScript without a browser, use Node.js.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook