473,287 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Using SendInput to emulate *double* click

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
6 15600
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Logan McKinley | last post by:
need my C# app to send a character to a different application. I believe I need to use the SendInput API call and to pass a KEYBDINPUT struct into that but I am lost past that point. Here is the...
5
by: Tim | last post by:
Hello All, I am writing a program that checks for the NumLock status and turns the NumLock on if it is off. I'm not sure what I'm overlooking at this point, but the code will compile and run, but...
1
by: Tim | last post by:
Hello All, I am writing a program that checks for the NumLock status and turns the NumLock on if it is off. I'm not sure what I'm overlooking at this point, but the code will compile and run, but...
1
by: kumar_subrahmanya | last post by:
Hi, I am facing problems in sending mouse clicks via SendInput API. Mouse clicks are being sent but at the X,Y co-ordinates. I am mapping my monitor to the (0,0,65535,65535) virtual monitor as...
1
by: ^Def_JaM^ | last post by:
I need a working sample of how to use the "SendInput" (as described in the WinAPI) method to emulate Unicode keystrokes. Most important is the fact that SendInput sample must be able to send Unicode...
3
by: John Dalberg | last post by:
I have an app that keeps popping up a windows with a 'Yes' or 'OK' button on it. I am trying to write a little app that automates hitting the enter key so I don't have to do it myself. I used...
2
by: =?Utf-8?B?TXJOb2JvZHk=?= | last post by:
I am trying to find a good example of SendInput. Doing a search on google I found two, one is incomplete and vague from the start and the other I copied the code and tried running it and it was...
14
by: Eugeny Myunster | last post by:
Hello all, How can i emulate sizeof() only for integers?
2
by: wkaibigan | last post by:
I have the following code Private Sub PictureBox_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Try Dim p As PictureBox = CType(sender, PictureBox) Dim filetemp As...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.