StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Rob  
#1 Posted : Friday, June 10, 2022 2:16:43 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
(from a Discord user request, putting here for reference)

This script will allow you to toggle the Windows Mouse ClickLock feature on/off.

In your Global Actions > Load/Unload > Load tab, add this script:
Code:
if(!NativeModules.MouseClickLock)
{
    var Int32T = host.typeOf(System.Int32);
    var UInt32T = host.typeOf(System.UInt32);
    var BooleanT = host.typeOf(System.Boolean);
    var BooleanT_ref = host.typeOf(System.Boolean).MakeByRefType();
    
    var mouseClickLockTB = sp.NativeModule().DefineType(
        "MouseClickLock", 
        "Class,Public,SequentialLayout,Serializable"
    );

    mouseClickLockTB.DefinePInvokeMethod(
        "SystemParametersInfo",
        "user32.dll",
        [UInt32T,UInt32T,BooleanT_ref,UInt32T], 
        Int32T, 
        "PreserveSig"
    );

    mouseClickLockTB.DefinePInvokeMethod(
        "SystemParametersInfo",
        "user32.dll",
        [UInt32T,UInt32T,BooleanT,UInt32T], 
        Int32T, 
        "PreserveSig"
    );

    mouseClickLockTB.Create();
}

function ToggleClickLock() {
    var SPI_GETMOUSECLICKLOCK = 0x101E;
    var SPI_SETMOUSECLICKLOCK = 0x101F;
    var SPIF_SENDCHANGE = 0x0002;
    var mouseClickLocked = host.newVar(System.Boolean);
    NativeModules.MouseClickLock.SystemParametersInfo(SPI_GETMOUSECLICKLOCK, 0, mouseClickLocked.ref, SPIF_SENDCHANGE);
    NativeModules.MouseClickLock.SystemParametersInfo(SPI_SETMOUSECLICKLOCK, 0, !mouseClickLocked.value, SPIF_SENDCHANGE);
}

Then just call this wherever you want to toggle ClickLock on/off:
Code:
ToggleClickLock();
thanks 1 user thanked Rob for this useful post.
randomConstant on 6/13/2022(UTC)
randomConstant  
#2 Posted : Sunday, June 12, 2022 5:23:56 PM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
Cool.

At first I did not understand what it really does but after testing I think it works as follow.
  1. Press the mouse key down
  2. Before un-pressing the key, toggle the mouse click lock
  3. Now, after un-pressing the key, it still keeps the key_pressed status until the key is pressed again manually

Please correct me if I'm still misunderstanding it.
Rob  
#3 Posted : Monday, June 13, 2022 12:23:14 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
ClickLock is a feature in the Mouse settings Control Panel applet.

When it's enabled, if you click and hold (time based on setting in that section) and release, the mouse button stays held until you click again.
randomConstant  
#4 Posted : Monday, June 13, 2022 7:29:17 AM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
So that's why my mouse was acting weird yesterday. I did not know about this feature Laugh

Thanks for clarification Rob
bossl  
#5 Posted : Tuesday, January 10, 2023 2:04:08 PM(UTC)
bossl

Rank: Newbie

Reputation:

Groups: Approved
Joined: 1/8/2023(UTC)
Posts: 5
Germany
Location: Germany

Thats awesome !
with one stroke , i just activate window-move-mode and lock it
Users browsing this topic
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.