For Programmers: Free Programming Magazines  


Home > Archive > Tcl > August 2006 > Virtual click on Windows









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Virtual click on Windows
Googie

2006-08-22, 8:01 am

Hi there!

Is there a way to generate virtual click at any coordinates on the
Windows Desktop? I mean something like:

I have some window (maeby TclTk, maeby not) with a button. I write:
event generate {} <Button-1> -x 200 -y 100
where 200x100 are coordinates of center of the button and this code
invokes the button, just pushes it.

Is it possible with any extension or something?

--
Pozdrawiam! (Greetings!)
Googie
suchenwi

2006-08-22, 8:01 am


Googie schrieb:

> Is there a way to generate virtual click at any coordinates on the
> Windows Desktop? I mean something like:
>
> I have some window (maeby TclTk, maeby not) with a button. I write:
> event generate {} <Button-1> -x 200 -y 100
> where 200x100 are coordinates of center of the button and this code
> invokes the button, just pushes it.
>
> Is it possible with any extension or something?


Aren't button bindings fired on ButtonRelease?

Michael Schlenker

2006-08-22, 8:01 am

Googie schrieb:
> Hi there!
>
> Is there a way to generate virtual click at any coordinates on the
> Windows Desktop? I mean something like:
>
> I have some window (maeby TclTk, maeby not) with a button. I write:
> event generate {} <Button-1> -x 200 -y 100
> where 200x100 are coordinates of center of the button and this code
> invokes the button, just pushes it.
>
> Is it possible with any extension or something?


See the twapi extension twapi.sf.net:
http://twapi.sourceforge.net/input.html

Michael
palmtcl@yahoo.com

2006-08-22, 8:01 am

For Tk windows you can just use Tk bindings. If the window is not a Tk
window, the TWAPI extension might be of help (http://twapi.sf.net). See
for example

http://twapi.sourceforge.net/opensy...thmouse.example - clicking on
a system menu of a window (very similar to what you want to do), or

http://twapi.sourceforge.net/sendmouseinput.example - driving MS Paint
with a mouse

/Ashok

Googie wrote:
> Hi there!
>
> Is there a way to generate virtual click at any coordinates on the
> Windows Desktop? I mean something like:
>
> I have some window (maeby TclTk, maeby not) with a button. I write:
> event generate {} <Button-1> -x 200 -y 100
> where 200x100 are coordinates of center of the button and this code
> invokes the button, just pushes it.
>
> Is it possible with any extension or something?
>
> --
> Pozdrawiam! (Greetings!)
> Googie


Donal K. Fellows

2006-08-22, 7:02 pm

Googie wrote:
> Is there a way to generate virtual click at any coordinates on the
> Windows Desktop? I mean something like:


Not with pure Tk. With pure Tk, you can only inject events into Tk's own
event queue, and not into the rest of the system. On the other hand, if
that is good enough there are a few other gotchas to watch out for when
clicking on buttons, namely that you need to generate the events in the
order: <Enter>, <ButtonPress>, <ButtonRelease>. This is because buttons
have to be primed to correctly respond to a press, and only actually
fire on release.

If you need to inject events into other apps, you need an extension.

Donal.
Emmanuel Frécon

2006-08-22, 7:02 pm

Googie wrote:
> Hi there!
>
> Is there a way to generate virtual click at any coordinates on the
> Windows Desktop? I mean something like:
>
> I have some window (maeby TclTk, maeby not) with a button. I write:
> event generate {} <Button-1> -x 200 -y 100
> where 200x100 are coordinates of center of the button and this code
> invokes the button, just pushes it.
>
> Is it possible with any extension or something?
>


You might also want to have a look my winop library, which offers an
abstraction on top of Tk and Windows. The ::winop::button does exactly
what you want, it will call the event generate if the handle passed to
it is a (local) tk control, or will generate the appropriate WM_ message
if the control is the handle of a (remote) windows/button.

http://www.sics.se/~emmanuel/?Code:winop
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com