Discussion in 'Scripts (.NET)' started by aza77, Mar 25, 2008.

  1. aza77

    aza77 Active Member

    Messages:
    5
    does anyone have an idea how to get a KeyDown/Up Event?
    For example pressing F1 in game will open a Window and releasing it will close the Window.
  2. CyberTech

    CyberTech Second-in-Command Staff Member

    Messages:
    376
    I'm not sure that "keylogger" is going to be the best name for your app.
  3. aza77

    aza77 Active Member

    Messages:
    5
    well keylogger isn't the name of my application. it's just a part of it. i just wanted to get certain keys as events. for opening or closing windows for example, override the runmode things like that. keylogger is just a well known word that describes the basics of the function. since a keylogger does about the same.
  4. don'tdoit

    don'tdoit Active Member

    Messages:
    94
    Regardless of semantics, using keypresses is lame. What is it you are trying to do? Maybe if you explain it we might be able to tell you how to accomplish it without keypresses.
  5. aza77

    aza77 Active Member

    Messages:
    5
    i want to disable my run thread as soon as i start moving my character and continue it once i stop moving my char. clicking something is no choice since it takes too long. that's one of the things i need it for. another one i wanted to do is to hide the control window and reopen it with a keystring and maybe a keycombo to stop the bot. i also thought about building a spell or ability queue with it.
  6. Stardog

    Stardog Active Member

    Messages:
    53
    umm

    I'm not sure i understand completely what your trying to do, however it sounds like you want to be able to hit an F-KEY like F1 and have it bring up a menu and/or start and stop your script/bot/program. if thats the case. There are a couple ways you could do it

    1) Set up an event to Minimize and maximize on a key hit.
    you can capture the Key press in .net and set it up on that.

    or you can build your own system with timers. and have it check a state flag every 1 second.

    best to explain exactly what your trying to do...
  7. aza77

    aza77 Active Member

    Messages:
    5
    well i tried to use a keyboard hook to capture certain keys and the duration they are pressed.

    the menu is only one example. the more important one is to override the bot during moving for example. while i move the bot should do nothing.

    the problem i have now is that hooks don't seem to work at all ;) they work as soon as i don't use them in game, but refuse their work where i need them. if someone could explain me why i would be more than glad. capturing a key at .net is only possible with a hook or controls as far as i know (<-- might be wrong here, but i don't know another way ;) ). since i want to capture them regardless if any window has a focus at all i thought hooks would be the way to go.
  8. rootkit

    rootkit Active Member

    Messages:
    12
    just use the innerspace (global)bind cmd+event system to catch ur keys.


    define eventhandler:
    private EventHandler<LSEventArgs> Keyhandler;

    register event and attach to eventhandler:
    LavishScript.Events.AttachEventTarget(LavishScript.Events.RegisterEvent("KeyEvent"), Keyhandler = new System.EventHandler<LSEventArgs>(Event_KeyPushed));

    bind key to event:
    LavishScript.ExecuteCommand("Bind sample1 w Event[KeyEvent]:Execute[w]");
    LavishScript.ExecuteCommand("Bind sample2 s Event[KeyEvent]:Execute");

    tell ur main thread loop, that someone hit a key

    private void Event_KeyPushed(object src, LSEventArgs lse)
    {
    try
    {
    for (int i = 0; i < lse.Args.Length; i++)
    {
    if (lse.Args="w") WDown=true;
    if (lse.Args="s") SDown=true;
    }
    }
    catch (Exception ex)
    {
    }

    }

    stop the main thread loop, after someone hit a key
    static void Main()
    {
    while (!WDown && !SDown) System.Threading.Thread.Sleep(0);
    }

Share This Page