Search code examples
electronuac

Electron load failed when set uiAccess true


I want to use electron to develop an app to show above lock screen. I need to set my window alwaysOnTop and set the uiAccess of the exe as true. The exe can load index.html successfully without uiAccess change, but when I change the uiAccess to true, the exe can only create a window but the window is blank, sometimes it's white while sometimes it's black. I tried to log some event and found that the crashed event was triggered if I open the exe with non-Administrator. If I open the exe with administrator, the 'did-finish-load' was triggered but the window is black, didn't show my index.html. How can I fix this?


Solution

  • I found that the cause is the parameter of setAlwaysOnTop. The type for windows should be "normal". After change to mainWindow.setAlwaysOnTop(true, 'normal');, it works well.