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)
|
Sure, you can use the gesture start and end: Code:var columns = 6;
var rows = 6;
var startRegion = sp.GetRegionFromPoint(action.Window.Rectangle, action.Start, columns, rows);
var endRegion = sp.GetRegionFromPoint(action.Window.Rectangle, action.End, columns, rows);
if((startRegion.Column == 1 && endRegion.Column != 6 && endRegion.Row != 6) || startRegion.Column == 2) {
sp.MessageBox(`Match!\r\nColumn 1 or 2, any Row\r\n\Start Region: Column: ${startRegion.Column} - Row: ${startRegion.Row}`, "Match");
} else if (startRegion.Column == 4 && startRegion.Row == 3) {
sp.MessageBox(`Match!\r\nColumn 4, Row 3\r\n\Start Region: Column: ${startRegion.Column} - Row: ${startRegion.Row}`, "Match");
} else if (startRegion.Column == 6 && (startRegion.Row == 5 || startRegion.Row == 6)) {
sp.MessageBox(`Match!\r\nColumn 6, Row 5 or Row 6\r\n\Start Region: Column: ${startRegion.Column} - Row: ${startRegion.Row}`, "Match");
} else if (startRegion.Column == 1 && startRegion.Row == 1 && endRegion.Column == 6 && endRegion.Row == 6) {
sp.MessageBox(`Multiple Region Match!\r\n1,1 to 6,6\r\n\Start Region: Column: ${startRegion.Column} - Row: ${startRegion.Row}\r\n\End Region: Column: ${endRegion.Column} - Row: ${endRegion.Row}`, "Match");
} else {
sp.MessageBox(`No match, default condition\r\nStart Region: Column: ${startRegion.Column} - Row: ${startRegion.Row}`, "No Match");
}
You can also use some math to find the distance between the gesture start and end points. This would be direct distance between the points, not the length of the line itself: Code:var distance = parseInt(Math.sqrt(Math.pow((action.End.X - action.Start.X), 2.0) + Math.pow((action.End.Y - action.Start.Y), 2.0)));
sp.MessageBox(distance, "Distance");
And you can get the number of gesture points captured for simple/rough comparisons: Code:var pointCount = action.GesturePoints.Count();
sp.MessageBox(pointCount, "Gesture Points");
Or use the gesture point count with your specified line options (pixel distances) to get the overall length of the line as it was drawn: Code://Subtract 1 since it's already counted in the startDistance
var gesturePoints = action.GesturePoints.Count() - 1;
//Add 1 because the logic is if start segment being greater than the setting
var startDistance = sp_config.MinGestureStartDistance + 1;
//Add 1 because the logic is if current segment being greater than the setting
var segmentLength = sp_config.MinSegmentLength + 1;
var totalDistance = (gesturePoints * segmentLength) + startDistance;
sp.MessageBox(totalDistance, "Total Distance");
Note that these may not always be 100% accurate, but will be very close. Mouse messages travel very fast and there can be timing issues during the capture of points, etc. Edited by user Thursday, August 15, 2019 1:08:04 PM(UTC)
| Reason: Not specified
|