using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
public static class DisplayFusionFunction
{
// update this value to match the hotkey you've assigned to this function -- ignoring ctrl, alt, etc. (I use Alt+A)
static Keys hotkeyKey = Keys.A;
[DllImport("user32")]
static extern bool GetAsyncKeyState(int vKey);
public static void Run(IntPtr windowHandle)
{
// if cursor is already unlocked by hotkey, don't start hotkey function again
if (BFS.ScriptSettings.ReadValueBool("Cursor unlocked")) return;
// unlock the mouse cursor since hotkey has been pressed down
Cursor.Clip = Rectangle.Empty;
BFS.ScriptSettings.WriteValueBool("Cursor unlocked", true);
// wait until the hotkey is released
while (GetAsyncKeyState((int)hotkeyKey)) {
Thread.Sleep(10);
}
// then lock the mouse cursor again
Cursor.Clip = BFS.Monitor.GetMonitorBoundsByMouseCursor();
BFS.ScriptSettings.WriteValueBool("Cursor unlocked", false);
}
}