simulating mouse events

I use the following code to click the mouse using a button on the keyboard.
It works exactly once. Then I have to move the actual mouse. This seems to
reset something and I can again click only once by pressing the key on the
keyboard. Off course I want it to click every time I press the key.

I am wondering if somebody else encountered the problem before and can help
me?


void ClickButton(int button){

int screen;
SCREEN_INPUT buffer;

screen = qnx_name_locate(0,“qnx/screen”,0,NULL);
memset(&buffer, 0, sizeof(SCREEN_INPUT));

///click wherever the cursor is(relative and x=0 y =0)
buffer._id = 0xFFFF;
buffer.absolute = 0;
buffer.buttons = button;

Send(screen,&buffer,NULL,sizeof(SCREEN_INPUT),0);

}

After a bit of experimenting I found the answer. The answer is as easy and
as elusive as it can be. The first version of the code just presses the
button. It does not let go of it. A second event has to be sent to let go of
the button.

Here is a function to press a mouse button in QNX Windows.

////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
////Purpose: Clicks the mouse
//
///x and y are in pixels form the top left corner
//
///4 = left button
//
///2 = middle button
//
///1 = right button
//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////
void ClickButton(int x, int y, int button){

int screen;
SCREEN_INPUT buffer;

///get Window Manager
screen = qnx_name_locate(0,“qnx/screen”,0,NULL);
memset(&buffer, 0, sizeof(SCREEN_INPUT));

///as described in windows_input.h
buffer._id = 0xFFFF;
buffer.absolute = 1;
buffer.x = x;
buffer.y = y;
buffer.buttons = button;

///press
Send(screen,&buffer,NULL,sizeof(SCREEN_INPUT),0);
buffer.absolute = 0;
buffer.x = 0;
buffer.y = 0;
buffer.buttons = 0;
///let go
Send(screen,&buffer,NULL,sizeof(SCREEN_INPUT),0);
}




“Lorenz Prem” <Lorenz.Prem@guidant.com> wrote in message
news:9finat$m9v$1@inn.qnx.com

I use the following code to click the mouse using a button on the
keyboard.
It works exactly once. Then I have to move the actual mouse. This seems to
reset something and I can again click only once by pressing the key on the
keyboard. Off course I want it to click every time I press the key.

I am wondering if somebody else encountered the problem before and can
help
me?


void ClickButton(int button){

int screen;
SCREEN_INPUT buffer;

screen = qnx_name_locate(0,“qnx/screen”,0,NULL);
memset(&buffer, 0, sizeof(SCREEN_INPUT));

///click wherever the cursor is(relative and x=0 y =0)
buffer._id = 0xFFFF;
buffer.absolute = 0;
buffer.buttons = button;

Send(screen,&buffer,NULL,sizeof(SCREEN_INPUT),0);

}

really interesting,

It seems you are developing a ditto from MS Windows to QNX Windows GUI ?
(In this case I am sorry, I have misinterpreted your previous demands,
my advice was not wise).
Such application could save many older systems running under QNX4 and
QNX Windows, which has to be replaced because of incapability to be
accessed from user’s terminal using GUI. Nice idea!

Andy

Lorenz Prem <Lorenz.Prem@guidant.com> wrote:

After a bit of experimenting I found the answer. The answer is as easy and
as elusive as it can be. The first version of the code just presses the
button. It does not let go of it. A second event has to be sent to let go of
the button.

Here is a function to press a mouse button in QNX Windows.

////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
////Purpose: Clicks the mouse
//
///x and y are in pixels form the top left corner
//
///4 = left button
//
///2 = middle button
//
///1 = right button
//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////
void ClickButton(int x, int y, int button){

int screen;
SCREEN_INPUT buffer;

///get Window Manager
screen = qnx_name_locate(0,“qnx/screen”,0,NULL);
memset(&buffer, 0, sizeof(SCREEN_INPUT));

///as described in windows_input.h
buffer._id = 0xFFFF;
buffer.absolute = 1;
buffer.x = x;
buffer.y = y;
buffer.buttons = button;

///press
Send(screen,&buffer,NULL,sizeof(SCREEN_INPUT),0);
buffer.absolute = 0;
buffer.x = 0;
buffer.y = 0;
buffer.buttons = 0;
///let go
Send(screen,&buffer,NULL,sizeof(SCREEN_INPUT),0);
}



“Lorenz Prem” <> Lorenz.Prem@guidant.com> > wrote in message
news:9finat$m9v$> 1@inn.qnx.com> …
I use the following code to click the mouse using a button on the
keyboard.
It works exactly once. Then I have to move the actual mouse. This seems to
reset something and I can again click only once by pressing the key on the
keyboard. Off course I want it to click every time I press the key.

I am wondering if somebody else encountered the problem before and can
help
me?


void ClickButton(int button){

int screen;
SCREEN_INPUT buffer;

screen = qnx_name_locate(0,“qnx/screen”,0,NULL);
memset(&buffer, 0, sizeof(SCREEN_INPUT));

///click wherever the cursor is(relative and x=0 y =0)
buffer._id = 0xFFFF;
buffer.absolute = 0;
buffer.buttons = button;

Send(screen,&buffer,NULL,sizeof(SCREEN_INPUT),0);

}