Results 1 to 10 of 10

Thread: How do I make a new KeyEvent? (For a bot)

  1. #1
    Join Date
    Sep 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How do I make a new KeyEvent? (For a bot)

    Okay so thanks to Wyn10, I know how to properly make a runescape loader. I've set up a thread when the loader starts that takes buffered image screenshots of the loader screen and saves them to a file (this is because I was experimenting with the screen capture method in the Robot class). Well I know that using the robot class for your key and mouse events takes control of your mouse and that you have to create a new KeyEvent using its constructor and using
    Code:
    Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(KeyEvent/MouseEvent)
    . The only thing I don't know is what exactly to put in the "when" parameter, and the source parameter. the constructors are (the 2 that aren't deprecated):
    1.)
    Code:
    public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar)
    2.)
    Code:
    public KeyEvent(Component source, int id, long when,  int modifiers, int keyCode, char keyChar, int keyLocation)
    the details in the Javadoc are:
    source - the Component that originated the event
    id - an integer identifying the type of event
    when - a long integer that specifies the time the event occurred
    modifiers - the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.
    keyCode - the integer code for an actual key, or VK_UNDEFINED (for a key-typed event)
    keyChar - the Unicode character generated by this event, or CHAR_UNDEFINED (for key-pressed and key-released events which do not map to a valid Unicode character)

    Anyways, I know how to get the source (which is the applet that the game is displayed on, the id is an int such as keyPressed/keyReleased, not sure about the when, modifiers is obvious, the keyCode is something such as VK_H/VK_SPACE, and I'm not sure about the keyChar. If anyone could explain how to find the "when" integer, and the source I would appreciate it.
    Last edited by chandlerethan; 01-07-2012 at 06:58 PM.

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    You could try giving the constructor the current time for the when parameter (probably System.currentTimeMillis()). If you're sending a key typed event, you'll want to provide the character you're sending (e.g. 'f' if you're sending the letter f) as the keyChar parameter; otherwise, you can pass CHAR_UNDEFINED as the documentation specifies.
    Last edited by Method; 01-07-2012 at 06:41 PM. Reason: constructor => documentation
    :-)

  3. #3
    Join Date
    Sep 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks. what do I put for the source parameter? I've tried using both my applet component, AND the jframe component, and neither work... :/ any suggestions? I tried adding a key listener to the applet and the jframe but it wont register them.. D:

  4. #4
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    I'm not positive, but you might need to grab the canvas object from the applet and use that as the source. You should be able to do something like applet.getComponentAt(1, 1) to do so.

    If that doesn't work, consider sending events directly to the client's input listeners.
    :-)

  5. #5
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Source would be the applet.

  6. #6
    Join Date
    Sep 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm not exactly sure how i'd send them directly to the client's input listeners. I'm not an expert at Java, but if you explain, I know my way around Java. If that makes sense.

  7. #7
    Join Date
    Jul 2008
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  8. #8
    Join Date
    Jan 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Which component would I send the keyevent to? I've tried sending it to both the applet and the jframe and neither are working. and none of my listeners are picking up and keystrokes/mouse clicks.

  9. #9
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Quote Originally Posted by Chandler` View Post
    Which component would I send the keyevent to? I've tried sending it to both the applet and the jframe and neither are working. and none of my listeners are picking up and keystrokes/mouse clicks.
    applet.getComponent(0).dispatchEvent just like ollie said on the mopaisthebest thread that stuart posted. It's Canvas component. You are doing pretty much the same I did like 2 days ago
    Quote Originally Posted by DeSnob View Post
    ETA's don't exist in SRL like they did in other communities. Want a faster update? Help out with updating, otherwise just gotta wait it out.

  10. #10
    Join Date
    Jan 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ~ ProRa's Runescape Public Hook Updater ~

    1084 classes.

    ~ Version #699 - ]


    SPP Hooks:
    Toolkit => mra.e
    MapAngle => hga.l
    LoopCycle => tn.j

    Animable:
    jl implements org/GL/client/Animable
    getX1() => static short jl.i
    getY1() => static short jl.p
    getX2() => static short jl.d
    getY2() => static short jl.f

    Cache:
    dea implements org/GL/client/Cache
    getTable() => org.GL.client.HashTable dea.b
    getList() => org.GL.client.NodeSubQueue dea.a
    getInitialCount() => int dea.c
    getSpaceLeft() => int dea.d

    Canvas:
    Class => bu java.awt.Canvas = org/GL/client/input/Canvas
    Utf8 => bu java/awt/Canvas = org/GL/client/input/Canvas

    Client:
    client implements org/GL/client/Client
    getMouse() => static org.GL.client.input.Mouse sha.j
    getCanvas() => static java.awt.Canvas lsa.a
    getLoginIndex() => static int qfa.c * -767437059
    getGUIRSInterfaceIndex() => static int vga.o * 1238906071
    getViewport() => static org.GL.client.Viewport hu.d

    DirectXModel:
    pja implements org/GL/client/ModelDirectX
    getXPoints() => int[] pja.R
    getYPoints() => int[] pja.lb
    getZPoints() => int[] pja.c
    getIndices1() => short[] pja.F
    getIndices2() => short[] pja.v
    getIndices3() => short[] pja.m

    DirectXRender:
    np implements org/GL/client/DirectXRender

    HardReference:
    hja implements org/GL/client/HardReference
    get() => java.lang.Object hja.h

    HashTable:
    dsa implements org/GL/client/HashTable
    getBuckets() => org.GL.client.Node[] dsa.d

    Keyboard:
    Class => ul java.lang.Object = org/GL/client/input/Mouse
    Utf8 => eka keyReleased = _keyReleased
    Utf8 => eka focusLost = _focusLost
    Utf8 => eka keyTyped = _keyTyped
    Utf8 => eka focusGained = _focusGained
    Utf8 => eka keyPressed = _keyPressed

    LDModel:
    oda implements org/GL/client/ModelLD
    getIndices1() => short[] oda.p
    getIndices2() => short[] oda.W
    getIndices3() => short[] oda.h
    getXPoints() => int[] oda.g
    getYPoints() => int[] oda.gb
    getZPoints() => int[] oda.eb

    LDRender:
    qca implements org/GL/client/LDRender

    Model:
    za implements org/GL/client/Model

    Mouse:
    Class => fl java.lang.Object = org/GL/client/input/Mouse
    Utf8 => m mouseDragged = _mouseDragged
    Utf8 => m mouseMoved = _mouseMoved
    Utf8 => m mouseClicked = _mouseClicked
    Utf8 => m mouseWheelMoved = _mouseWheelMoved
    Utf8 => m mouseEntered = _mouseEntered
    Utf8 => m mousePressed = _mousePressed
    Utf8 => m mouseReleased = _mouseReleased
    Utf8 => m mouseExited = _mouseExited
    getMouseDataList() => org.GL.client.NodeDeque m.n
    getLastMouseDataList() => org.GL.client.NodeDeque m.H
    getX() => int m.L
    getY() => int m.t
    getComponent() => java.awt.Component m.x
    isLoggingMouseMovements() => boolean m.K

    Node:
    ca implements org/GL/client/Node
    getId() => long ca.b
    getNext() => org.GL.client.Node ca.a
    getPrevious() => org.GL.client.Node ca.c

    NodeDeque:
    ita implements org/GL/client/NodeDeque
    getCurrent() => org.GL.client.Node ita.a
    getTail() => org.GL.client.Node ita.b

    NodeSub:
    vf implements org/GL/client/NodeSub
    getNextSub() => org.GL.client.NodeSub vf.d
    getPreviousSub() => org.GL.client.NodeSub vf.f

    NodeSubQueue:
    hua implements org/GL/client/NodeSubQueue
    getCurrent() => org.GL.client.NodeSub hua.b
    getTail() => org.GL.client.NodeSub hua.a

    OpenGLModel:
    nea implements org/GL/client/OpenGLModel

    OpenGLRender:
    mk implements org/GL/client/OpenGLRender

    Reference:
    ao implements org/GL/client/Reference
    getIndex() => int ao.g

    Render:
    l implements org/GL/client/Render

    SoftReference:
    tea implements org/GL/client/SoftReference
    getReference() => java.lang.ref.SoftReference tea.h

    SoftwareModel:
    p implements org/GL/client/SoftwareModel

    SoftwareRender:
    g implements org/GL/client/SoftwareRender

    StatusNode:
    uca implements org/GL/client/StatusNode
    getNext() => org.GL.client.StatusNode uca.a
    getPrevious() => org.GL.client.StatusNode uca.b

    StatusNodeList:
    ln implements org/GL/client/StatusNodeList
    getHead() => org.GL.client.StatusNode ln.b
    getNext() => org.GL.client.StatusNode ln.a

    StatusNodeSub:
    af implements org/GL/client/StatusNodeSub
    getNextSub() => org.GL.client.StatusNodeSub af.c
    getPreviousSub() => org.GL.client.StatusNodeSub af.d

    TileData:
    xa implements org/GL/client/TileData
    getHeights() => int[][] xa.j

    Viewport:
    hu implements org/GL/client/Viewport
    getXX() => float hu.j
    getXY() => float hu.f
    getXZ() => float hu.a
    getXOff() => float hu.b
    getYX() => float hu.e
    getYY() => float hu.i
    getYZ() => float hu.c
    getYOff() => float hu.g
    getZX() => float hu.k
    getZY() => float hu.l
    getZZ() => float hu.m
    getZOff() => float hu.h

    23.524 seconds.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •