Re: How can I emulate a mouse click event at a specific location in my code?
- From: "ying lcs" <yinglcs gmail com>
- To: mmassonnet gmail com
- Cc: gtk-list gnome org
- Subject: Re: How can I emulate a mouse click event at a specific location in my code?
- Date: Fri, 9 Nov 2007 10:05:01 -0600
On Nov 9, 2007 12:12 AM, <mmassonnet gmail com> wrote:
>
> On Thu, Nov 08, 2007 at 10:58:39PM -0600, ying lcs wrote:
> > On Nov 8, 2007 11:24 AM, <jcupitt gmail com> wrote:
> > > Hi,
> > >
> > > On 11/8/07, ying lcs <yinglcs gmail com> wrote:
> > > > How can I emulate a mouse click event at a specific location (x,y)in
> > > > my code so that my GTK application will response to it as if a user
> > > > has clicked at the same location?
> > >
> > > You can use the XTest extension to do this. Here's a bot that plays
> > > the flash game "zookeeper" by grabbing the screen, analysing the
> > > board, and generating click events:
> > >
> > > http://cima.ng-london.org.uk/~john/zoobot.c
> > >
> > > search for send_click().
> > >
> > > John
> >
> > Thanks. But can you please tell me how can I find the XTest extension?
> > When I do a google search, I only find this, but it is for Java?
> >
> > http://xtest.netbeans.org/
>
> He means XTest, a X11 extension:
> http://www.xfree86.org/current/xtest.html
>
Thank you. But i only have ' GtkWidget *', How can I get a get a
GdkWindow in order to use XTestFakeMotionEvent?
int
send_click( GdkWindow *window, int x, int y )
{
Display *xdisplay = GDK_WINDOW_XDISPLAY( window );
XTestFakeMotionEvent( xdisplay, gdk_x11_get_default_screen(),
window_x + ZOO_TILE_LEFT +
x * ZOO_TILE_WIDTH + ZOO_TILE_WIDTH / 2,
window_y + ZOO_TILE_TOP +
y * ZOO_TILE_HEIGHT + ZOO_TILE_HEIGHT / 2,
0 );
XTestFakeButtonEvent( xdisplay, 1, TRUE, 0 );
XTestFakeButtonEvent( xdisplay, 1, FALSE, 0 );
XFlush( xdisplay );
return( 0 );
}
> Mike
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]