Open gaabora opened 4 years ago
Hello!
For 1., are you getting any errors in the logs starting with “Error: Could not get accessibility element at position”. This is a native macOS API, so it might be that the apps have a broken accessibility integration.
For 2., what do you mean by the previous position? You could store the position in a variable. Currently you have the variable within the function scope so you can hoist the variable outside of the function to be able to store it across event callbacks. Or if you need to store the values across system boots you could use the Storage feature.
var lastPos = Mouse.location();
var mouseDidMove_lastPos = new Event('mouseDidMove', function (event) {
lastPos = Mouse.location();
});
var mouseDidLeftDrag_winMove = new Event('mouseDidLeftDrag', function (event) {
if (_.includes(event.modifiers, 'shift')) {
let currPos = Mouse.location();
const window = Window.at(currPos);
if (window != undefined) {
let winPos = window.topLeft();
const diff = {
x: lastPos.x - winPos.x,
y: lastPos.y - winPos.y
};
const newPos = {
x: currPos.x - diff.x,
y: currPos.y - diff.y
};
window.setTopLeft(newPos)
}
lastPos = Mouse.location();
}
});
var mouseDidRightDrag_winSize = new Event('mouseDidRightDrag', function (event) {
if (_.includes(event.modifiers, 'shift')) {
let currPos = Mouse.location();
const window = Window.at(currPos);
if (window != undefined) {
let winSize = window.size();
const diff = {
x: lastPos.x - currPos.x,
y: lastPos.y - currPos.y
};
const newSize = {
width: winSize.width - diff.x,
height: winSize.height - diff.y
};
window.setSize(newSize)
}
lastPos = Mouse.location();
}
});
Hello. I want to make a script for moving and sizing windows with a mouse over any window's area with some modificator key pressed (this behaviour you can set up eazily in KDE)
I've got two issues:
Thanks!
My code is: