By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Using SendInput to emulate *double* click

P: n/a
I'm using P/Invoke to call SendInput (using code culled
from these newsgroups!) to send mouse events to a window.
But I'm unsure how to send double-clicks. A VB6 article I
saw on SendInput suggested simply queueing two click
events, but this is not working for me, regardless of the
delay I put between clicks. So give this as a click
(where INPUT is an appropriate structure for sending the
SendInput data):

public static void Click()
{
INPUT aInput = new INPUT();

aInput.type = INPUT_MOUSE;
aInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
aInput.mi.dwExtraInfo = 0;
aInput.mi.mouseData = 0;
aInput.mi.time = 0;

int aResult = SendInput(1, ref aInput, 28 );

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
bInput.mi.dwExtraInfo = 0;
bInput.mi.mouseData = 0;
bInput.mi.time = 0;

int bResult = SendInput(1, ref bInput, 28 );
}

The call:

Click();
Thread.Sleep(50);
Click();

Does not work no double-click is produced no matter if the
delay is 0, 50, 100 etc. How can I send a double-click?

TIA
Richard
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Could you tell me the idea behind simulating double click

Kalpesh

"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:0e****************************@phx.gbl...
I'm using P/Invoke to call SendInput (using code culled
from these newsgroups!) to send mouse events to a window.
But I'm unsure how to send double-clicks. A VB6 article I
saw on SendInput suggested simply queueing two click
events, but this is not working for me, regardless of the
delay I put between clicks. So give this as a click
(where INPUT is an appropriate structure for sending the
SendInput data):

public static void Click()
{
INPUT aInput = new INPUT();

aInput.type = INPUT_MOUSE;
aInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
aInput.mi.dwExtraInfo = 0;
aInput.mi.mouseData = 0;
aInput.mi.time = 0;

int aResult = SendInput(1, ref aInput, 28 );

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
bInput.mi.dwExtraInfo = 0;
bInput.mi.mouseData = 0;
bInput.mi.time = 0;

int bResult = SendInput(1, ref bInput, 28 );
}

The call:

Click();
Thread.Sleep(50);
Click();

Does not work no double-click is produced no matter if the
delay is 0, 50, 100 etc. How can I send a double-click?

TIA
Richard

Nov 13 '05 #2

P: n/a
I want to control a 'legacy' GUI that you must dbl-click
on in certain forms. This GUI will run on an undisturbed
server and has tolerance for failure. But it needs the
double-click event at certain points.

Richard
-----Original Message-----
Could you tell me the idea behind simulating double click

Kalpesh

"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in messagenews:0e****************************@phx.gbl...
I'm using P/Invoke to call SendInput (using code culled
from these newsgroups!) to send mouse events to a window. But I'm unsure how to send double-clicks. A VB6 article I saw on SendInput suggested simply queueing two click
events, but this is not working for me, regardless of the delay I put between clicks. So give this as a click
(where INPUT is an appropriate structure for sending the
SendInput data):

public static void Click()
{
INPUT aInput = new INPUT();

aInput.type = INPUT_MOUSE;
aInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
aInput.mi.dwExtraInfo = 0;
aInput.mi.mouseData = 0;
aInput.mi.time = 0;

int aResult = SendInput(1, ref aInput, 28 );

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
bInput.mi.dwExtraInfo = 0;
bInput.mi.mouseData = 0;
bInput.mi.time = 0;

int bResult = SendInput(1, ref bInput, 28 );
}

The call:

Click();
Thread.Sleep(50);
Click();

Does not work no double-click is produced no matter if the delay is 0, 50, 100 etc. How can I send a double- click?
TIA
Richard

.

Nov 13 '05 #3

P: n/a
Are you sure the structure is right? Can you post a copy of your
definition of the structure?

Jonathan Schafer
On Tue, 8 Jul 2003 05:36:59 -0700, "Richard A. Lowe"
<ch*****@yumspamyumYahoo.com> wrote:
I'm using P/Invoke to call SendInput (using code culled
from these newsgroups!) to send mouse events to a window.
But I'm unsure how to send double-clicks. A VB6 article I
saw on SendInput suggested simply queueing two click
events, but this is not working for me, regardless of the
delay I put between clicks. So give this as a click
(where INPUT is an appropriate structure for sending the
SendInput data):

public static void Click()
{
INPUT aInput = new INPUT();

aInput.type = INPUT_MOUSE;
aInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
aInput.mi.dwExtraInfo = 0;
aInput.mi.mouseData = 0;
aInput.mi.time = 0;

int aResult = SendInput(1, ref aInput, 28 );

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
bInput.mi.dwExtraInfo = 0;
bInput.mi.mouseData = 0;
bInput.mi.time = 0;

int bResult = SendInput(1, ref bInput, 28 );
}

The call:

Click();
Thread.Sleep(50);
Click();

Does not work no double-click is produced no matter if the
delay is 0, 50, 100 etc. How can I send a double-click?

TIA
Richard


Nov 13 '05 #4

P: n/a
Thanks Jonathan, I've pasted it below, however keep in
mind that other SendInput calls work as expected, both
single clicks AND mouse movements. My original assumption
was that double-clicks were a different type of input, but
then I saw the example where a double-click is created via
sending two clicks in rapid succession.

[StructLayout(LayoutKind.Explicit)]
public struct MOUSEINPUT
{
[FieldOffset(0)] public int dx; //
4
[FieldOffset(4)] public int dy; //
4
[FieldOffset(8)] public int mouseData; // 4
[FieldOffset(12)] public int dwFlags; //
4
[FieldOffset(16)] public int time; //
4
[FieldOffset(20)] public int dwExtraInfo; //
4
};
-----Original Message-----
Are you sure the structure is right? Can you post a copy of yourdefinition of the structure?

Jonathan Schafer
On Tue, 8 Jul 2003 05:36:59 -0700, "Richard A. Lowe"
<ch*****@yumspamyumYahoo.com> wrote:
I'm using P/Invoke to call SendInput (using code culled
from these newsgroups!) to send mouse events to a window.But I'm unsure how to send double-clicks. A VB6 article Isaw on SendInput suggested simply queueing two click
events, but this is not working for me, regardless of thedelay I put between clicks. So give this as a click
(where INPUT is an appropriate structure for sending the
SendInput data):

public static void Click()
{
INPUT aInput = new INPUT();

aInput.type = INPUT_MOUSE;
aInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
aInput.mi.dwExtraInfo = 0;
aInput.mi.mouseData = 0;
aInput.mi.time = 0;

int aResult = SendInput(1, ref aInput, 28 );

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
bInput.mi.dwExtraInfo = 0;
bInput.mi.mouseData = 0;
bInput.mi.time = 0;

int bResult = SendInput(1, ref bInput, 28 );
}

The call:

Click();
Thread.Sleep(50);
Click();

Does not work no double-click is produced no matter if thedelay is 0, 50, 100 etc. How can I send a double-click?

TIA
Richard


.

Nov 13 '05 #5

P: n/a
Actually, it's started working... funny, nothing changed :(
-----Original Message-----
Are you sure the structure is right? Can you post a copy of yourdefinition of the structure?

Jonathan Schafer
On Tue, 8 Jul 2003 05:36:59 -0700, "Richard A. Lowe"
<ch*****@yumspamyumYahoo.com> wrote:
I'm using P/Invoke to call SendInput (using code culled
from these newsgroups!) to send mouse events to a window.But I'm unsure how to send double-clicks. A VB6 article Isaw on SendInput suggested simply queueing two click
events, but this is not working for me, regardless of thedelay I put between clicks. So give this as a click
(where INPUT is an appropriate structure for sending the
SendInput data):

public static void Click()
{
INPUT aInput = new INPUT();

aInput.type = INPUT_MOUSE;
aInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
aInput.mi.dwExtraInfo = 0;
aInput.mi.mouseData = 0;
aInput.mi.time = 0;

int aResult = SendInput(1, ref aInput, 28 );

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
bInput.mi.dwExtraInfo = 0;
bInput.mi.mouseData = 0;
bInput.mi.time = 0;

int bResult = SendInput(1, ref bInput, 28 );
}

The call:

Click();
Thread.Sleep(50);
Click();

Does not work no double-click is produced no matter if thedelay is 0, 50, 100 etc. How can I send a double-click?

TIA
Richard


.

Nov 13 '05 #6

P: n/a
I searched through Google regarding SendInput and double-click. Every
post mentioned doing it the same way you were. I read in a couple of
posts that timing was an issue. This may be what you are
experiencing.

Jonathan Schafer

On Tue, 8 Jul 2003 14:38:49 -0700, "Richard A. Lowe"
<ch*****@yumspamyumYahoo.com> wrote:
Actually, it's started working... funny, nothing changed :(
-----Original Message-----
Are you sure the structure is right? Can you post a copy

of your
definition of the structure?

Jonathan Schafer
On Tue, 8 Jul 2003 05:36:59 -0700, "Richard A. Lowe"
<ch*****@yumspamyumYahoo.com> wrote:
I'm using P/Invoke to call SendInput (using code culled
from these newsgroups!) to send mouse events to awindow.But I'm unsure how to send double-clicks. A VB6 articleIsaw on SendInput suggested simply queueing two click
events, but this is not working for me, regardless ofthedelay I put between clicks. So give this as a click
(where INPUT is an appropriate structure for sending the
SendInput data):

public static void Click()
{
INPUT aInput = new INPUT();

aInput.type = INPUT_MOUSE;
aInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
aInput.mi.dwExtraInfo = 0;
aInput.mi.mouseData = 0;
aInput.mi.time = 0;

int aResult = SendInput(1, ref aInput, 28 );

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
bInput.mi.dwExtraInfo = 0;
bInput.mi.mouseData = 0;
bInput.mi.time = 0;

int bResult = SendInput(1, ref bInput, 28 );
}

The call:

Click();
Thread.Sleep(50);
Click();

Does not work no double-click is produced no matter ifthedelay is 0, 50, 100 etc. How can I send a double-click?

TIA
Richard


.


Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.