Title

Message

Confirm

Want to earn a free DisplayFusion Pro license? We're looking for DisplayFusion translators!
<< DiscussionsReply

Move window to right third of screen? (Minor function help needed)

Avatar from Gravatar.com
dracho
8 discussion posts
This code contains what I need, but I'm not sure how to modify it to suit my needs. It cycles between resizing and moving the active window to the left third, middle third, and right third.

I want separate buttons for middle third and right third. I have left third already.

Code

16 days ago  • #1
Avatar from Gravatar.com
dracho
8 discussion posts
P.S. I almost forgot, I would also love a cycle-type button, similar to the one I posted above, that resizes to 50% vertical and moves to the top, then moves to the bottom when clicked again, etc. Once I understand the code above a bit better, I should be able to do this on my own, unless you feel so inclined to help further. Thanks.
16 days ago  • #2
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Were you able to get the separate buttons working with the Custom Functions you were mentioning in the other thread?

For the other script are you wanting it to cycle between 50% height, 100% width on the top, and the same on the bottom?
16 days ago  • #3
Avatar from Gravatar.com
dracho
8 discussion posts
Ideally, I would like to understand the code better so that I can tweak things to my liking.

In the code snippet I pasted, could you (or someone) add comments to explain where the 33% width is determined, where the location of the window is determined, and how the cycling works between three locations?

In the end, I'll want a single button that cycles between these 3 functions: Size to 33% Width and Center Horizontally on Monitor (this is included in the code snippet, when the button is clicked twice), Size and Move Window to Top of Monitor, and Size and Move to Bottom (these two are built-in).

I will also want a button that cycles between these 2 functions: Size and Move Window (50%) to Left Side of Monitor, and Size and Move Window (33%) to Left Side of Monitor (again, this is included in the code snippet, when the button is clicked once).

Finally, I want a button that is the inverse of the one mentioned above - focusing on the right side instead of the left.

Thanks very much! :)

(EDIT: Reworded description of first button to properly represent the order in which I want to click it - first Center, then Top, then Bottom.)
16 days ago (modified 16 days ago)  • #4
Keith Lammers (BFS)'s profile on WallpaperFusion.com
The 33% is determined on line 25 by dividing the monitor width by 3:

int iFinalWinW = monitorRect.Width / 3;

The windowRect near the top is what gets the current window size, and further down it gets compared to the target size determined by iFinalWinX/Y/W/H.

The script you want to write would be pretty complicated, but is possible to do. Basically, you'd need to know your desired size/locations, then compare the current size to figure out if it's already at one of them and load the next size. In reality, that's trickier than it sounds :)
15 days ago  • #5
Avatar from Gravatar.com
dracho
8 discussion posts
Ok, thanks for the reply.

I can make my request much simpler. I would be very happy to have a button that performs only one function: Size the window to 33% width and move it to the Right side of the screen.

Using the code that you will hopefully graciously give me, I should be able to make my own button that does the exact same thing; only one function (no cycling) that will size to 33% and move to the Left side.

Thank you much!
8 days ago  • #6
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ok, try this out:

Code



The left side is much easier, you just need to change the calculation to:

targetWindowBounds.X = monitorBounds.X;

And if you want to do the middle, do this:

targetWindowBounds.X = monitorBounds.X + targetWindowBounds.Width;

Hope that helps!
5 days ago  • #7
Was this helpful?  Login to Vote  Login to Vote
<< DiscussionsReply