Rank: Member
Groups: Approved
Joined: 12/2/2019(UTC) Posts: 20
Thanks: 2 times
|
Hi
How do I set up a hotkey that would execute only when the mouse pointer is inside a particular area (right side of the screen)?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
This works okay for me. Code:// Get the location of the mouse cursor
var mouseLoc = sp.GetCurrentMousePoint();
// Get the rectangle of the screen where mouse is located
var mouseScreenRect = Screen.FromPoint(mouseLoc).Bounds;
// Divide the width of the screen in half and add the result to the Left starting location of the screen
// to define the center of the screen. parseInt ensures only whole numbers are used
var screenCenter = parseInt(mouseScreenRect.Left + (mouseScreenRect.Width / 2));
// If the mouse's X location is at or to the right of the screen's center, then show message
if(mouseLoc.X >= screenCenter) {
sp.MessageBox("Right Side of screen", "Hotkey");
}
Edited by user Wednesday, February 17, 2021 2:59:45 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Another method using regions. This would be easier to work with if you wanted to divide the screen into a grid and do different things in different cells. This example only creates a 1 Row, 2 Column region - but you could do 3 x 3 for example Code:// Get location of mouse cursor
var mouseLoc = sp.GetCurrentMousePoint();
// Get region the mouse cursor is in, based on the screen rectangle,
// using 2 columns and 1 row to split the screen rectangle into
var columns = 2;
var rows = 1;
var region = sp.GetRegionFromPoint(Screen.FromPoint(mouseLoc).Bounds, mouseLoc, columns, rows);
// If mouse is in Column 2 (right half) and Row 1 (only 1 row possible, but to demonstrate)
// Show message
if(region.Column === 2 && region.Row === 1) {
sp.MessageBox("Right Side of screen", "Hotkey");
}
Edited by user Wednesday, February 17, 2021 3:20:05 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Approved
Joined: 12/2/2019(UTC) Posts: 20
Thanks: 2 times
|
Works perfectly, thank you!
|
|
|
|
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