What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Help KeyPress/KeyDown Event

taladis

New Member
Joined
Feb 10, 2012
Messages
5
Reaction score
0
I'm developing an arena CC but having difficulties to implement a function to detect keyboard inputs
The point is, i need to stop the rotation whenever i press certain keys so it doesn't eat all the GCDs.

Found this so far, but still cant apply the thing on my CC.
Control.KeyDown Event (System.Windows.Forms)

any tips??
 
@Taladis,

There are a few of us that have come to this wall... From what I know there are 3 ways to send "Keystrokes" to the top window (in this case WoW):

1) SendInput
2) PostMessage
3) SendMessage


It's a daunting task, you might get further if you try using Scripts instead of the above.
 
You guys might wanna look into how PQR handles keybinds.

I didn't play a whole lot with it but it seemed extremely smooth on that particular aspect.
 
honorbuddy does not have the ability to Nativity handle key-binds, you can make a plugin to handle them, but your stuck going to have to code it yourself.
 
Not sure how helpful these would be
Styx.Logic.Combat.SpellManager.GlobalCooldown (bool): Returns true if the Global Cooldown timer is running.
and
Styx.Logic.Combat.SpellManager.GlobalCooldownLeft (TimeSpan): Returns the amount of time left on Global Cooldown. TimeSpan with remaining time for the Global Cooldown Timer, TimeSpan.Zero if it's not running.

I guess those could only help if you were able to detect when the GCD timer is active when you weren't expecting it to be. Certainly seems easier if you can just detect keystrokes like you want :p.


@Taladis,

There are a few of us that have come to this wall... From what I know there are 3 ways to send "Keystrokes" to the top window (in this case WoW):

1) SendInput
2) PostMessage
3) SendMessage


It's a daunting task, you might get further if you try using Scripts instead of the above.
I believe OP is trying to listen for when he manually presses keys on the keyboard, not simulate keystrokes programmatically.
 
Last edited:
Make a /yell macro "Freeze mothafuckah!" and then listen to the chatmessage, totally doable and easy since there are a few plugins to have as reference.:)
 
Make a /yell macro "Freeze mothafuckah!" and then listen to the chatmessage, totally doable and easy since there are a few plugins to have as reference.:)
LMAO, not ideal but should work...
 
@Taladis,

Can you re-explain to me what exactly you are trying to do:

From what I gather you are trying to make a Function that will stop Combat() with the press of a button. Am I right to assume such?
 
@Taladis,

Can you re-explain to me what exactly you are trying to do:

From what I gather you are trying to make a Function that will stop Combat() with the press of a button. Am I right to assume such?

Yeah, exactly, i need it to stop just while i have a keyboard button pressed on the top window(WoW).
the idea is to allow a player to do stuff with the bot running, because what happens now is that the bot consumes
all the global cooldowns and you have to spam a button hoping the key enters
 
@Taladis,

Ok so if you want it to only stop Combat() while you have the key pressed you will need something such as the following:
PHP:
[DllImport("User32.dll")]
     private static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey);
 
[DllImport("User32.dll")]
    private static extern short GetAsyncKeyState(System.Int32 vKey);
 [DllImport("User32.dll")]
    public static extern int GetWindowText(int hwnd, StringBuilder s, int nMaxCount);
 [DllImport("User32.dll")]
    public static extern int GetForegroundWindow();
After which you will need something such as this to actually listen for the Key (Lets say you are using CapsLock as there is no Left or Right):
PHP:
public static bool CapsLock
{
    get { return Convert.ToBoolean(GetAsyncKeyState(Keys.CapsLock) & 0x8000); }
}
Then you need to add something such as this to your Combat():
PHP:
if(CapsLock)
{
    if(!tglCapslock)
    {
        tglCapslock = true;
        keyBuffer += "";
    }
}
else
{
    if(tglCapslock)
    {
        tglCapslock = false;
        keyBuffer += "";
    }
}
NOW STOP!!!
I will say this once and only once:


Your intentions may be good but the above is simply too close to that of a "Key-Logger", in reality it is the foundation of one. I would be very cautious if you take this route & I would state very clearly that by no means is this section of code meant to be used as such. Also, there are various software programs that will detect the CC within HB as the user presses the "Stop Combat() Key" and think that a "Key-Logger" has latched onto their gaming system thus blocking HB. The user only needs to allow HB through the software program and continue as normal but the headache still remains if you get spammed with "Why's".

In any case I wish you luck & hope the above gives you insight to fixing your problem,
"if I where you I'd take a look into Scripts."
 
ty a lot, will try to implement this and give a feedback here
 
An easy workaround is using focus, focus yourself and use macros
 
@Kaihaider,

Could you expand upon your theory please, would love to see some code or an explanation of your idea! I use both the method I showed in my last post and Scripts (Basically the same as macros), but would like to see if your idea is better!
 
Just a simple bool check: StyxWoW.Me.FocusedUnit != Styx.WoW.Me before the combat logic or whatever spells you want to stop it from casting, to free up your cast. Just have them macro two buttons, one for focus target and one for focus self. That way toggleing combat is really simple.



You could also use a local var; so each time the focus changes to you, you wait one global cooldown. That way people don't accidentally lock up combat for a long time. I'm kind of too lazy to write that right now, but if you have trouble with it, i guess I can implement it in RogueRaidBT so you can have a look.
 
Last edited:
@Kaihaider,

I understand what you've done, nice way to do it. In PvP this wouldn't work as it would mess up your Focus (Such as if you need to cast Strangulate on your focus or w/e or make you have to press more focus macros to get what you wanted focus). I personally use a "Toggle Script" and "IsKeyPressed()" function to stop Combat(). So that if the macro is pressed ti stops and if pressed again it starts, you only need wait for whatever is left of the GCD to cast your spell. With the "IsKeyPressed()" function you just need to hold down the key and it will cast whatever spell is bound to it when the GCD is finished, and then starts Combat() automatically.
 
I think saying it wouldn't work for PvP and that it would mess up focus is a little harsh :P Binding a group of buttons for focus and swapping focus around isn't so bad. Eventually I want to track a list of wowunits so I can watch for and interrupt possible heals when focus isn't set.
 
@Kaihaider,

I think Singular has a spell cast method similar to that, I use it for AMS (It will cast AMS if anyone is casting at me) also used for other various checks. You might be able to set it to target/Focus them if "Spell" is cast and then cast "Kick spell" without ever having to manually swap a focus or target. Will look it up and post here.
 
Not really sure what you mean, if you keep an instance of their wowunit you just send it to SpellManager.Cast(spellId, wowunit);
 
@Kaihaider,

I don't think I've ever used a method in which a player is stored, would be interested in seeing how that works! I have used a similar function as to the one you posted above, but only if I state who the unit is. I supose one could use arena1, arena2, arena3 like in macros, or maybe I am way off, lol.
 
You could use macros to get the arena wowunit if there's nothing in the api. But storing players/mobs is just basic programming since there a variable given by the api. Any .me or .currenttarget gets a wowunit, or you can just use the objectmanager.getobjecttype<wowunit>.where blah blah. orderBy blah blah. For an Ienumerable with all of the wowunits. Either update every tick or under some condition and then you can do whatever you want with them.
 
Back
Top