Skip to content

Commit

Permalink
fix #20
Browse files Browse the repository at this point in the history
  • Loading branch information
SnosMe committed Jan 19, 2020
1 parent 890dbdd commit 1e3fb45
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/shortcuts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen, Point } from 'electron'
import { screen, Point, clipboard } from 'electron'
import robotjs from 'robotjs'
import ioHook from 'iohook'
import { pollClipboard } from './PollClipboard'
Expand Down Expand Up @@ -54,12 +54,19 @@ export function setupShortcuts () {
}

function typeChatCommand (command: string) {
const saved = clipboard.readText()

clipboard.writeText(command)
robotjs.keyTap('enter')
robotjs.typeString(command)
robotjs.keyTap('key_v', ['control'])
robotjs.keyTap('enter')
// restore the last chat
robotjs.keyTap('enter')
robotjs.keyTap('up')
robotjs.keyTap('up')
robotjs.keyTap('escape')

setTimeout(() => {
clipboard.writeText(saved)
}, 100)
}

0 comments on commit 1e3fb45

Please sign in to comment.