Well I figured it out, mostly. I thought that the event field of the hash was used for the event to send, but now I know it isn't. I'm not sure what it is for, perhaps an event ID.

The detail field is where you can specify what to send for a KeyPress event. But it's not the ASCII value, or even the X keysym (which, for letters, are mapped to ASCII anyway). The detail field actually takes a keycode, which is simply a number representing a certain keyboard key.

All the keys on a keyboard are coded according to your modmap, and it doesn't really have any relation to what the key being pressed is supposed to do, it just says "Key #25 was pressed". Internally, X translates the keycode (specific to your keyboard setup) to the keysym (portable across X), depending on what is in the state field, so that the statement becomes "The letter 'w' was given".

The state field tells what modifier keys should be taken into consideration. 0 means none, 1 means SHIFT (so you'd get 'W' instead of 'w'), etc. It's probably taken as a bit vector to specify combinations of SHIFT, ALT, CTRL, META, and SUPER, but I didn't test fully to find out which bit is which. I'm not exactly sure what the code field does, but it seems to be another indicator of the event type. 0 and 1 are invalid, 2 seems to work for keypresses, and anything higher doesn't seem to do anything (in my very limited testing) except for 15 and 18, which specify events for window notifications (focus in/out, and map/unmap I think).

The other fields are rather self-explanatory, except for sequence_number about which I have no idea. In this module, the time field can also be given 'CurrentTime', which does the obvious, although I'm not sure X cares about the time.

I'm still having a problem getting the event to be delivered to the correct window, but I haven't done extensive testing. Updates as they come.

PS. You can get a look at your modmap to find out your specific keycodes by using the command: xmodmap -pk


In reply to Re: Re: Re: SendEvent in X11::Protocol by kelan
in thread SendEvent in X11::Protocol by kelan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.