I have the following situation. I have made some buttons that do actions but now I also want to make some keybindings. The problem is, that in the keybindings I'll have the same code from the buttons,and to avoid duplicating it I'd like to know how to emulate button pushes ,if possible(so that I can emulate the button pushes in the keybindings I want to make). I'm pretty sure I was able to do that on win32api. I remember I would do enumwindow and then findwindow and sendmessage WM_COMMAND or something similar(only difference was,that there I was trying to emulate press button on programs that were not made by me,here I have this perl script that I should be able to control much better). Can I do that here too , but in a simpler way , because I already have the object(the button).

More Clearly: How can one send events to a certain object in Perl/Tk ?

I'd also like to ask if possible about getting to a certain object if one only has access to the mainwindow of Tk.

If one only has access to a Tk main window how would it be possible to access objects on the Tk main window ? Would it be a good ideea to make a global hash in wich one puts references to all objects created ?


In reply to emulate Tk button push by spx2

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.