Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 823  Location: Tampa, FL Thanks: 18 times Was thanked: 196 time(s) in 171 post(s)
|
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");
}
}
Edited by user Monday, September 9, 2019 8:34:50 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 93  Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Dear Rob,
This script doesn't work properly.
When I release the Alt key, the window still moves with the mouse. When I execute the script for the second or third time, the window will not be moved。
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 823  Location: Tampa, FL Thanks: 18 times Was thanked: 196 time(s) in 171 post(s)
|
Hmm, I just copied the script into my left click script and it works fine. Are you able to provide any additional details which might allow me to reproduce the issue? What other settings do you have, anything like having the Alt be as the ignore key, etc?
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 93  Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 823  Location: Tampa, FL Thanks: 18 times Was thanked: 196 time(s) in 171 post(s)
|
Okay, I was able to reproduce the issue.
Under Options > Advanced, check the Use Script Engine Pool checkbox and enter 2 for Max Script Pool Size. I use 3, but each engine take a little more memory and system resources, but at least two will ensure you can have multiple scripts able to quickly execute in parallel without trying to use an excessive amount of resources by creating a new one for each execution.
NOTE: You must close and restart S+ after saving that option.
I will look into whether this option should remain or if restrictions need to be applied.
Your config had that unchecked which means every single script execution is spinning up an entire new script engine, loading all of the objects/plug-ins, then executing the script.
The problem is, this script is using a timer which executes every 10 milliseconds. This causes a very large load on the system and is creating a lot of contention, with dozens of script engines being created in less than a half second. I opened Task Manager while doing the Alt+Drag (without the script engine pool checked) and you could see the memory growing very fast.
There is really no good reason to have that option unchecked. I like to give people options, so I wanted to have it available...but I'm thinking that it may not be a good idea. At a minimum, I should probably make it a hidden settings...but even then, it can create a bad user experience and I really think I remove it.
|
 1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 93  Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Well, you know, for users who don't have script engines, it always prompts "No script engine available; quit the script." Please try again. It really affects experience.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 823  Location: Tampa, FL Thanks: 18 times Was thanked: 196 time(s) in 171 post(s)
|
Increase your script lock attempts (can't remember exact name, not at the computer). It's a very brief delay between attempts, so you should use a high value. I have mine set to 500 and I only get that message if I'm trying to make it happen.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 93  Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
OK, you are right. Thanks a lot.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 4/23/2020(UTC) Posts: 41  Thanks: 5 times Was thanked: 1 time(s) in 1 post(s)
|
Does this script no longer work, Rob.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 823  Location: Tampa, FL Thanks: 18 times Was thanked: 196 time(s) in 171 post(s)
|
I just tried it and it worked fine for me. What is happening for you? What settings/options do you have configured that might interfere?
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 4/23/2020(UTC) Posts: 41  Thanks: 5 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: Rob  I just tried it and it worked fine for me. What is happening for you? What settings/options do you have configured that might interfere? It is ok on Win10, last time I tested it on Win7 that can not work, and now I have no problem, thank you replied to me.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close