.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How can I do virtual mouse click?

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :Windows Application

Hi all,

I have to do a virtual click on any position on window(I mean click by not use a mouse  ). How can I do that in C#?

Thank a lot.

View Complete Post

More Related Resource Links

Context Menu And Mouse Click Issue

Hello. I am trying to show a context menu at runtime on MouseRightButtonUp, while over a selected image. I also have left mouse button events set up for the selected image. For some reason I cannot get the context menu to show unless I click the left mouse button and while it is held down click the right mouse button and keep it down while I release the left mouse button, followed by releasing the right mouse button. I tested the MouseRightButtonUp event using a simple MessageBox and did not have any problems; it worked as expected when the right mouse button was released. Here is the code: //add behavior for right mouse on this image. img.MouseRightButtonUp += (sender, e) => { //Create Context Menu ContextMenu menu = new ContextMenu(); //img is an Image img.ContextMenu = menu; //Add context menu item MenuItem photoNewWindow = new MenuItem(); photoNewWindow.Header = "Open Original Image"; photoNewWindow.Click += OpenOriginal; //Add menu items to context menu menu.Items.Add(photoNewWindow); //change the current image currentImage = img; }; // add behavior for mouse click on this image. img.MouseLeftButtonUp += (sender, e) => { // left mouse stuff }; Thanks! 

mouse click event

there are many control lack this mouseclick event, though they have the mousedoubleclick. in this scenario: i click on obj1, holding the click, move it to obj2 and release the click you see here obj1 is mouse-down, but mouse-up is obj2 so, do you count there's a mouse click event happened here? if you count it, which object will you consider should receive the mouse click? or is there a better way/algorithm to handle this mouse click? in my view, there's no mouse click happen, unless the down and up are happened on same obj.

Open ContextMenuStrip on left mouse click on NotifyIcon

Hi,I was working with an application and faced this problem, I have this code :public partial class Form2 : Form    {        public Form2()        {            InitializeComponent();        }        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)        {            if (e.Button == MouseButtons.Left)            {                contextMenuStrip1.Show(this, Control.MousePosition); // Or any other overload            }        }        private void Form2_Load(object sender, EventArgs e)        {            notifyIcon1.Icon = Icon;        }    }Here, in design mode, i have set contextMenuStrip1 as notifyIcon1's ContextMenuStrip. When I right click on notifyIcon1, it opens the context menu and when I click somewhere else, it closes. But with my code opens the contextmenu on left click and when I open context menu that way, it shows in taskbar and doesn't close when I click some where else.In short, I want to open contextmenustrip when user left clicks and right clicks on the notifyicon and it works well with right click by default but not with left click. And I want to avoid using SendMessage to send left click message.Is there any way I can work this out?

Implement Mouse Click event in AxShockWaveFlash

Hi, I want to hide the AxShockWaveFlash control when I clck on it. public class myAxShockwaveFlash: AxShockwaveFlashObjects.AxShockwaveFlash { private const int WM_LBUTTONDOWN = 0x0201; protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_LBUTTONDOWN: { Visible = false; // I also tried SetVisibleCore(false); } break; } base.WndProc(ref m); } } There are no errors while debugging. Unfortunatelly the AxShockWaveFlash doesn't disappear. If I use methods instead that are defined direct in AxShockWaveFlash (like Play(), Stop(),...), the source code will work. Why does it not work?

OpenDialog box to open file with a double-mouse click

Hi, I am having a hard time trying to find an example that opens an opendialog box and allows the users to open the file with a Double-Click. Please help.   Thanks

Activity/State mouse double click

Hi, When I double click activity/state, the workflow designer sets that activity/state as root designer. Is there a way to  disable this behavior? Thank you

Suppress mouse click event following LostFocus


I have a Canvas which handles mouse click events. When the mouse is clicked it will pop up a TextBox at the position of the click. The TextBox subscribes to the LostFocus event and will make itself disappear when this event is fired.

What happens is: the user clicks, text box appears, user types, user clicks outside textbox (to finish the text entry process), the text box disappears, a new text box appears at the position of the click.

What I would like to happen: when the user clicks outside of the text box I would to suppress the click event so that the text box disappears and a new one does not appear.

Many thanks,


GridView and mouse double click Response.Redirect problem


VS 2005, AJAX 

I use gridview and I need single and double click for each row in gridview.

When I click once on a row, some action will execute (e.g. next button should be enabled) and when I double click the row there should be redirection to another page.

I used the code below for both single and double click  usage:


protected void GwContainers_RowDataBound(object sender, GridViewRowEventArgs e)
                if (e.Row.RowType == DataControlRowType.DataRow)
                    // Get the LinkButton control in the first cell

                    LinkButton singleClickButton = (LinkButton)e.Row.Cells[8].Controls[0];
                    // Get the javascript which is assigned to this LinkButton


Datagrid + Mouse right click event


I have a datagrid and it contains the list of files from the folder. I want to display the default window files right click options in right click on the filename.

That is when ever i right click the filename in the datagrid, a default windows right click pop up should appear.


Can anyone help me to sort this out. The project is in C#.

Thank you.

Saugat K.C.

Mouse Right Click Disabling in grid row



   Can one tell me how to disable Mouse rigth click in Grid row,please tell me how to handle it in xaml.

Thanks  in Advance

Isenabled property in WPF not working on mouse right click



   I set Isenabled =false on a paticular condition using trigger evry thing got disabled but mouse right click is working and Getting selected,can any one let me know how to resolve this issue.


Thanks in Advance

Disable Mouse Right click in datagrid


Hi Friends,

       Can any one Suggest,how to disable mouse right click in WPF Datagrid.


Thanks in Advance,


Right Mouse Click


I am working on a website that draws fractals on the screen. It was my intention that with a right mouse click the picture could be saved to the visitor's computer. But that I get an error message "filetype blocked".

The file is called test.jpg and is drawn to the screen as a bitmap. Could anybody tell me how to 'unblock' the right mouse click so that a visitor can save a picture he or she likes?

Maybe it would be possible to let people download the image? But how would that work?


(near) realtime measurement of mouse click intervals

I'm writing a application[net/wpf/c#] that is supposed to measure how fast an user clicks (responds) after hearing a word. Its called a Auditory Processing Speed Test (PST) and the average human speed is around 70-140ms. To get an idea of the precision of time intervals of mouse events generated, I wrote the following.

namespace WpfApplication1

    public partial class MainWindow : Window
        [DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")]
        public static extern uint MM_BeginPeriod (uint uMilliseconds);

        [DllImport("winmm.dll", EntryPoint = "timeEndPeriod")]
        public static extern uint MM_EndPeriod (uint uMilliseconds);

        System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch();

        public MainWindow ()

GridView Javascript Click Row and Ajax

This article shows 2 common tasks with the ASP.NET GridView: Binding a List (generic) of objects as DataSource and on clicking a row, getting the values of the selected row by a javascript function. In the example a List with User-objects is displayed. On clicking a row containing the data of a User-object, the Id of the object is used to get the address of the user by an Ajax-call and display it in a details-field.

How to highlight datagrid or GridView row on mouse over?

This article will show how you can Ajax with GridView to display popup messages when mouse moves over certain column. In the demo project I have added first column as an image column with a help icon in it. This kind of implements a feature that if you want more information about the row you can move mouse over this icon, a asynchronous request is sent to server for data about that row and when call returns the returned message is show as a popup message.

Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend