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 : Sunday, November 10, 2019 6:48:22 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
UPDATE

Starting with version 0.3.5.3, these zones can now be managed via Options > Exclusion Zones.



-- ORIGINAL POST, STILL TECHNICALLY CORRECT - ADDED NEW .Description TO SCRIPTS --

Starting with version 0.3.5.1, you can define mouse hook exclusion zones, which allow you to selectively instruct StrokesPlus.net to not react in certain areas of the screen(s).

This addition stemmed from a request regarding mouse wheel scripts, but supports more than just that. For example, mouse wheel scripts are great, but can have poor performance due to a script having to execute for each mouse wheel tick. This can result in noticeably slower scrolling or still scrolling after you've stopped (since the scripts are still queued up for execution).

This new functionality will allow you to define areas of the screen where S+.net doesn't react to certain mouse events. For example, you can exclude the center area of the screen from mouse wheel events so they respond the same as if S+.net wasn't running, but if the mouse is along the edges of the screen, the Mouse Wheel Script will be executed.

However, you can also define exclusion zones for just the primary stroke button, or secondary stroke button. For example, instead of creating an ignored app for the Windows Taskbar (and any other docked toolbar), you could simply create an exclusion zone for that area using Screen.WorkingArea. Note that you wouldn't simply use the .WorkingArea rectangle as that would exclude the main area of the screen, you would need to create one or more exclusion zones to represent the rectangle(s) at the edges of the screen. See below for an example of creating an exclusion zone around the edges of the working area.

You can have as many exclusion zones as you want - in the future, I will create a user interface area to manage these.

The Screen class documentation is here: Screen Class

The Rectangle constructor documentation is here: Rectangle(Int32, Int32, Int32, Int32)
Code:
//MouseExclusionZone class definition
public class MouseExclusionZone
{
    public string Description { get; set; }
    public bool Relative { get; set; }
    public bool ScaleTop { get; set; }
    public bool ScaleLeft { get; set; }
    public bool FixedRightBorder { get; set; }
    public bool FixedBottomBorder { get; set; }
    public bool ScaleWidth { get; set; }
    public bool ScaleHeight { get; set; }
    public Rectangle Rectangle { get; set; }
    public bool HorizontalMouseWheelScroll  { get; set; }
    public bool VerticalMouseWheelScroll  { get; set; }
    public bool PrimaryStrokeButton  { get; set; }
    public bool SecondaryStrokeButton { get; set; }
    public bool Active { get; set; }
    public Rectangle GetRelativeRectangle(Rectangle originalBoundingRect, Rectangle currentBoundingRect, Rectangle sourceRect)
}


This script will define this exclusion zone for all screens on the system, basically leaving a 20 pixel area along the working area edges of the screen. Note that screen working area excludes the taskbar or other docked areas. You can use .Bounds instead of .WorkingArea for the absolute edges of the screen(s).
Code:
//This clears all exclusion zones - it is not necessary to call
//Just make sure you're not unintentionally adding multiple extra 
//exclusion zones which you're testing this script.
sp_config.MouseHookExclusionZones.Clear();

//Get all screens
var allScreens = Screen.AllScreens;

//Loop through all screens, setting the exclusion area
for(var i = 0; i < allScreens.Length; i++) {
    
    //Get the working area rectangle of the screen
    var rect = allScreens[i].WorkingArea;

    //Exclude all but the screen edges, for a mouse wheel script to not 
    //execute in the main area of the screen
    //This only affects mouse wheel scroll events, does not exclude stroke button events
    var exclZoneCenter = new MouseHookExclusionZone();
    exclZoneCenter.Description = "Center";
    exclZoneCenter.Rectangle = new Rectangle(rect.Left + 20, rect.Top + 20, rect.Width - 40, rect.Height - 40);

    //This exclusion area only affects mouse wheel scroll events, not the stroke buttons
    exclZoneCenter.HorizontalMouseWheelScroll = true;
    exclZoneCenter.VerticalMouseWheelScroll = true;

    //Do not exclude stroke button click events
    exclZoneCenter.PrimaryStrokeButton = false;
    exclZoneCenter.SecondaryStrokeButton = false;

    exclZoneCenter.Active = true;
    //Add the exclusion zone to S+ settings
    sp_config.MouseHookExclusionZones.Add(exclZoneCenter);

}

//Save S+.net settings
sp_config.Save();


This script creates 4 exclusion zones for each screen, to exclude along each edge of the working area; only affects stroke button events, not mouse wheel scroll events:

Code:
//This clears all exclusion zones - it is not necessary to call
//Just make sure you're not unintentionally adding multiple extra 
//exclusion zones which you're testing this script.
sp_config.MouseHookExclusionZones.Clear();

//Get all screens
var allScreens = Screen.AllScreens;

//Loop through all screens, setting the exclusion area
for(var i = 0; i < allScreens.Length; i++) {

    //Get the working area rectangle of the screen
    var rect = allScreens[i].WorkingArea;

    //Left side
    var exclZoneLeft = new MouseHookExclusionZone();
    exclZoneLeft.Description = "Left";
    exclZoneLeft.Rectangle = new Rectangle(rect.Left, rect.Top, 20, rect.Height);

    //Don't exclude for mouse wheel scroll events
    exclZoneLeft.HorizontalMouseWheelScroll = false;
    exclZoneLeft.VerticalMouseWheelScroll = false;

    //This exclusion only affects stroke buttons, not mouse wheel scroll events
    exclZoneLeft.PrimaryStrokeButton = true;
    exclZoneLeft.SecondaryStrokeButton = true;

    exclZoneLeft.Active = true;
    //Add the exclusion zone to S+ settings
    sp_config.MouseHookExclusionZones.Add(exclZoneLeft);

    //Right side
    var exclZoneRight = new MouseHookExclusionZone();
    exclZoneRight.Description = "Right";
    exclZoneRight.Rectangle = new Rectangle(rect.Right - 20, rect.Top, 20, rect.Height);
    
    //Don't exclude for mouse wheel scroll events
    exclZoneRight.HorizontalMouseWheelScroll = false;
    exclZoneRight.VerticalMouseWheelScroll = false;

    //This exclusion only affects stroke buttons, not mouse wheel scroll events
    exclZoneRight.PrimaryStrokeButton = true;
    exclZoneRight.SecondaryStrokeButton = true;

    exclZoneRight.Active = true;
    //Add the exclusion zone to S+ settings
    sp_config.MouseHookExclusionZones.Add(exclZoneRight);

    //Along top
    var exclZoneTop = new MouseHookExclusionZone();
    exclZoneTop.Description = "Top";
    exclZoneTop.Rectangle = new Rectangle(rect.Left, rect.Top, rect.Width, 20);

    //Don't exclude for mouse wheel scroll events
    exclZoneTop.HorizontalMouseWheelScroll = false;
    exclZoneTop.VerticalMouseWheelScroll = false;

    //This exclusion only affects stroke buttons, not mouse wheel scroll events
    exclZoneTop.PrimaryStrokeButton = true;
    exclZoneTop.SecondaryStrokeButton = true;

    exclZoneTop.Active = true;
    //Add the exclusion zone to S+ settings
    sp_config.MouseHookExclusionZones.Add(exclZoneTop);

    //Along bottom
    var exclZoneBottom = new MouseHookExclusionZone();
    exclZoneBottom.Description = "Bottom";
    exclZoneBottom.Rectangle = new Rectangle(rect.Left, rect.Bottom - 20, rect.Width, 20);
  
    //Don't exclude for mouse wheel scroll events
    exclZoneBottom.HorizontalMouseWheelScroll = false;
    exclZoneBottom.VerticalMouseWheelScroll = false;

    //This exclusion only affects stroke buttons, not mouse wheel scroll events
    exclZoneBottom.PrimaryStrokeButton = true;
    exclZoneBottom.SecondaryStrokeButton = true;

    exclZoneBottom.Active = true;
    //Add the exclusion zone to S+ settings
    sp_config.MouseHookExclusionZones.Add(exclZoneBottom);
}

//Save S+.net settings
sp_config.Save();

Edited by user Monday, November 18, 2019 8:09:29 PM(UTC)  | Reason: Updated for 0.3.5.6

thanks 1 user thanked Rob for this useful post.
liuchina on 11/19/2019(UTC)
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.