473,804 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.dwFla gs = MOUSEEVENTF_LEF TDOWN;
aInput.mi.dwExt raInfo = 0;
aInput.mi.mouse Data = 0;
aInput.mi.time = 0;

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

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFla gs = MOUSEEVENTF_LEF TUP;
bInput.mi.dwExt raInfo = 0;
bInput.mi.mouse Data = 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 15646
Could you tell me the idea behind simulating double click

Kalpesh

"Richard A. Lowe" <ch*****@yumspa myumYahoo.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.dwFla gs = MOUSEEVENTF_LEF TDOWN;
aInput.mi.dwExt raInfo = 0;
aInput.mi.mouse Data = 0;
aInput.mi.time = 0;

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

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFla gs = MOUSEEVENTF_LEF TUP;
bInput.mi.dwExt raInfo = 0;
bInput.mi.mouse Data = 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*****@yumspa myumYahoo.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.dwFla gs = MOUSEEVENTF_LEF TDOWN;
aInput.mi.dwExt raInfo = 0;
aInput.mi.mouse Data = 0;
aInput.mi.time = 0;

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

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFla gs = MOUSEEVENTF_LEF TUP;
bInput.mi.dwExt raInfo = 0;
bInput.mi.mouse Data = 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*****@yumspa myumYahoo.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.dwFla gs = MOUSEEVENTF_LEF TDOWN;
aInput.mi.dwExt raInfo = 0;
aInput.mi.mouse Data = 0;
aInput.mi.time = 0;

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

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFla gs = MOUSEEVENTF_LEF TUP;
bInput.mi.dwExt raInfo = 0;
bInput.mi.mouse Data = 0;
bInput.mi.time = 0;

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

The call:

Click();
Thread.Sleep(5 0);
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(La youtKind.Explic it)]
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*****@yumsp amyumYahoo.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.dwFla gs = MOUSEEVENTF_LEF TDOWN;
aInput.mi.dwExt raInfo = 0;
aInput.mi.mouse Data = 0;
aInput.mi.time = 0;

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

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFla gs = MOUSEEVENTF_LEF TUP;
bInput.mi.dwExt raInfo = 0;
bInput.mi.mouse Data = 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*****@yumsp amyumYahoo.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.dwFla gs = MOUSEEVENTF_LEF TDOWN;
aInput.mi.dwExt raInfo = 0;
aInput.mi.mouse Data = 0;
aInput.mi.time = 0;

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

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFla gs = MOUSEEVENTF_LEF TUP;
bInput.mi.dwExt raInfo = 0;
bInput.mi.mouse Data = 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*****@yumspa myumYahoo.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*****@yums pamyumYahoo.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.dwFla gs = MOUSEEVENTF_LEF TDOWN;
aInput.mi.dwExt raInfo = 0;
aInput.mi.mouse Data = 0;
aInput.mi.time = 0;

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

INPUT bInput = new INPUT();

bInput.type = INPUT_MOUSE;
bInput.mi.dwFla gs = MOUSEEVENTF_LEF TUP;
bInput.mi.dwExt raInfo = 0;
bInput.mi.mouse Data = 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
6289
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 code I have struct KEYBDINPUT { public short wVk; //the actual key public short wScan; //not needed public int dwFlags; //not needed public int time; //not needed
5
5111
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 the SendInput call always returns "0". Here is some of the code: Beginning of Code... static extern uint SendInput(uint nInputs, ref INPUT pInputs, int cbSize);
1
1972
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 the SendInput call always returns "0". Here is some of the code: Beginning of Code... static extern uint SendInput(uint nInputs, ref INPUT pInputs, int cbSize);
1
2328
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 needed by the SendInput. But the mouse clicks are always reported at the "current cursor location" (I am testing it with the notepad) irrespective of the X,Y co-ordinates specified.
1
5501
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 strings even when the according keyboard layout isn't loaded or not present. For example, with the old SendKeys method I used to write "SendKeys ChrW(932)" to send a greek character. I' ve not been able to do this with SendInput.
3
29917
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 the FindWindow method to get a handle of the window and then issued: SendMessage(hwnd, 273, 0, IntPtr.Zero) to send an ENTER key to it but it didn't work. If I need to get the handle of the 'OK' button, how do I do it? (How do you
2
9490
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 first of all incomplete (compiler errors) which I had to resolve by guessing on some things like how some variables were instantiated, and then finally it doesn't work. Ok, maybe I guessed wrong, but I shouldn't be guessing on what the code should...
14
1727
by: Eugeny Myunster | last post by:
Hello all, How can i emulate sizeof() only for integers?
2
3280
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 String filetemp = Replace(p.Tag, "Thumb", "jpg") If Me.UseEditor = True Then System.Diagnostics.Process.Start(filetemp)
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.