mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-28 07:35:40 +00:00
feat: Scroll Stash, closes #18
This commit is contained in:
@@ -123,7 +123,7 @@ function getOffsetX (poePos: Rectangle): number {
|
||||
}
|
||||
}
|
||||
|
||||
function poeUserInterfaceWidth (windowHeight: number) {
|
||||
export function poeUserInterfaceWidth (windowHeight: number) {
|
||||
// sidebar is 370px at 800x600
|
||||
const ratio = 370 / 600
|
||||
return Math.round(windowHeight * ratio)
|
||||
|
||||
+26
-3
@@ -4,11 +4,11 @@ import ioHook from 'iohook'
|
||||
import { pollClipboard } from './PollClipboard'
|
||||
import { win } from './window'
|
||||
import { windowManager } from './window-manager'
|
||||
import { showWindow, lockWindow } from './positioning'
|
||||
import { showWindow, lockWindow, poeUserInterfaceWidth } from './positioning'
|
||||
|
||||
const KEY_CTRL = 29
|
||||
// const KEY_CTRL = 29
|
||||
// const KEY_ALT = 56
|
||||
const KEY_D = 32
|
||||
const KEY_ALT = 56
|
||||
const KEY_F5 = 63
|
||||
const POE_TITLE = 'Path of Exile'
|
||||
|
||||
@@ -66,6 +66,29 @@ export function setupShortcuts () {
|
||||
robotjs.keyTap('key_c')
|
||||
})
|
||||
|
||||
let naiveInventoryCheckX: number | undefined
|
||||
ioHook.on('mousewheel', async (e: { ctrlKey?: true, x: number, rotation: 1 | -1 }) => {
|
||||
if (!e.ctrlKey) return
|
||||
if (naiveInventoryCheckX === undefined) {
|
||||
if (await windowManager.getActiveWindowTitle() !== POE_TITLE) {
|
||||
return
|
||||
} else {
|
||||
// NOTE: will not be updated if window moved
|
||||
const poePos = await windowManager.getActiveWindowContentBounds()
|
||||
naiveInventoryCheckX = (poePos!.x + poePos!.width) - poeUserInterfaceWidth(poePos!.height)
|
||||
}
|
||||
}
|
||||
|
||||
const mouseX = (process.platform === 'linux') ? screen.getCursorScreenPoint().x : e.x
|
||||
if (mouseX > naiveInventoryCheckX) {
|
||||
if (e.rotation > 0) {
|
||||
robotjs.keyTap('right')
|
||||
} else if (e.rotation < 0) {
|
||||
robotjs.keyTap('left')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
ioHook.registerShortcut([KEY_F5], () => { /* ignore keydown */ }, async () => {
|
||||
const title = await windowManager.getActiveWindowTitle()
|
||||
if (title === POE_TITLE) {
|
||||
|
||||
Reference in New Issue
Block a user