This commit is contained in:
bangae1
2025-10-20 18:57:24 +09:00
parent 24bedfd325
commit 12d6e29d90
5 changed files with 26 additions and 1777 deletions

22
main.js
View File

@@ -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) {