Пример #1
0
 private void Callout(HotKey hotkey)
 {
     if (hotkey == null)
     {
         throw new ArgumentNullException(nameof(hotkey));
     }
     Ahk = AutoHotkeyEngine.Instance;
     if (WindowState == WindowState.Minimized)
     {
         Ahk.ExecRaw("Send, ^c");
         Thread.Sleep(300);
         Box.Text             = Clipboard.GetText().Trim();
         GlobalVariables.Text = Box.Text;
         WindowState          = WindowState.Normal;
         Activate();
         Focus();
         ShowInTaskbar = true;
         //Topmost = true;
     }
     else
     {
         WindowState   = WindowState.Minimized;
         ShowInTaskbar = true;
     }
 }
Пример #2
0
 public MouseDisabler()
 {
     if (PlayerIndexController._PlayerIndex == null)
     {
         try
         {
             ahk = new AutoHotkeyEngine();
             ahk.ExecRaw("*RButton:: return");                    //The star means it will disable even with modifier keys e.g. Shift
             ahk.ExecRaw("*LButton:: return");
             ahk.ExecRaw("*MButton:: return");
             ahk.ExecRaw("*XButton1:: return");
             ahk.ExecRaw("*XButton2:: return");
             //ahk.ExecRaw("*WheelDown:: return"); //Player can scroll very fast such that AutoHotKey is overloaded, so dont lock scroll wheel
             //ahk.ExecRaw("*WheelUp:: return");
             //ahk.ExecRaw("*WheelLeft:: return");
             //ahk.ExecRaw("*WheelRight:: return");
             ahk.Suspend();
         }catch
         {
             Monitor.Log("Could not load Mouse Disabler. This is probably not the first instance", StardewModdingAPI.LogLevel.Info);
         }
     }
     else
     {
         Monitor.Log("Will not load Mouse Disabler on this instance because player index is not zero", StardewModdingAPI.LogLevel.Warn);
     }
 }
Пример #3
0
        public PoetTrainer(PoetConfiguration config)
        {
            TkTrainerFactory.Initialize(TkClient.BasePath.Poet.ToString());

            _clients = new ActiveClients(config.Process);

            _poet = string.IsNullOrWhiteSpace(config.Name)
                ? _clients.GetPoet()
                : _clients.GetPoet(config.Name);

            _poet.Activity.DefaultCommandCooldown = config.CommandDelay;

            Log.Debug($"Key item assignments:\n{_poet.Inventory.KeyItems}\n");
            Log.Debug($"Key spell assignments:\n{_poet.Spells.KeySpells}\n");

            _isRunning        = new AutoHotkeyToggle("^F2", "isRunning", true);
            _isPaused         = new AutoHotkeySuspendToggle("F2", "isPaused", false);
            _shouldHardenBody = new AutoHotkeyToggle("F5", "shouldHardenBody", config.HardenBody.Value);
            _resetCurses      = new AutoHotkeyToggle("F12", "resetCurses", false);
            _shouldEsunaExternalGroupMembers = new AutoHotkeyToggle("^F12", "shouldEsunaExternalGroupMembers", false);

            var toggles = new[]
            {
                _isRunning,
                _isPaused,
                _shouldHardenBody,
                _resetCurses,
                _shouldEsunaExternalGroupMembers
            };

            _ahk = AutoHotkeyEngine.Instance;
            _ahk.LoadToggles(toggles);
        }
Пример #4
0
        public InputDisabler()
        {
            try
            {
                ahk = new AutoHotkeyEngine();
                ahk.ExecRaw("*RButton:: return");                //The star means it will disable even with modifier keys e.g. Shift
                ahk.ExecRaw("*LButton:: return");
                ahk.ExecRaw("*MButton:: return");
                ahk.ExecRaw("*XButton1:: return");
                ahk.ExecRaw("*XButton2:: return");
                //ahk.ExecRaw("*WheelDown:: return"); //Player can scroll very fast such that AutoHotKey is overloaded, so dont lock scroll wheel
                //ahk.ExecRaw("*WheelUp:: return");
                //ahk.ExecRaw("*WheelLeft:: return");
                //ahk.ExecRaw("*WheelRight:: return");

                //Prevents accidentally opening start menu
                ahk.ExecRaw("*Lwin:: return");
                ahk.ExecRaw("*Rwin:: return");

                //(Doesn't seem to prevent accidentally alt+tab)
                ahk.ExecRaw("*Alt:: return");
                ahk.ExecRaw("*Control:: return");
                ahk.ExecRaw("*Shift:: return");
                ahk.Suspend();
            }
            catch
            {
                Monitor.Log("Could not load Mouse Disabler. This is probably not the first instance");                //TODO: info level
            }
        }
        public static AutoHotkeyEngine Run()//toto make disposable wrapper to deal with saving state, saved positions..ect.
        {
            var ptr = Marshal.GetFunctionPointerForDelegate(ahkDelegate);
            var ahk = new AutoHotkeyEngine();

            ahk.Load("input.ahk");
            ahk.SetVar("ptr", ptr.ToString());
            return(ahk);
        }
Пример #6
0
        /// <summary>
        /// A convenience method for loading a collection of AutoHotkeyToggle objects into an instance of AutoHotkey.
        /// </summary>
        /// <param name="ahk">The instance of AutoHotkey into which to load the toggles.</param>
        /// <param name="toggles">A collection of AutoHotkeyToggle objects to load into AutoHotkey.</param>
        public static void LoadToggles(this AutoHotkeyEngine ahk, IEnumerable <AutoHotkeyToggle> toggles)
        {
            var sb = new StringBuilder();

            foreach (var toggle in toggles)
            {
                sb.AppendLine(toggle.GetDeclaration());
            }

            ahk.LoadScript(sb.ToString());
        }
Пример #7
0
    private void InitBindMode()
    {
        bindModeThread = new AutoHotkeyEngine();
        BindModeEvent bindModeEventDelegate = BindModeEventCallback;

        IntPtr eptr = Marshal.GetFunctionPointerForDelegate(bindModeEventDelegate);

        bindModeThread.LoadFile("BindModeThread.ahk");
        var tv = bindModeThread.GetVar("tv");

        bindModeThread.ExecRaw(String.Format("bh := new BindHandler({0})", eptr));
    }
Пример #8
0
        public MainWindow()
        {
            InitializeComponent();
            Ahk              = AutoHotkeyEngine.Instance;
            InputSimulator   = new InputSimulator();
            KeyActionManager = new KeyActionManager(Dispatcher, InputSimulator);
            BluetoothManager bluetoothManager = new BluetoothManager();

            GyroscopeReadingUuid       = GyroscopeRfcommServiceConnectionWrapper.RfcommServiceId;
            KeyboardServiceUuid        = Constants.KeyboardServiceGuid;
            MouseServiceUuid           = Constants.MouseServiceId;
            MouseCharacteristicUuid    = Constants.MouseActionCharacteristicWrapper;
            KeyboardCharacteristicUuid = Constants.KeyActionCharacteristicWrapper;

            var characteristicDict = new Dictionary <Guid, List <CharacteristicProfile> >();

            characteristicDict.Add(KeyboardServiceWrapper.Guid, new List <CharacteristicProfile>()
            {
                new CharacteristicProfile
                {
                    Notified = true,
                    Guid     = Constants.KeyActionCharacteristicWrapper
                },
                new CharacteristicProfile
                {
                    Notified = true,
                    Guid     = Constants.MouseActionCharacteristicWrapper
                }
            });
            var serviceId = new List <Guid>
            {
                MouseServiceWrapper.ServiceId
            };
            ConnectionProfile profile = new ConnectionProfile()
            {
                RequiredCharacteristicGuids = characteristicDict,
                RequiredServiceGuids        = serviceId
            };

            BleDeviceSelectorWindow bleDeviceSelectorWindow = new BleDeviceSelectorWindow(bluetoothManager, profile);

            bleDeviceSelectorWindow.ShowDialog();
            ConnectionBuildResult = bleDeviceSelectorWindow.ConnectionBuildResult;
            MouseServiceWrapper   = new MouseServiceWrapper(ConnectionBuildResult[MouseServiceUuid].RfcommConnection);
            MouseServiceWrapper.OnMouseMoveReceived           += MouseServiceWrapper_OnMouseMoveReceived;
            KeyboardServiceClientWrapper                       = new KeyboardServiceClientWrapper(ConnectionBuildResult[KeyboardServiceUuid, KeyboardCharacteristicUuid], ConnectionBuildResult[KeyboardServiceUuid, MouseCharacteristicUuid]);
            KeyboardServiceClientWrapper.OnKeyStatusChanged   += KeyboardServiceClientWrapper_OnKeyStatusChanged;
            KeyboardServiceClientWrapper.OnMouseStatusChanged += KeyboardServiceClientWrapper_OnMouseStatusChanged;
        }
Пример #9
0
        public void Start()
        {
            _instance = AutoHotkeyEngine.Instance;
            var currentKeyboardLayout = KeyboardLayouts.GetProcessKeyboardLayout();

            if (Enum.IsDefined(typeof(EuropeanLayout), (int)currentKeyboardLayout.KeyboardId))
            {
                _instance.ExecRaw(
                    $"+,::\n" +
                    $"Random, rand, 1, 5\n" +
                    $"If(rand == 1)\n" +
                    $"Sendinput % chr(894)\n" +     // greek questionmark
                    $"Else\n" +
                    $"Sendinput % chr(59)");
            }
        }
Пример #10
0
        public MageTrainer(MageConfiguration config)
        {
            TkTrainerFactory.Initialize(TkClient.BasePath.Mage.ToString());

            _clients = new ActiveClients(config.Process);

            _mage = string.IsNullOrWhiteSpace(config.Name)
                ? _clients.GetMage()
                : _clients.GetMage(config.Name);

            _mage.Activity.DefaultCommandCooldown = config.CommandDelay;

            Log.Debug($"Key item assignments:\n{_mage.Inventory.KeyItems}\n");
            Log.Debug($"Key spell assignments:\n{_mage.Spells.KeySpells}\n");

            _isRunning = new AutoHotkeyToggle("^F1", "isRunning", true);
            _isPaused  = new AutoHotkeySuspendToggle("F1", "isPaused", false);
            _shouldEsunaExternalGroupMembers = new AutoHotkeyToggle("F11", "shouldEsunaExternalGroupMembers", false);
            _shouldHeal       = new AutoHotkeyToggle("`", "shouldHeal", config.Heal.Value);
            _shouldBlind      = new AutoHotkeyToggle("1", "shouldBlind", config.Blind.Value);
            _shouldParalyze   = new AutoHotkeyToggle("2", "shouldParalyze", config.Paralyze.Value);
            _shouldVenom      = new AutoHotkeyToggle("3", "shouldVenom", config.Venom.Value);
            _shouldVex        = new AutoHotkeyToggle("4", "shouldVex", config.Vex.Value);
            _shouldZap        = new AutoHotkeyToggle("5", "shouldZap", config.Zap.Value);
            _shouldUpdateNpcs = new AutoHotkeyToggle("6", "shouldUpdateNpcs", false);

            var toggles = new[]
            {
                _isRunning,
                _isPaused,
                _shouldEsunaExternalGroupMembers,
                _shouldHeal,
                _shouldBlind,
                _shouldParalyze,
                _shouldVenom,
                _shouldVex,
                _shouldZap,
                _shouldUpdateNpcs
            };

            _ahk = AutoHotkeyEngine.Instance;
            _ahk.LoadToggles(toggles);
        }
Пример #11
0
        static InputController()
        {
            ahk = new AutoHotkeyEngine();
            ahk.Reset();

            try
            {
                var sets = new Settings.Settings(); sets.Load();
                bindings = sets.Controls.AsArray();
            }
            catch (Exception)
            {
                bindings = new InputBinding[0];
            }

            Thread t = new Thread(() => Application.Run(hookWnd));

            t.SetApartmentState(ApartmentState.STA);
            t.IsBackground = true;
            t.Start();
        }
Пример #12
0
    public static IObservable <IOperation> GetAllAhkVars(this AutoHotkeyEngine ahk)
    {
        var xy    = ahk.ExecFunction("GetMyMouse");
        var split = xy.Split('|');

        IOperation p = new ProcessInfo
        {
            WindowTitle    = ahk.ExecFunction("GetMyWindow"),
            ProcessId      = ahk.ExecFunction("GetPid"),
            ProcessName    = ahk.ExecFunction("GetProcessName"),
            ActiveWindowId = ahk.ExecFunction("GetTransparent")
        };

        IOperation m = new MouseInfo {
            X = Int32.Parse(split[0]), Y = Int32.Parse(split[1])
        };

        return(Observable.Return(p).
               Concat(
                   Observable.Return(m)
                   ));
    }
Пример #13
0
        public WarriorTrainer(WarriorConfiguration config)
        {
            TkTrainerFactory.Initialize(TkClient.BasePath.Warrior.ToString());

            _clients = new ActiveClients(config.Process);

            _warrior = string.IsNullOrWhiteSpace(config.Name)
                ? _clients.GetWarrior()
                : _clients.GetWarrior(config.Name);

            _warrior.Activity.DefaultCommandCooldown = config.CommandDelay;

            Log.Debug($"Key item assignments:\n{_warrior.Inventory.KeyItems}\n");
            Log.Debug($"Key spell assignments:\n{_warrior.Spells.KeySpells}\n");

            _shouldUpdateNpcs         = new AutoHotkeyBool("shouldUpdateNpcs", false);
            _isRunning                = new AutoHotkeyToggle("^F4", "isRunning", true);
            _isPaused                 = new AutoHotkeySuspendToggle("F4", "isPaused", false);
            _shouldSpotTrapsOnAethers = new AutoHotkeyToggle("F6", "shouldSpotTrapsOnAethers", false);
            _shouldTaunt              = new AutoHotkeyToggleWithPrerequisite("F7", "shouldTaunt", false, _shouldUpdateNpcs);
            _shouldWhirlwindOnAethers = new AutoHotkeyToggle("F8", "shouldWhirlwindOnAethers", config.Whirlwind.Value);
            _shouldBerserkOnAethers   = new AutoHotkeyToggle("F9", "shouldBerserkOnAethers", config.Berserk.Value);
            _shouldAutoMelee          = new AutoHotkeyToggle("F10", "shouldAutoMelee", config.Attack.Value);

            var toggles = new[]
            {
                _isRunning,
                _isPaused,
                _shouldTaunt,
                _shouldWhirlwindOnAethers,
                _shouldBerserkOnAethers,
                _shouldAutoMelee,
                _shouldSpotTrapsOnAethers
            };

            _ahk = AutoHotkeyEngine.Instance;
            _ahk.LoadToggles(toggles);
        }
Пример #14
0
        public RogueTrainer(RogueConfiguration config)
        {
            TkTrainerFactory.Initialize(TkClient.BasePath.Rogue.ToString());

            _clients = new ActiveClients(config.Process);

            _rogue = string.IsNullOrWhiteSpace(config.Name)
                ? _clients.GetRogue()
                : _clients.GetRogue(config.Name);

            _rogue.Activity.DefaultCommandCooldown = config.CommandDelay;

            Log.Debug($"Key item assignments:\n{_rogue.Inventory.KeyItems}\n");
            Log.Debug($"Key spell assignments:\n{_rogue.Spells.KeySpells}\n");

            _shouldUpdateNpcs               = new AutoHotkeyBool("shouldUpdateNpcs", false);
            _isRunning                      = new AutoHotkeyToggle("^F3", "isRunning", true);
            _isPaused                       = new AutoHotkeySuspendToggle("F3", "isPaused", false);
            _shouldTaunt                    = new AutoHotkeyToggleWithPrerequisite("7", "shouldTaunt", false, _shouldUpdateNpcs);
            _shouldLethalStrikeOnAethers    = new AutoHotkeyToggle("8", "shouldLethalStrikeOnAethers", config.LethalStrike.Value);
            _shouldDesperateAttackOnAethers = new AutoHotkeyToggle("9", "shouldDesperateAttackOnAethers", config.DesperateAttack.Value);
            _shouldAutoMelee                = new AutoHotkeyToggle("0", "shouldAutoMelee", config.Attack.Value);
            _shouldAmbushOnMelee            = new AutoHotkeyToggle("-", "shouldAmbushOnMelee", config.Ambush.Value);

            var toggles = new[]
            {
                _isRunning,
                _isPaused,
                _shouldTaunt,
                _shouldLethalStrikeOnAethers,
                _shouldDesperateAttackOnAethers,
                _shouldAutoMelee,
                _shouldAmbushOnMelee
            };

            _ahk = AutoHotkeyEngine.Instance;
            _ahk.LoadToggles(toggles);
        }
Пример #15
0
        //TODO: move to start of program in separate thread so it doesnt cause delay when start is first clicked

        public static void Init()
        {
            initTask = Task.Run(() =>
            {
                try
                {
                    Logger.WriteLine("Initialising InputDisabler");
                    ahk = AutoHotkeyEngine.Instance;
                    ahk.Suspend();

                    //The star means it will disable even with modifier keys e.g. Shift

                    ahk.ExecRaw("*MButton:: return");
                    ahk.ExecRaw("*XButton1:: return");
                    ahk.ExecRaw("*XButton2:: return");

                    ahk.ExecRaw("*LWin:: return");
                    ahk.ExecRaw("*Control:: return");
                    ahk.ExecRaw("*Alt:: return");
                    ahk.ExecRaw("*Shift:: return");                    //Important or shift will not function properly in game

                    ahk.ExecRaw("*RButton:: return");
                    ahk.ExecRaw("*LButton:: return");

                    ahk.Suspend();

                    IsInitialised = true;

                    Logger.WriteLine("Initialised InputDisabler");
                }
                catch
                {
                    Logger.WriteLine("Could not load InputDisabler");
                }
            });
        }
Пример #16
0
 public AutoHotkeyExecutor()
 {
     ahk = new AutoHotkeyEngine();
 }
Пример #17
0
 public AhkFunctions()
 {
     _ahk = AutoHotkeyEngine.Instance;
     _ahk.LoadFile("functions.ahk");
 }
Пример #18
0
 public Tasks(AutoHotkeyEngine ahk)
 {
     this.ahk = ahk;
 }