コード例 #1
0
        public static void SetKeyByAction(Enums.Keybindings action, string key)
        {
            try
            {
                Lua.LuaDoString("SetBinding(GetBindingKey(\"" + action + "\"));");
                Lua.LuaDoString("SetBinding(\"" + key.ToUpper() + "\", \"" + action + "\");");
                Lua.LuaDoString("SaveBindings(2)");

                ResetList();
            }
            catch (Exception exception)
            {
                Logging.WriteError("SetKeyByAction(Enums.Keybindings action, string key): " + exception);
            }
        }
コード例 #2
0
 public static void DownKeybindings(Enums.Keybindings action)
 {
     try
     {
         string k = GetKeyByAction(action);
         if (k != "")
         {
             Keyboard.DownKey(Memory.WowProcess.MainWindowHandle, k);
         }
     }
     catch (Exception exception)
     {
         Logging.WriteError("DownKeybindings(Enums.Keybindings action): " + exception);
     }
 }
コード例 #3
0
        public static string GetKeyByAction(Enums.Keybindings action, bool autoAssignKeyIfNull = true)
        {
            try
            {
                // Search if exist in list
                foreach (KeybindingsStruct k in _keybindingsList)
                {
                    if (k.Key != "" && k.Action == action)
                    {
                        return(k.Key);
                    }
                }

                // Search if exist ingame:
                Lua.LuaDoString("key1, key2 = GetBindingKey(\"" + action + "\");");
                string k1 = Lua.GetLocalizedText("key1");
                string k2 = Lua.GetLocalizedText("key2");
                if (k1 != "" && k1 != "BUTTON3")
                {
                    _keybindingsList.Add(new KeybindingsStruct {
                        Action = action, Key = k1
                    });
                    return(k1);
                }
                if (k2 != "" && k2 != "BUTTON3")
                {
                    _keybindingsList.Add(new KeybindingsStruct {
                        Action = action, Key = k2
                    });
                    return(k2);
                }

                // Create if don't exist:
                if (autoAssignKeyIfNull)
                {
                    string key = GetAFreeKey();
                    if (!string.IsNullOrEmpty(key))
                    {
                        if (k1 == "BUTTON3" || k2 == "BUTTON3")
                        {
                            Logging.WriteDebug(action + " were bind to a mouse button, as TheNoobBot does not support mouse button, currently trying to bind it with key: " + key + ".");
                        }
                        else
                        {
                            Logging.WriteDebug(action + " were not bind, currently trying to bind it with key: " + key + ".");
                        }
                        SetKeyByAction(action, key);
                        _keybindingsList.Add(new KeybindingsStruct {
                            Action = action, Key = key
                        });
                        return(key);
                    }
                    Logging.WriteDebug(
                        "No free keys found on 236 possible bindings, if you got that line, you mainly have a problem with your WoW keybindings.");
                    return("");
                }
                return("");
            }
            catch (Exception exception)
            {
                Logging.WriteError("GetKeyByAction(Enums.Keybindings action, bool autoAssignKeyIfNull = true): " +
                                   exception);
                return("");
            }
        }