简体   繁体   English

发送鼠标单击进行处理

[英]Send mouse click to process

I'm trying to accomplish sending a mouse click to a application. 我正在尝试将鼠标单击发送到应用程序。

I currently have: 我目前有:

    int hWnd = FindWindow(null, "Window Title Here");
            SendMessage(hwnd, 0x201, 0, 0); //Mouse left down
            SendMessage(hwnd, 0x202, 0, 0); //Mouse left up

I'm using 我正在使用

     [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
    static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

and

    [DllImportAttribute("User32.dll")]
    private static extern int FindWindow(String ClassName, String WindowName);

But I get errors, these are: 但我得到错误,这些是:

"The name 'hwnd' does not exist in the current context" “当前上下文中不存在名称'hwnd'”

How can I resolve this? 我该如何解决这个问题?

C# is case-sensitive. C#区分大小写。 hwnd and hWnd are different things. hwndhWnd是不同的东西。

There's already libraries doing that, Windows Input Simulator would be an example, if you can use it, it would save you from having to write this kind of code. 已有图书馆这样做, Windows Input Simulator就是一个例子,如果你可以使用它,它将使你不必编写这种代码。 See on CodePlex 请参阅CodePlex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM