- Jun 30, 2014
- 13,739
- 5,216
I'm using PostMessage to send keys to third party software.. This code below works fine for Uppercase characters but when I send Lowercase it seems to send 3 of each character sent.
This is a cut down example of sending the "c" character. I know its not the software because it does the same in notepad.
What am i doing wrong here?
[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
staticextern bool PostMessage(IntPtr hWnd,uint msg,IntPtr wParam,IntPtr lParam);
constint WM_KEYDOWN =0x100;
constint WM_KEYUP =0x101;
constInt32 WM_CHAR =0x0102;
IntPtr val =newIntPtr((Int32)'c');
PostMessage(WindowHandle, WM_KEYDOWN, (IntPtr)(val -0x020),newIntPtr(0));
PostMessage(WindowHandle, WM_CHAR, (IntPtr)val,newIntPtr(0));
PostMessage(WindowHandle, WM_KEYUP, (IntPtr)(val -0x020),newIntPtr(0));
This is a cut down example of sending the "c" character. I know its not the software because it does the same in notepad.
What am i doing wrong here?
[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
staticextern bool PostMessage(IntPtr hWnd,uint msg,IntPtr wParam,IntPtr lParam);
constint WM_KEYDOWN =0x100;
constint WM_KEYUP =0x101;
constInt32 WM_CHAR =0x0102;
IntPtr val =newIntPtr((Int32)'c');
PostMessage(WindowHandle, WM_KEYDOWN, (IntPtr)(val -0x020),newIntPtr(0));
PostMessage(WindowHandle, WM_CHAR, (IntPtr)val,newIntPtr(0));
PostMessage(WindowHandle, WM_KEYUP, (IntPtr)(val -0x020),newIntPtr(0));