using System; using System.Drawing; public static class VoiceBotScript { private const string ScriptSettingName = "driving_mode"; // The deadzone of the mouse movement, in pixels private const int DeadZone = 10; // The speed at which the script runs. Each loop will wait for // this many milliseconds private const int IntervalMS = 10; public static void Run(IntPtr windowHandle) { // If the script is running, this will set the script to // stop running, and then exit if (BFS.ScriptSettings.ReadValueBool(ScriptSettingName)) { BFS.ScriptSettings.WriteValueBool(ScriptSettingName, false); return; } // If we got this far, that means the script isn't running BFS.ScriptSettings.WriteValueBool(ScriptSettingName, true); // Check where the mouse was when we started the script int origin = BFS.Input.GetMousePositionX(); // Run the loop while the script should be running while (BFS.ScriptSettings.ReadValueBool(ScriptSettingName)) { // Check how far the mouse is now int x = BFS.Input.GetMousePositionX(); int deltaX = Math.Abs(x - origin); // If the mouse is within the Deadzone, do nothing. // Otherwise, press the left of right key if(deltaX >= DeadZone) { // right if (x > origin) BFS.Input.SendKeysFast("{VK_39}"); else // left BFS.Input.SendKeysFast("{VK_37}"); } // Wait for the specified time BFS.General.ThreadWait(IntervalMS); } } }