English 中文(简体)
C# 后职业所需的图书馆是什么?
原标题:C# what is the necessary library for PostMessage?

我正试图模拟C#和Im中的一个关键词,以弄清这些错误:

Error   2   The name  WM_KEYDOWN  does not exist in the current context c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 28  52  HaxBot3
Error   5   The name  WM_KEYDOWN  does not exist in the current context c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 29  52  HaxBot3
Error   8   The name  WM_KEYDOWN  does not exist in the current context c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 30  52  HaxBot3
Error   9   The name  VK_RIGHT  does not exist in the current context   c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 30  64  HaxBot3
Error   3   The name  VK_CONTROL  does not exist in the current context c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 28  64  HaxBot3
Error   6   The name  VK_ALT  does not exist in the current context c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 29  64  HaxBot3
Error   1   The name  PostMessage  does not exist in the current context    c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 28  17  HaxBot3
Error   4   The name  PostMessage  does not exist in the current context    c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 29  17  HaxBot3
Error   7   The name  PostMessage  does not exist in the current context    c:usersfrkdocumentsvisual studio 2010ProjectsHaxBot3HaxBot3Form1.cs 30  17  HaxBot3

而这是造成错误的法典:

public static void Forward()
        {
            Process[] processes = Process.GetProcessesByName("test");

            foreach (Process proc in processes)
            {
                PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_CONTROL, 0);
                PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_ALT, 0);
                PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0);
            }
        }//Fprward

我猜想,我必须加上“条码”使用系统。 得到帮助。

最佳回答

你们需要界定这些决定因素。

[DllImport("user32.dll")]
public static extern bool PostMessage(IntPtr hWnd, uint msg, uint wParam, IntPtr lParam);

public const uint WM_KEYDOWN = 0x0100;
public const uint VK_RIGHT = 27;
public const uint VK_CONTROL = 11;
public const uint VK_ALT = 12;
问题回答

它是用户32。 Dll. http://www.pinvoke.net/default.aspx/user32.postmessage”rel=“nofollow”>。 http://www.ohchr.org。

此处为<代码>Forward(>>的一个实例类别为

public static class MyClass
{
  public static void Forward()
  {
     /* snip */
  }

  [return: MarshalAs(UnmanagedType.Bool)]
  [DllImport("user32.dll", SetLastError = true)]
  static extern bool PostMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签