Electron: How to minimize a window from a rendered process

守給你的承諾、 提交于 2019-12-03 08:15:45

You can call minimize() on the respective BrowserWindow instance. The question is how to best get access to this instance and this, in turn, depends on how you open the windows and where your minimize button is. From your example, I take it that the minimize button is actually in the window you want to close, in that case you can just minimize the focused window, because to when a user clicks the button inside it, the window should currently have the focus:

const { remote } = require('electron')
remote.BrowserWindow.getFocusedWindow().minimize();

Alternatively you can use BrowserWindow.fromId() to get access to the window in question if, for example, you want to minimize the task window from the other window.

In case you stumble upon this thread and are using electron vue you can use this.$electron.remote.BrowserWindow.getFocusedWindow().minimize(); from directly inside your renderer.

vboyko

This works for me:

const { remote } = require('electron')
remote.getCurrentWindow().minimize();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!