Rank: Member
Groups: Approved
Joined: 6/11/2021(UTC) Posts: 24 Thanks: 6 times
|
Originally Posted by: Rob Put this script inside the Global Actions > Mouse Events > Left Click Script to allow Alt+Drag to move window (which is not maximized). FYI, the click event scripts do not interfere with input, so the Alt key down and release are still received by the window. Note, this only works starting with version 0.2.9.2, prior versions only executed the click scripts on mouse up. IMPORTANT: Do not use this (or any timer script, really) without having the Use Script Engine Pool option enabled and a pool size of at least two. I will likely be removing that option, so if I forget to update this post and you don't see the option, don't worry about it! Code:if(click.Down) {
if((sp.GetKeyState(vk.LMENU) & 0x8000) && !sp.GetStoredBool("MoveWindowActive")) {
if(!click.Window.Maximized) {
sp.StoreBool("MoveWindowActive", true);
sp.StoreHandle("MoveWindowHandle", click.Window.HWnd);
sp.StorePoint("MoveWindowMouseStart", sp.GetCurrentMousePoint());
sp.StorePoint("MoveWindowStart", click.Window.Location);
sp.CreateTimer("MoveWindow", 20, 10, String.raw`
var wnd = sp.WindowFromHandle(sp.GetStoredHandle("MoveWindowHandle"));
if(sp.GetKeyState(vk.ESCAPE) & 0x8000) {
wnd.Location = sp.GetStoredPoint("MoveWindowStart");
sp.DeleteTimer("MoveWindow");
}
var startMousePt = sp.GetStoredPoint("MoveWindowMouseStart");
var currMousePt = sp.GetCurrentMousePoint();
var currWinPt = wnd.Location;
if(sp.GetStoredBool("MoveWindowActive")) {
wnd.Location = new Point(currWinPt.X + currMousePt.X - startMousePt.X, currWinPt.Y + currMousePt.Y - startMousePt.Y);
}
sp.StorePoint("MoveWindowMouseStart", currMousePt);
`);
}
}
} else {
if(sp.GetStoredBool("MoveWindowActive"))
{
sp.DeleteStoredHandle("MoveWindowHandle");
sp.DeleteStoredBool("MoveWindowActive");
sp.DeleteTimer("MoveWindow");
sp.DeleteStoredPoint("MoveWindowMouseStart");
sp.DeleteStoredPoint("MoveWindowStart");
}
}
This is quite a nice solution and it works like intended on my Win 10. However, it still has 3 problems: - The mouse pointer moves faster than the window and sometimes ends up being very far from where it should be - this is most prominent when the window changes monitors.
- The left click is not consumed, so the window below the pointer responds. If I drag the explorer window, I must be extra cautious where I click because I might unintentionally copy some folder into another folder and not even know about it.
- The action requires an additional keypress, so the user has to use a keyboard with another hand. This raises a question whether it would be easier to just click on the title bar and move the window altogether.
I had a nice little script in the old StrokesPlus which you helped me to make to work. And it worked perfectly: Code:function dragWindow(wHandle)
acActivateWindow(wHandle, nil, nil)
acSetNumber(1)
local xDelta = acGetMouseLocationX() - acGetWindowLeft(wHandle, nil, nil)
local yDelta = acGetMouseLocationY() - acGetWindowTop(wHandle, nil, nil)
while (acGetNumber() == 1) do
acMoveWindow(wHandle, nil, nil, acGetMouseLocationX()-xDelta, acGetMouseLocationY()-yDelta)
acDelay(10)
end
end
dragWindow(acGetParentWindowByPoint(gsx, gsy))
It was activated with Stroke Button + Left Button and it would run as long as the left mouse button was held down. The click would not go through to window itself and the pointer always stayed in the same location relative to the window. Can at least problems 2. and 3. be solved some way in StrokesPlus.net? Edited by user Monday, June 14, 2021 11:54:45 AM(UTC)
| Reason: Not specified
|