chrisbing / electorn-capture-screen

electron capture screen
MIT License
225 stars 65 forks source link

从边缘点击开始截图无响应 #7

Open canvascat opened 5 years ago

canvascat commented 5 years ago

平台:win 问题:边缘5px内点任何事件都无法捕捉到,导致无法监听到开始截图的指令。这5px应该是边框,而且是在使用了透明窗口后才会有这个问题new BrowserWindow({ transparent: true, frame: false }),想寻求解决方案。

xieerduos commented 3 years ago

平台:win 问题:边缘5px内点任何事件都无法捕捉到,导致无法监听到开始截图的指令。这5px应该是边框,而且是在使用了透明窗口后才会有这个问题new BrowserWindow({ transparent: true, frame: false }),想寻求解决方案。

大兄弟, 我也遇到了这个问题,有方案了嘛

canvascat commented 3 years ago

@xieerduos I have given up on it, and use qt to develop this screenshots plugin now. of course, you can try iohook.

xieerduos commented 3 years ago

@xieerduos I have given up on it, and use qt to develop this screenshots plugin now. of course, you can try iohook.

I solved, Set transparent: false, opacity: 0.01 to achieve the purpose of background transparency

const captureWin = new BrowserWindow({
            x: display.bounds.x,
            y: display.bounds.y,
            width: display.bounds.width,
            height: display.bounds.height,
            // Solve the problem that the mouse click to the edge within 6px pixels does not respond to the click event
            transparent: false, 
            frame: false,
            show: true,
            opacity: 0.01,
            skipTaskbar: true,
            // autoHideMenuBar: true,
            movable: false,
            resizable: true, // Must be set, otherwise the window may not be full screen
            enableLargerThanScreen: true,
            hasShadow: false,
            fullscreen: true, // Must be set, otherwise the window may not be full screen
            fullscreenable: true,// Must be set, otherwise the window may not be full screen
            webPreferences: {
                nodeIntegration: true
            }
        });
canvascat commented 3 years ago

@xieerduos , and do you know how to solve the problem of not hiding the title bar when using Mac OS.

xieerduos commented 1 year ago

@xieerduos , and do you know how to solve the problem of not hiding the title bar when using Mac OS.


const { BrowserWindow } = require('electron')

function createWindow() { const mainWindow = new BrowserWindow({ width: 800, height: 600, titleBarStyle: 'hidden', // Hide the title bar, keep the window controls // frame: false, // Remove the entire window frame and title bar, uncomment to use webPreferences: { nodeIntegration: true } })

mainWindow.loadFile('index.html') }



Please note that titleBarStyle: 'hidden' is effective on macOS, but might not work on other platforms. To ensure cross-platform compatibility, you can add platform-specific code as needed.