Is there a way in Electron to resize non-electron windows?

If a user has my electron app’s window open, I would like a way to prevent other (nonelectron) windows, such as an internet browser window, from overlapping with the electron window.

This is a little different than the alwaysOnTop option. With that option, if the electron window is open and the user opens another window, the electron window stays on top of the other window, but that window appears “behind” the electron window.

I would like instead to keep the two windows separate. For example, having the other window open to the side of the electron window or below it. This would likely require that the other non-electron window be resized to only take up half of the screen.

Is there a way to do this? I am considering if there is a straightforward Electron option or if not if there is a creative way to approach the issue.


I’m looking forward for similar thing. But not just managing windows but complete control over the OS via OS level APIs. If there is nor support yet I’m gonna have to code some so you maybe can get use of it.
I however hope there is a way to do that because it would save some time. :slight_smile:

Thanks. I will let you know if I find anything useful. In looking into this, I have seen some mention of resizing windows using Apple Script and alternatively the Accessibility API. For example, here is a stack overflow: . But I am not sure those would be the way to go for my needs at least. I am not familiar with accessing those through electron/node apps, and these would likely be specific to macs.

Basically, in my case I would just need some way of moving windows over by a certain amount. Say my electron browser window sits on the left of the screen and is 200px wide. I just need some way of ensuring that new nonelectron windows are shifted 200px to the right. A bit like how windows always open below the menubar on a mac or above the menu bar on Windows.

I appreciate any ideas on this.

I got the idea. I think there is no such lib so far. Apple Script is for Mac only, yes. It won’t help you on Windows.
I however decided to code a “bridge” between JS and Windows OS level API calls (and Mac later) on Assembler.
I need that for my project too and also in way more wide variety of possibilities. I basically need complete control over the OS via the Electron so I will make it as generic as possible.

In your case I don’t know why but I feel like there is a workaround so you won’t need to dig in too deep like me.
I however found something that is very close to what you are looking for, yet nothing to help you with rearranging the windows…

If I come up with something I will reply to you.
Good luck!

Thank you, I appreciate it. I agree there seems like there would be a workaround for this, and I will consider.

did you ever figure anything out for this? thanks :slight_smile:

Two approaches I see:

  1. You can work with the macOS Carbon APIs by building a native Node.js addon but it will require compilation which can be complex with Electron.


  1. Use Apple’s Open Scripting Architecture which is essentially AppleScript in JavaScript. You can call Objective-C code in JavaScript which should make it really easy to build a quick and dirty proof-of-concept. The ObjC code would make use of the Accessibility API.