Jump to content

Plugins and Accept User Keyboard Input


Recommended Posts

18 minutes ago, Apexx said:

Hello, is there a way to get keys pressed? I would like to have two "keybinds", to my plugin if it is at all possible?

Can you explain a little more on what you mean?

If you're asking if it's possible to Press a Keybind from a Plugin , the answer is yes. If your question is: Is it possible to click a WoW macro by using a Keybind from a plugin, then answer is yes :).

Link to comment
Share on other sites

I would like to have the ability to add or remove the nearest WoW game object to the collections list for my WRadar plugin using hotkeys, like "Shift+Insert" and "Shift+Delete".

Link to comment
Share on other sites

I looked into the code and it seems you had used your own form events handling. I am using the WRobot's settings window from inside the class itself.
I don't think the InputHook catches anything while the game window has focus. I guess I am trying to catch the even from WRobot directly.

Link to comment
Share on other sites

19 minutes ago, Apexx said:

I looked into the code and it seems you had used your own form events handling. I am using the WRobot's settings window from inside the class itself.
I don't think the InputHook catches anything while the game window has focus. I guess I am trying to catch the even from WRobot directly.

I initially implemented it, because sometimes i had a bug from WRobot's keyboard class which didn't hooked my keys, dunno if it's fully working now.

Link to comment
Share on other sites

Yeah I cannot get WRobot's keyboard class to work either. Seen the examples throughout the forums though.

public class Main : IPlugin
{
	private Wradar.InputHook.KeyboardHook _hook;
	private Keys _keyAdd = Keys.None;
	private Keys _keyRemove = Keys.None;
	
	public void Initialize()
	{
		_keyAdd = Keys.F5;
		_keyRemove = Keys.F6;
		_hook = new Wradar.InputHook.KeyboardHook(true);	// Strange it doesn't work with this set as Global
		_hook.KeyDown += HookOnKeyDown;
		
		_isLaunched = true;
	}

	private void HookOnKeyDown(Keys key, bool shift, bool ctrl, bool alt)
    {
        Logging.WriteDebug("key = " + key);

        if (key == _keyAdd)
        {
            try
            {
                Logging.WriteDebug("Would you like to add ____ object to the collections list?");
            }
            catch (Exception ex)
            {
                Logging.WriteError("HookOnKeyDown _keyAdd Error:\n" + ex);
            }
        }
        else if(key == _keyRemove)
        {
            try
            {
                Logging.WriteDebug("Would you like to remove ____ object from the collections list?");
            }
            catch (Exception ex)
            {
                Logging.WriteError("HookOnKeyDown _keyRemove Error:\n" + ex);
            }
        }
    }
	
	public void Dispose()
    {
        try
        {
            if (_hook != null)
            {
                _hook.KeyDown -= HookOnKeyDown;
                _hook.Dispose();
            }
        }
        catch { }
        _isLaunched = false;
    }
}

 

Link to comment
Share on other sites

5 hours ago, Droidz said:

Yes I did. I have searched and tried everything from the forums that returned anything to do with keyboard events. I will double check the .Net framework version in a bit.

Link to comment
Share on other sites

Would it be easier to create a small addon for WoW directly that communicates with the plugin? I don't have much knowledge  integrated an addon with WRobot. How would one get/set variables from WRobot plugin data to an addon?

Link to comment
Share on other sites

Yeah I don't think KeyboardHook is working. I have tried using Target framework .NET Framework 4.5 as well as other later versions and it still cannot register hot key.
I also tried many different variations of hot key combinations.

Link to comment
Share on other sites

On 13/10/2017 at 5:03 PM, Apexx said:

Yes I did. I have searched and tried everything from the forums that returned anything to do with keyboard events. I will double check the .Net framework version in a bit.

In your code you don't "RegisterHotKey"

Link to comment
Share on other sites

readonly KeyboardHook _hookKeybinding = new KeyboardHook();

public InitMethod()
{
   _hookKeybinding.KeyPressed += (object sender, KeyPressedEventArgs e) =>
   {
      Logging.Write("Key was pressed!");
   };

   _hookKeybinding.RegisterHotKey(ModifierKeys.Shift, Keys.Insert);
}

Something like this is not working for you?

Link to comment
Share on other sites

Just now, Apexx said:

No errors, just the same [Keyboard Hook] Couldn’t register the hot key.

Oh damn i had the same problems y.y thats why i switched over to lua ingame detection. This will be a part for Driodz.

Link to comment
Share on other sites

Yeah I don't know. I somewhat give up on it for now. People will just have to pause/stop the bot and go to Plugin Settings to add/remove items from the collections list for now. Thanks though, @iMod

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...