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)
|
Try this: Code:var lt = action.Window.Screen.Bounds.Left;
var rt = action.Window.Screen.Bounds.Right;
var tt = action.Window.Screen.Bounds.Top;
var bt = action.Window.Screen.Bounds.Bottom;
var ht = action.Window.Screen.Bounds.Height;
var wd = action.Window.Screen.Bounds.Width;
//Create rectangles for left, right, top, bottom
//These rectangles can overlap, adjust math to prevent if needed
var leftRect = new Rectangle(lt, tt, parseInt(wd / 8), ht);
var topRect = new Rectangle(lt, tt, wd, parseInt(ht / 8));
var rightRect = new Rectangle(rt - parseInt(wd / 8), tt, parseInt(wd / 8), ht);
var bottomRect = new Rectangle(lt, bt - parseInt(ht /8), wd, parseInt(ht / 8));
//Test location within rectangles
//supports special handling for in the corners, where the rectangles overlap
if(leftRect.Contains(action.End) && topRect.Contains(action.End)) {
sp.MessageBox("In Upper Left Rectangles", "Upper Left");
}
else if(leftRect.Contains(action.End) && bottomRect.Contains(action.End)) {
sp.MessageBox("In Lower Left Rectangles", "Lower Left");
}
else if(rightRect.Contains(action.End) && topRect.Contains(action.End)) {
sp.MessageBox("In Upper Right Rectangles", "Upper Right");
}
else if(rightRect.Contains(action.End) && bottomRect.Contains(action.End)) {
sp.MessageBox("In Lower Right Rectangles", "Lower Right");
}
else if(leftRect.Contains(action.End)){
sp.MessageBox("In Left Rectangle", "Left");
}
else if(rightRect.Contains(action.End)){
sp.MessageBox("In Right Rectangle", "Right");
}
else if(topRect.Contains(action.End)){
sp.MessageBox("In Top Rectangle", "Top");
}
else if(bottomRect.Contains(action.End)){
sp.MessageBox("In Bottom Rectangle", "Bottom");
}
else{
sp.MessageBox("Main Screen Area", "Not Along Edge");
}
|