Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
break;
}
}
} catch (e) {
console.log(e);
sendMsg('Error', e);
}
}
}
});
// Register and start hook
ioHook.start();
// Alternatively, pass true to start in DEBUG mode.
ioHook.start(true);
// if altgr is disabled do not show dock...
if (disableKeyUpListen && event.rawcode != 164) {
if (disableKeyUpListenTimeout) clearTimeout(disableKeyUpListenTimeout);
disableKeyUpListenTimeout = setTimeout(() => {
clearTimeout(disableKeyUpListenTimeout)
disableKeyUpListen = false;
}, 1000);
return;
};
fnMethod(event);
});
/**
* Fires on user's keydown
*/
ioHook.on('keydown', event => {
if (event.altKey) {
// If alt key is pressed, show dock
// if altgr is disabled do not show...
if (config.disableAltGr && event.rawcode == 165) {
disableKeyUpListen = true;
return;
}
interChannel.sendShowClient();
}
});
}
if (process.platform == "darwin") {
// MacOS switching strategy ...
* @param {} event
*/
function fnMethod(event) {
// if altgr is disabled do not switch...
if (event.altKey) {
react(event);
}
}
if (process.platform == 'win32') {
/**
* Fires on user's keyup
*/
ioHook.on('keyup', event => {
// if altgr is disabled do not show dock...
if (disableKeyUpListen && event.rawcode != 164) {
if (disableKeyUpListenTimeout) clearTimeout(disableKeyUpListenTimeout);
disableKeyUpListenTimeout = setTimeout(() => {
clearTimeout(disableKeyUpListenTimeout)
disableKeyUpListen = false;
}, 1000);
return;
};
fnMethod(event);
});
/**
* Fires on user's keydown
*/
ioHook.on('keydown', event => {
{
notifier.notify(
{
title: 'Switch - '+title,
message: message,
// icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
});
notifier.on('click', function(notifierObject, options, event) {
// Triggers if `wait: true` and user clicks notification
});
}
ioHook.on('keyup', event => {
// 1. When use holds the alt key
if (event.altKey) {
// 2. Find the app with the registered keycode that match the keycode the user just press
let whichHotWindowToOpen = hotSwitches.filter(hot => hot.keycode == event.keycode);
// 3. If found:
if (whichHotWindowToOpen.length > 0) {
// 4. We only use the first match
whichHotWindowToOpen = whichHotWindowToOpen[0];
try {
// 5. Get all windows that matches the app title
let windows = windowManager.getWindows().filter(window => window.getTitle().includes(whichHotWindowToOpen.name));
// 6. If none is found exit the function
if (windows == null || windows.length == 0) {
sendMsg('Yikes 🤔', `Ops! It seems like ${whichHotWindowToOpen.name} is yet opened. Click to launch app! 🚀`);
return;
}
Date.now() - this.lastDown > 100 &&
Math.abs(this.newX - this.lastX) + Math.abs(this.newY - this.lastY) > 10
) {
simulate.copy();
this.copied = true;
}
});
ioHook.on("mousedown", (event: MouseEvent) => {
this.lastDown = Date.now();
this.lastX = event.x;
this.lastY = event.y;
this.copied = false;
});
ioHook.on("mousedrag", (event: MouseEvent) => {
this.drag = true;
this.newX = event.x;
this.newY = event.y;
});
//注册的指令。send到主进程main.js中。
// Register and start hook
ioHook.start(false);
}
}
return
if (!room) {
const Room = require('@living-room/client-js')
room = new Room()
}
let start = new Date()
const ioHook = require('iohook')
// TODO: get window size programattically, and listen to screen size changes
const windowSize = { width: 1920, height: 1080 }
const lastMousePositions = []
ioHook.on('mousemove', event => {
if (new Date() - start < 16) return
start = new Date()
const x = event.x / windowSize.width
const y = event.y / windowSize.height
lastMousePositions.unshift({ x, y })
if (lastMousePositions.length > 9) lastMousePositions.pop()
const alphabet = 'abcdefghijklmnopqrstuvwxyz'
for (let [i, pos] of lastMousePositions.entries()) {
const b = 255 - i * 10
const r = 30 - i * 2
const l = alphabet[i]
const fact = `mouse${l} is a (${b}, ${b}, ${b}) circle at (${pos.x}, ${
let x_now = event.x;
let y_now = event.y;
let dx = x_now - x;
let dy = y_now - y;
x = x_now;
y = y_now;
let bounds = focusWin.getBounds();
bounds.x += dx;
bounds.y += dy;
focusWin.setBounds(bounds);
}
});
//注册的指令。send到主进程main.js中。
// Register and start hook
ioHook.start(false);
};
}
// When user tabs Comand+Options
ioHook.registerShortcut([3676, 3640], () => {
interChannel.sendShowClient();
});
ioHook.registerShortcut([3675, 56], () => {
interChannel.sendShowClient();
});
}
// Register and start hook.
(checkDevMode()) ? ioHook.start(true) : ioHook.start();
// Registers the on toast click event handler.
registerNotifierOnClick();
/**
* Fires when hot apps list
* update is recieved from client
*/
interChannel.emitter.on('update-hot-apps', (happs) => {
hotapps = happs;
log(Switch.LOG_INFO, 'Hot apps update received', hotapps);
saveHotApps(happs);
});
/**
* Fires when config
ioHook.on("mousedown", (event: MouseEvent) => {
this.lastDown = Date.now();
this.lastX = event.x;
this.lastY = event.y;
this.copied = false;
});
ioHook.on("mousedrag", (event: MouseEvent) => {
this.drag = true;
this.newX = event.x;
this.newY = event.y;
});
//注册的指令。send到主进程main.js中。
// Register and start hook
ioHook.start(false);
}
}
initializeHotkeys() {
var self = this;
// Register CTRL + C hotkey
const clipboardShortcut = ioHook.registerShortcut([29, 46], (keys) => {
if(config.get("pricecheck") && this.poeFocused) {
// Waiting 100ms before calling the processing method, because the clipboard needs some time to be updated
var timeout = setTimeout(function() {
Pricecheck.getPrice(clipboardy.readSync());
}, 100);
}
});
ioHook.start();
}