using System; using System.Drawing; using System.Runtime.InteropServices; // The 'windowHandle' parameter will contain the window handle for the: // - Active window when run by hotkey // - Trigger target when run by a Trigger rule // - TitleBar Button owner when run by a TitleBar Button // - Jump List owner when run from a Taskbar Jump List // - Currently focused window if none of these match public static class VoiceBotScript { [DllImport("User32.dll")] private static extern void mouse_event(MouseEventFlags dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo); public static void Run(IntPtr windowHandle) { // Press the left mouse button mouse_event(MouseEventFlags.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero); // Wait 1 second BFS.General.ThreadWait(1000); // Release the left mouse button mouse_event(MouseEventFlags.MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero); } // This enum contains the mouse_event constants [Flags] private enum MouseEventFlags : uint { MOUSEEVENTF_MOVE = 0x0001, /* mouse move */ MOUSEEVENTF_LEFTDOWN = 0x0002, /* left button down */ MOUSEEVENTF_LEFTUP = 0x0004, /* left button up */ MOUSEEVENTF_RIGHTDOWN = 0x0008, /* right button down */ MOUSEEVENTF_RIGHTUP = 0x0010, /* right button up */ MOUSEEVENTF_MIDDLEDOWN = 0x0020, /* middle button down */ MOUSEEVENTF_MIDDLEUP = 0x0040, /* middle button up */ MOUSEEVENTF_XDOWN = 0x0080, /* x button down */ MOUSEEVENTF_XUP = 0x0100, /* x button down */ MOUSEEVENTF_WHEEL = 0x0800, /* wheel button rolled */ MOUSEEVENTF_HWHEEL = 0x01000 /* hwheel button rolled */ } }