Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Simulación de pulsaciones de teclas fuera de la ventana en Electron

Estoy buscando referencias sobre cómo lograr presionar teclas fuera de la ventana de Electron (incluso cuando la ventana está minimizada). Similar a AutoHotKey. Estaba usando python para lograr esto (usando pynput) pero quería cambiar a Electron por su facilidad para crear UI. Hasta ahora he intentado algo como esto:

 window.addEventListener('keydown', (e) => { console.log(e) }) window.dispatchEvent(new KeyboardEvent('keydown', { key: "e", keyCode: 69, code: "KeyE", which: 69, shiftKey: false, ctrlKey: false, metaKey: true }));

Aunque estoy escuchando las claves correctamente, esto no parece funcionar como me gustaría. Agradecería recomendaciones para cualquier lectura adicional, tutoriales, etc.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En lugar de tratar de escuchar las pulsaciones de teclas en el subproceso de procesamiento, use el subproceso principal en su lugar.

Consulte GlobalShortcut de Electron para obtener más información.

Para obtener una lista de las combinaciones de atajos disponibles, consulte Acelerador .

Esta funcionalidad funcionará incluso si la ventana está minimizada.

main.js (hilo principal)

 const electronApp = require('electron').app const electronGlobalShortcut = require('electron').globalShortcut let window = null; electronApp.on('ready', () => { // Create a window. window = new electronBrowserWindow ({ ... }); // Load the window. window.loadFile('./index.html') // Register your global shortcut(s). electronGlobalShortcut.register('Alt+J', shortcutPressed(); ) // Prove it works. function shortcutPressed() { console.log('Alt+J was pressed.'); } }) app.on('will-quit', () => { // Don't forget to unregister your global shortcut(s). globalShortcut.unregister('Alt+J') })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!