123
This commit is contained in:
22
main.js
22
main.js
@@ -3,7 +3,7 @@ const { app, BrowserWindow, Tray, Menu, nativeImage, dialog, ipcMain } = require
|
||||
const path = require('path');
|
||||
const io = require('socket.io-client');
|
||||
const { desktopCapturer } = require('electron');
|
||||
|
||||
const { mouse, Point, straightTo, keyboard, Key, clipboard } = require('@nut-tree-fork/nut-js')
|
||||
// 고유 직원 ID
|
||||
const EMPLOYEE_ID = "psn14020";
|
||||
|
||||
@@ -28,8 +28,10 @@ function createHiddenWindow() {
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
win.webContents.openDevTools();
|
||||
win.loadFile('index.html');
|
||||
return win;
|
||||
}
|
||||
@@ -136,27 +138,21 @@ async function setupWebRTCConnection(offer, requestedDisplayId) {
|
||||
// 🖱️ 입력 이벤트 처리 (robotjs 필요)
|
||||
function setupInputHandler() {
|
||||
// robotjs는 별도 설치 및 권한 필요
|
||||
let robot;
|
||||
try {
|
||||
robot = require('robotjs');
|
||||
} catch (e) {
|
||||
console.warn('robotjs 미설치 또는 로드 실패. 입력 제어 불가.');
|
||||
return;
|
||||
}
|
||||
|
||||
socket.on('inputEvent', ({ type, ...data }) => {
|
||||
socket.on('inputEvent', async({ type, ...data }) => {
|
||||
try {
|
||||
if (type === 'mouse') {
|
||||
const { x, y, action } = data;
|
||||
robot.moveMouse(Math.round(x), Math.round(y));
|
||||
const targetPoint = new Point(x, y)
|
||||
await mouse.move(straightTo(targetPoint));
|
||||
if (action === 'click') {
|
||||
robot.mouseClick();
|
||||
await mouse.leftClick();
|
||||
}
|
||||
} else if (type === 'keyboard') {
|
||||
const { key } = data;
|
||||
// 간단한 키 매핑 (보안상 복잡한 키는 제한 권장)
|
||||
if (key.length === 1 || ['Enter', 'Backspace', 'Tab', 'Escape'].includes(key)) {
|
||||
robot.keyTap(key.toLowerCase());
|
||||
await keyboard.pressKey(key.toLowerCase());
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user