views:

212

answers:

1

We are working on a module in which I gave the xpos, ypos, windowhandle. Now what I want to do is I want to raise the event for the corresponding input on (xpos, ypos, windowhandle).

For example:

The input given is to select a file means it will select a file automatically through my module.

00010086 PWM_LBUTTONDBCLK fwKeys:MK_LBUTTON xPos:273yPos:354

The event will look like the above.

+2  A: 

Pseudo code.. You can modify to suit your need...

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class Form1 : Form
{
   [DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
   public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);

   private const int MOUSEEVENTF_LEFTDOWN = 0x02;
   private const int MOUSEEVENTF_LEFTUP = 0x04;
   private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
   private const int MOUSEEVENTF_RIGHTUP = 0x10;

   public Form1()
   {
   }

   public void DoMouseClick()
   {
      //Call the imported function with the cursor's current position
      mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
   }

  //...other code needed for the application
}
lakshmanaraj
thru code i need to open file . for which i can give xpos, ypos.... is it possible....
RV
S, You can read and pass the function parameters to above mouseevent function, to generate the mouse event from user32.dll. Even you can send keystrokes as given in msdn.microsoft.com/en-us/library/ms171548.aspx
lakshmanaraj