Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C应用程序双击另一个windows应用程序_C#_Sendmessage_Postmessage_Sendinput - Fatal编程技术网

C# 使用C应用程序双击另一个windows应用程序

C# 使用C应用程序双击另一个windows应用程序,c#,sendmessage,postmessage,sendinput,C#,Sendmessage,Postmessage,Sendinput,我需要使用SendMessage或PostMessage通过C应用程序左键单击、右键单击和双击另一个基于windows的应用程序。 我能够使用FindWindow方法找到窗口句柄,现在我需要发送/发布另一个应用程序的消息,如左键单击给定的x,y位置,右键单击给定的x,y位置,双击传递给定的x,y位置。 请帮忙。谢谢你可以使用我从一家公司偷来的这个片段。威奇是从他家偷来的 感谢您的回复,但这里没有使用窗口句柄,那么它将如何自动单击到另一个应用程序?谢谢 using System; using Sy

我需要使用SendMessage或PostMessage通过C应用程序左键单击、右键单击和双击另一个基于windows的应用程序。 我能够使用FindWindow方法找到窗口句柄,现在我需要发送/发布另一个应用程序的消息,如左键单击给定的x,y位置,右键单击给定的x,y位置,双击传递给定的x,y位置。
请帮忙。谢谢

你可以使用我从一家公司偷来的这个片段。威奇是从他家偷来的


感谢您的回复,但这里没有使用窗口句柄,那么它将如何自动单击到另一个应用程序?谢谢
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(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
       //Mouse actions
       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
          uint X = (uint)Cursor.Position.X;
          uint Y = (uint)Cursor.Position.Y;
          mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
       }

       //...other code needed for the application
    }