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, July 19, 2019 6:04:07 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 261
United States

Thanks: 5 times
Was thanked: 53 time(s) in 45 post(s)
This script is a timer that polls every 200 milliseconds to check the mouse's location and if it's in the lower right corner of the screen where the mouse resides, shows a message box:
Code:
sp.CreateTimer("CornerCheck", 0, 200, `if(!sp.GetStoredBool("CornerCheckActive")) { 
                                              sp.StoreBool("CornerCheckActive", true);
                                              var mousePos = sp.GetCurrentMousePoint();
                                              var mouseScreen = Screen.FromPoint(mousePos);
                                              if(mousePos.X == mouseScreen.Bounds.Right - 1 && mousePos.Y == mouseScreen.Bounds.Bottom - 1) {
                                                  //Put your code here
                                                  sp.MessageBox("In lower right corner!", "Hi");
                                              }
                                              sp.StoreBool("CornerCheckActive", false);
                                        }`); 

Note that for the Right and Bottom screen properties, you need to subtract 1 pixel since the mouse cursor cannot reside along those edges.

This script is the same, but for the upper left corner:
Code:
sp.CreateTimer("CornerCheck", 0, 200, `if(!sp.GetStoredBool("CornerCheckActive")) { 
                                               sp.StoreBool("CornerCheckActive", true);
                                               var mousePos = sp.GetCurrentMousePoint();
                                               var mouseScreen = Screen.FromPoint(mousePos);
                                               if(mousePos.X == mouseScreen.Bounds.Left && mousePos.Y == mouseScreen.Bounds.Top) {
                                                   //Put your code here
                                                   sp.MessageBox("In upper left corner!", "Hi");
                                               }
                                               sp.StoreBool("CornerCheckActive", false);
                                        }`); 

The CornerCheckActive bool is just to prevent multiple/continued execution when the mouse is in the location, until the script finishes that is. You could also store the current location and if hasn't left the corner, to not execute again until the mousePos has changed then came back to the corner, for example.

You could either start this script manually via an action, or add it to your Global Actions > Load/Unload Scripts > Load Script so it starts when S+.net starts.

Edited by user Friday, July 19, 2019 6:06:42 AM(UTC)  | Reason: Not specified

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.