StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
lyscop  
#1 Posted : Thursday, April 30, 2020 2:45:58 PM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
I want to divide the screen into 5 parts, the top/bottom/left/right of the screen of 1/8 and the middle.

In the option of the globe gesture of S+Net, I can choose the gesture zone, but I want to use code to achieve this thought like the following post.

I learned the code by the author in the following post, it is a pity that the result is the 1/8 or bottom of the program, not the windows screen.

https://forum.strokesplus.net/posts/t4023-how-to-achieve-the-following-three-gestures

Code by Rob:
Code:

//NOTE: gTopBottomMargin was not defined, I didn't see it in your script
//I just set it to something here
var gTopBottomMargin = 50;

var rt = action.Window.Rectangle.Right;
var bt = action.Window.Rectangle.Bottom;
var aw = rt / 8;
if(action.End.X > (rt - aw)) {
    sp.SendVKey(vk.VOLUME_DOWN);
} else if (action.End.Y > (bt - gTopBottomMargin)) { 
    sp.SendVKey(vk.RIGHT);
    //or sp.SendKeys("{RIGHT}");
} else {
    sp.SendModifiedVKeys([vk.LCONTROL,vk.LMENU], [vk.TAB]);
    //or sp.SendKeys("%^{TAB}");
}


Gesture zone of screen
Rob  
#2 Posted : Sunday, May 3, 2020 3:33:03 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)
Try using the screen's rectangle instead:

Code:
// Using screen's complete rectangle (full size)
var rt = action.Window.Screen.Bounds.Right;
var bt = action.Window.Screen.Bounds.Bottom;

// Using screen's working area (e.g. excluding taskbar area)
var rt = action.Window.Screen.WorkingArea.Right;
var bt = action.Window.Screen.WorkingArea.Bottom;
lyscop  
#3 Posted : Thursday, May 7, 2020 3:41:07 AM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
Originally Posted by: Rob Go to Quoted Post
Try using the screen's rectangle instead:

Code:
// Using screen's complete rectangle (full size)
var rt = action.Window.Screen.Bounds.Right;
var bt = action.Window.Screen.Bounds.Bottom;

// Using screen's working area (e.g. excluding taskbar area)
var rt = action.Window.Screen.WorkingArea.Right;
var bt = action.Window.Screen.WorkingArea.Bottom;


Dear Rob,

Nice to meet you.

Can you tell me particularly that how to judge the location like the following, I do not know whether it is right?

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;


if(action.End.X < lt ){

}
else if(action.End.X > rt ){

}
else if(action.End.Y < tt ){

}
else if(action.End.Y > bt ){

}
else{

}


Edited by user Thursday, May 7, 2020 3:42:13 AM(UTC)  | Reason: Not specified

Rob  
#4 Posted : Thursday, May 7, 2020 6:54:25 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)
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");
}
lyscop  
#5 Posted : Friday, May 8, 2020 1:21:09 AM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
Originally Posted by: Rob Go to Quoted Post
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");
}



Thank you so so so so much, Rob.

You show me the code not only the Top/Bottom/Left/Right zone but also the corner.

It helps me a lot.
Users browsing this topic
Guest
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.