Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
Sorrylol
42 discussion posts
Hello again!

I was wondering when creating 'if commands', is it possible to include another dependency on top of the initial one, so here is a current script that I have (linked below), and I want to include a dependency based on the location of another window entirely, and then reference it into the if command. so I imagine i'd first have to specify the window i am talking about with something like this:

IntPtr window = BFS.Window.GetWindowByText("*Program Name*");

but then how do i tell the function, to also include the coordinates of this window?

if (currentMonitor == 4) && location of program listed above is at a specific location (Rectangle (x, y, h, w);

then continue with the specified task

is this possible in anyway?

______________________________________

Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        // (Google Chrome tab dragging fix)
        if(BFS.Input.IsMouseDown("1"))
            return;
        
        // Get the monitor that the mouse cursor is on
        uint currentMonitor = BFS.Monitor.GetMonitorIDByXY(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY());
        
        // Setup the locations for the left and right monitors
        Rectangle topMonitorLocation = new Rectangle(-554, -1034, 1523, 1028);
        Rectangle toptopMonitorLocation = new Rectangle(-240, -2240, 1920, 1160);
        
        // Move window on which monitor the mouse cursor is on
        if (currentMonitor == 4)
        {
            BFS.Window.SetSizeAndLocation(windowHandle, topMonitorLocation.X, topMonitorLocation.Y, topMonitorLocation.Width, topMonitorLocation.Height);
        }
        else if (currentMonitor == 5)
        {
            BFS.Window.SetSizeAndLocation(windowHandle, toptopMonitorLocation.X, toptopMonitorLocation.Y, toptopMonitorLocation.Width, toptopMonitorLocation.Height);
        }
    }
}
Oct 19, 2020 (modified Oct 20, 2020)  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
If you get the bounds of the window, you can check them in the if statement like this:

Code

Rectangle windowBounds = BFS.Window.GetBounds(window);
if (currentMonitor == 4 &&
    windowBounds.X == 123 &&
    windowBounds.Y == 456 &&
    windowBounds.Width == 800 &&
    windowBounds.Height == 600)
{
    // Do stuff
}


Alternatively, to make the if statement a bit cleaner, you can set the bounds you want to check in a Rect first, like this:

Code

Rectangle windowBounds = BFS.Window.GetBounds(windowHandle);
Rectangle compareBounds = new Rectangle(123,456,800,600);
if (currentMonitor == 4 && windowBounds == compareBounds)
{
    // Do stuff
}


Hope that helps!
Oct 20, 2020  • #2
User Image
Sorrylol
42 discussion posts
This worked perfectly! thank you so much for the help.
Oct 20, 2020  • #3
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)