How to open and minimize running programs in Electron JS? - javascript

I have a project that simply needs to select two different running programs and handle their windows, opening one in full screen, then minimizing it and doing the same for the second one, in an infinite loop, similarly of what ALT + TAB does, but in an automatic way, so i can monitor these two choosen windows' content without having to alt+tab them. I'm trying to do this on Win10.
I took i look at Electrons shell in both shell.showItemInFolder and shell.openPath, passing the directories of the two programs i wanted to show and minimize and i wrapped them in a setInterval loop to manage the show/minimize but it didn't help since it only opens the file explorer, not an actual running program.

Related

Using Internet Explorer, from the UI of a website is it possible to view the Javascript that is behind certain functionality

I know a small amount of web development but not enough to make it a career. I am working for an organization that is restricted to using internet explorer and one of the main sites that we use is constantly undergoing changes and always has bugs.
I'd like to see if I can try to see some of the code behind the bugs sometimes. When I use developer tools on the site, I can see that there are about 20 or more JavaScript files downloaded. Each file is a few hundred to a few thousand lines long. Is there any type of tool that I can use in Internet Explorer browser tools that can show me what JavaScript is being executed when actions happen on the webpage?
e.g.: I click a button and a form appears. I then click a button on that form and a snackbar appears, but it always appears in random places. Is there any way I can see the JavaScript that was executed to display the snackbar, rather than search line by line in the JavaScript?
Well the answer is yes, but for more complicated sites it will be a painful experience. Without concrete knowledge of the javascript framework/library used it will often be near impossible.
Having the sourcecode for the website would help greatly. When the website has minified javascript it's pretty much a must.
Sometimes an element like a button will have an onclick attribute which makes a function call. Other time some function is attached to an element from javascript by addressing it by it's id etc.
Searching through the scripts using the F12 tools in Internet Explorer is very limited.
You can of course download some of the javascript files so you can browse them in a text/code editor. They may improve you ability to search etc.
If you can find some entry point you could use breakpoints with the debugger and step through to see what happens and what gets called.

What are the proper ways to troubleshoot js drag and drop?

I need to troubleshoot a problem with javascript drag and drop and need some counsel as far as the proper way to do it. I have some experience working in the console and often using inspect in Chrome browser. I don't mind installing other browser extensions if they will help. The problem is a drag and drop function that works in some circumstances and not in others. This takes place on two separate pages of the same type in a Rails application that should have all the same javascript present. My plan of attack is the following but feel free to advise me otherwise:
Find the javascript code responsible for the drag and drop. How do I do that?
Debug the code. I think by setting breakpoints and stepping through it and comparing it on two separate pages, one where it's working and the other where it's not. Will I run into problems debugging, though, since drag and drop requires me to hold down the mouse button and traverse the tracking pad at the same time and the instant I stop I will no longer be running through the drag and drop code?
EDIT: I found Firebug's Profile tab in Firefox and using that I can see that in the page that works just mousing over a blank part of the page fires off 5 js functions, while nothing happens doing the same on the other page. So apparently the working page is listening for events that the non-working page is not, though the pages should be identical in that aspect as they are generated from the same code. Now the question is how can I find out why these listeners aren't there on the non-working page?

Using arrows to navigate a page in Chrome

So the situation is that I have a media PC (Ubuntu, kodi, mythtv, chrome) and I have a chrome launcher for things like netflix to open up. However, this creates an issue when trying to browse with the remote (using an xbox 360 media remote).
I think the easiest way to get around this would be somehow be able to use the arrow and OK keys to navigate around different elements on the site (so in the main screen the different shows/movies, and in them the different episodes etc). There are 2 ways I see to approach this:
1) A generic solution. This means it would work for all websites, and may be a page with javascript that loads the required webpage into a frame or something similar, or it may be a chrome extension.
2) A site specific option. So code written just to be run on the netflix page and could be run from something like CJS (https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija?hl=en).
I think one of the hardest things would be to work out where elements are on the page to be able to go left/right as well as up/down.
Any ideas?

Is there a way to control browser size and position across multiple displays / monitors?

Preface
First of all, I am very well aware that webapps should not fiddle with window size or position. Been through a lot of similar SO questions and forum posts.
But this is a special case, where the browser is just a platform to run an app on several specific machines in a controlled environment.
Task
The app should manage windows across several displays. (up to 5)
What I've tried until now
Searched for methods for gaining information about the host system display information, but the window.screen object only reports properties of the display the window is currently on (or considered to be on, if it is halfway on one)
Tried window.moveTo and window.open with flags "left=123,top=123" but they are always limited to the current display
Tried window.resize and window.open with flags "height=123,width=123" but just as with the moveTo they are limited to the current display.
Question
What could I do to make my application use (without manual window positioning) all the available space in a multi display environment?
Scenario
Think of it like I have two projectors correctly aligned, and would like to make it possible for:
each project to project different things (each projector projecting its own browser window)
project an app seamlessly across both projectors (possibly fullscreen)
There could/should be a window running the master window layout logic
Note
I can use any flags, app or kiosk mode, as again: we deploy the app to the target environment.
The browser options are Chrome(preferred), Chromium, and Firefox on a Windows platform (because of the special video card we will be using for 5 displays).
Fallback solution
Manually stretch a window across available displays and run the apps in iframes within this master window.
Drawback: A single process is running everything, so should an app break within a frame it breaks everything.
Afterword
Also a solution to this question would be a great help as well: Windows / Chrome / ATI / Browser fullscreen across multiple monitors
Go with a chrome/firefox extension that has access to window/tabs specific APIs.
Either embed your whole application in the extension or communicate with the extension through messages (chrome, there's an equivalent on firefox).
Support in Chrome is experimental.
You can use window.moveTo(-1000,100) to move a pop up to a second monitor in IE if you check the permission "allow script-initiated windows without size or position constraints" under Internet Options/Security/custom level.
If you only have a single monitor connected, it will move the window to the edge of the primary display. I have not found a way to do it in Chrome though, it doesn't appear to have the same security option.
Try using the chrome.windows API to interact with browser windows. You can use this API to create, modify, and rearrange windows in the browser.
https://developer.chrome.com/extensions/windows
It even works with nightwatch.
Another possible solution is to use the win32 to size & position the window.
As seen in the solution of question: Chrome Packaged App and Dual Monitors (no code there, this is just for reference)
I don't think it's possible.
Browser really limit JavaScript in its permissions for security reasons.
Maybe you can manually(in JavaScript of course) set the x and y position far outside of the screen so it appears on another screen but that's not a neat way to do it.
As far as I can think of, you have two options:
Create different pages for every screen and open them separately every time.
Create all the windows with a button and make the user drag them to the corresponding screen. When the user clicks the button open the window in full screen/kiosk mode and load the content. However I don't know what will happen if you activate another screen while your in fullscreenmode somewhere. It might invalidate and close the fullscreenmode.
This is the only way you can have distinct windows in your browsers as far as I know.

Is it viable to use actual browser windows for detached panels in a web application?

I'm planning an application and I'm wondering if it would be possible to use actual windows (window.open) for pop-out style panels as an alternative to using the "virtual" sort of windows made using absolutely positioned elements. This would have the advantage of being detachable from the browser window so that users could take advantage of the additional screen space provided by multiple monitors.
But I'm unsure how well it would work. Some points:
Would it be possible to keep the opened windows on top of the main application window, so that the detached panels wouldn't disappear behind the application itself
Would it even be possible to open multiple windows from the same application, or would automatic browser security perhaps limit you to one?
What about compatibility with the myriad of browser alternatives?
To summarize, would the advantage of additional screen space outweigh the disadvantages of using browser windows?
Do not use popup windows. They will usually be blocked. It is far easier to give the user a link and ask them (as if giving instructions) to right-click and open-in-new-window, than it is to do a popup and ask the user to manually unblock it. (Even that is bad practice.)
Would it be possible to keep the opened windows on top of the main application window, so that the detached panels wouldn't disappear behind the application itself
Probably not
Probably not.
Would it even be possible to open multiple windows from the same application, or would automatic browser security perhaps limit you to one?
window.open('http://www.google.com', 'win1'), window.open('http://www.google.com', 'win2')
What about compatibility with the myriad of browser alternatives?
Terrible, especially with popup-blockers, though it might work if your users only use one browser.
To summarize, would the advantage of additional screen space outweigh the disadvantages of using browser windows?
I do not think this is a summary of the previous question. Multiple monitors seems to be a useful but rare use-case. I do not know of a website which requires multiple monitors. If you are making some sort of "monitor" (like the security monitor kind) or information-display kind of software, it might be worthwhile, but other websites make do with just 1 window which can be as large or small as the user wants.
That said, it is possible to use popup windows. Gmail for example uses them to create chat windows, which you can later "pop back in". It is not a required feature however, and more than one can quickly get unwieldy.
I would strongly suggest you avoid window.open as many browsers and plugins will stop them. What you need are dialog boxes. See the following links for example of the jQuery UI one.
http://jqueryui.com/demos/dialog/
You can find many other solution online that works without or with other libraries.
You can have as much as you like and can virtually do anything you would do in another window the advantage is that is that it will be much easier to handle communication between the dialog box and the main page that it would be using popup windows.

Categories

Resources