Sorry but the discussion was accidentally become private.

---------- Forwarded message ----------
From: Matteo Landi <landima...@gmail.com>
Date: Sat, Dec 26, 2009 at 4:51 PM
Subject: Re: Simulate button press events
To: Michael Libby <michael.c.li...@gmail.com>


On Sat, Dec 26, 2009 at 3:22 PM, Michael Libby
<michael.c.li...@gmail.com> wrote:
> On Thu, Dec 24, 2009 at 6:39 PM, Matteo Landi <landima...@gmail.com> wrote:
>
>> as the subject says, I'm trying to synthesize mouse clicks over the
>> focused window (which is now owned by my application). Looking around
>> it seems that gtk offers only a way to move the cursor
>> (gdk_display_warp_pointer) but there is anything related to button
>> press. For the moment I'm using xlib for such a purpose, but I was
>> wondering if I could accompish my task only making use of gtk.
>
> For testing? There might be less fragile ways to interact with your UI
> for testing purposes. Setting specific x,y coordinates in your test
> code for mouse clicks may break if the layout of the UI changes.
>
> Simulating user interaction visually? Still fragile, but more worth
> the effort since you will already be computing the path the mouse
> needs to travel.

Well I'am creating to create a game sovler. Once my window is placed
over the grid of the game, the application starts to take shots of the
display, and move the mouse and clicks over the grid depending on the
content of the shot.

>
> In any case: Did you look at gdk_display_put_event () with a
> GdkEventButton? This has the ability to send type of mouse click,
> modifier keys, and x,y coords.

I'm reading its documentation right now, but it seems not work even
tought it's possible I'm using it wrong. Indeed when I create an event
I should insert the window which is going to receive the event: what
is it in my particular case? is the gdk_display_put_event going to
override this field inside my event object? Here is the code I'm
trying (python):

 def fake_button_press_event(self, x, y):
   event = gdk.Event(gdk.BUTTON_PRESS)
   event.x = 500.
   event.y = 500.
   event.button = 1

   gtk.gdk.display_get_default().put_event(event)


Thanks in advance.

> --
> Michael C. Libby
> www.mikelibby.com
>



--
Matteo Landi
http://www.matteolandi.net/



-- 
Matteo Landi
http://www.matteolandi.net/
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to