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

Notification

Icon
Error

Options
Go to last post Go to first unread
Act  
#1 Posted : Thursday, February 10, 2022 2:50:59 PM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
Hey Rob love the app!

I'm currently using my laptop and have set stroke button as left.

To initiate the gesture all I do is double tap then draw the gesture.

I've set it so strokesplus doesn't draw the gesture but I'd love it if you can go two steps further and hide (make cursor invisible)

once you initialise the gesture and also hide the cursor.

Sometimes I want to perform an action but not lose the position of the cursor where it is and this way my workflow isn't interrupted

by having to account for where the cursor would finish kinda like keeping strokesplus in the background.

This way I can perform as many gestures without having to worry if my cursor is at the edge of the screen.

Please could you consider this. THANKYOU <3
Act  
#2 Posted : Thursday, February 10, 2022 4:48:49 PM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
I also think this has uses, example

I need to perform a gesture on the exact spot I intitated the gesture but currently there is no way you (that I know of) that can accomplish this.

I use this gesture to left click and chose an option for a link on a site but I need the pointer to stay put, hope this helps thanks
Rob  
#3 Posted : Thursday, February 10, 2022 8:36:07 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)
Under Global Actions > Settings > After Action select Custom use:
Code:
sp.MouseMove(action.Start);

Within each application, go to Before/After Automation and select Inherit from Global Actions.

What this does is after an action is executed it would move the mouse back to where the gesture began.

I haven't tested this out, but it should work fine.

You can use these to hide/show the mouse cursor, but note that showing the mouse cursor simply tells Windows to reset all cursors to the default. So depending on your setup, it could have undesired results.
Code:
sp.HideMouseCursor();

sp.ShowMouseCursor();


Act  
#4 Posted : Thursday, February 10, 2022 9:21:46 PM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
I got so excited when the first command worked! it goes back to the original position but the rest of the code you posted, I'm not understanding where I put that.
I tried putting it in
add action -> script part

so In chrome I set up a gesture to open a new tab with

sp.HideMouseCursor();
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_T]);
sp.ShowMouseCursor();

But it didn't work and then I realised it will only get that command after the gesture is performed so then I tried adding

sp.HideMouseCursor();

in the before action (in global)
and the
sp.ShowMouseCursor();

in the after action (in global)

but still didn't work. It's almost perfect like I want it but please could you guide me more on where I put those codes
Rob  
#5 Posted : Thursday, February 10, 2022 10:56:24 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)
You'd have to have the hide call in the mouse down event (e.g. Global, mouse events, left click), then show after the mouse move call.

if(click.Down) {
//Hide cursor call here
}

Honestly, I wouldn't bother with it unless it's really important to you. It adds extra overhead to every single mouse click, etc.

On my phone so I can't give a better example, but can later.
Act  
#6 Posted : Friday, February 11, 2022 9:30:16 AM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
Yeah It's important so would love to get it working

I added

if(click.Down) {
sp.HideMouseCursor();
}

in Global, mouse events, left click

and

if(click.Up) {
sp.ShowMouseCursor();
}

In release part

this works almost perfectly except when I tap (instead of double tapping to initiate the stroke) on a link, it defines that as a click and will hide the cursor but it doesn't register the up event and the cursor is hidden all the time.
Only way I can get the cursor back is to perform a stroke so it can register click.up event. Any suggestions please

edit: I even ticked the "consume click event" but same result

Edited by user Friday, February 11, 2022 9:43:22 AM(UTC)  | Reason: Not specified

Act  
#7 Posted : Friday, February 11, 2022 10:09:28 AM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
I almost got it to work like I asked.

I added

if(click.Downp)
{
sp.HideMouseCursor();
}

in left click

and

if(click.Up)
{
sp.ShowMouseCursor();
}

in release, but when I tap on touchpad (as apposed to double tap to initiate the gesture) it hides the cursor but it won't unhide since it doesn't receive a click.up event from a (single) tap. So close, any suggestions please?


Rob  
#8 Posted : Saturday, February 12, 2022 3:16:12 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)
First of all, there is no click.Up, only click.Down - it is a boolean meaning true or false.

So you would look for the up event like this:
Code:
if(click.Down) {
    //mouse down
} else {
    //mouse up
}

Or:
Code:
// ! before a boolean means NOT, so is not down (up)
if(!click.Down) {
    //mouse up
}

Or:
Code:
// Test it more explicitly, easier to understand for non-programmers
if(click.Down == false) {
    //mouse up
}


The next question is: Where did you put your mouse up script?
Act  
#9 Posted : Saturday, February 12, 2022 10:07:13 AM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
I pasted this script in mouse events, left click

if(click.Down) {
sp.HideMouseCursor();
} else {
sp.ShowMouseCursor();
}

the script works when I perform a gesture.

I perform a gesture by double tapping my touchpad and then draw the gesture.

but if I single tap (which I need the touchpad for) it will hide the cursor. I have not performed a gesture just single tapped.

I can unhide it with performing an actual gesture after that point but I'd like to have the script work but let me able to use single tap. I'm sorry if I'm not clear but basically it's reading a single tap as click.down but I only want click.down with a double tap, just like a double tap is needed to perform a gesture but a single tap does not initiate the gesture :(
Rob  
#10 Posted : Saturday, February 12, 2022 12:48:21 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)
Okay, and Left button is your Stroke button?

If so, you'll need this in your Left Click script:
Code:
if(click.Down) {
    sp.HideMouseCursor();
}

And this in your Mouse Events > Release script:
Code:
if(click.Button == MouseButtons.Left && !click.Down) {
    sp.ShowMouseCursor();
}

Due to internal reasons, the click up/release event cannot be fired within the click scripts. So you have to use the Release tab for stroke buttons to handle the button up event.
Act  
#11 Posted : Saturday, February 12, 2022 1:55:23 PM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
It works! Thankyou so much
just one quirk that spoils it

1/if I perform a gesture but don't take my finger off the touchpad, the gesture will timeout and nothing will happen but the cursor remains hidden until I tap the screen again.

if it's too much trouble to find a solution I'll live with it. Thanks alot for creating this amazing software and your time and help!
Rob  
#12 Posted : Saturday, February 12, 2022 3:34:03 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)
You can create a timer as a fallback.

Left click:
Code:
if(click.Down) {
    sp.HideMouseCursor();

    // After 1 second (1000 milliseconds below), this will execute the show mouse cursor code
    // Increase/decrease 1000 as needed to find the right timing for you
    sp.CreateTimer("showMouse", 1000, -1, "sp.ShowMouseCursor();");
}

Release:
Code:
if(click.Button == MouseButtons.Left && !click.Down) {
    sp.DeleteTimer("showMouse"); //Delete the timer
    sp.ShowMouseCursor();
}
thanks 1 user thanked Rob for this useful post.
Act on 2/12/2022(UTC)
Act  
#13 Posted : Saturday, February 12, 2022 3:42:43 PM(UTC)
Act

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/10/2022(UTC)
Posts: 9
United Kingdom

Thanks: 1 times
works perfectly! TYSM for your help
Rob  
#14 Posted : Saturday, February 12, 2022 3:59: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)
....now that you have it all working within the normal UI, here's how to do it by using a mouse event binding BigGrin

An event binding ignores any of the normal logic S+ uses and simply invokes the function on every mouse button event.

Global Actions > Load/Unload > Load script:
Code:
// IMPORTANT: Make sure to check the Enable Mouse Hook Event Subscription
// checkbox under Options > Advanced

// Only create one binding in the last script engine
if(__spEngineWrapper.Engine.Name == sp.EngineList().Last().Engine.Name) {

    //Disconnect any previous event binding before creating the new one
    var mouseButtonEventObj = sp.GetStoredObject("mouseButtonEvent");
    if(mouseButtonEventObj.GetType().FullName.includes('EventConnection')) 
    {
        mouseButtonEventObj.disconnect();
        sp.DeleteStoredObject("mouseButtonEvent");
    } 

    // Create the event binding, bind to asynchronous mouse event
    var mouseButtonEvent = MouseHook.OnMouseHookButtonEventAsync.connect(
        function (sender, mouseHookEvent) {
            //Wrap all code in try/catch, exceptions will crash S+ in an event binding
            try {
                if(mouseHookEvent.Button == MouseButtons.Left)
                {
                    if(mouseHookEvent.ButtonState == ButtonState.Down) 
                    {
                        sp.HideMouseCursor();
                    }
                    else
                    {
                        sp.ShowMouseCursor();
                    }
                }
            }
            catch{}
        });
    //Note that on S+ reload, events in Stored Object list have disconnect called on them
    sp.StoreObject("mouseButtonEvent", mouseButtonEvent);
}
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.