Witam, próbuję ze symulować naciśniecie przycisku do innego programu. Nie wiem dlaczego ciągle wyskakują mi błędne argumenty. Chce aby w programie został naciśnięty klawisz "T" (jest to pewien skrót). Oto kod:
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
const int WM_KEYDOWN = 0x100;
IntPtr MainHandle = FindWindow("ahk_class SbFrameConEmul", "SMALL BUSINESS");
SendMessage(MainHandle, WM_KEYDOWN, Key.T, 0); // has some invalid arguments
Korzystam z:
SendMessage(
int hWnd, // handle to destination window
uint Msg, // message
long wParam, // first message parameter
long lParam // second message parameter
);
Dlaczego wiadomość musi być liczbą, i czym są dwa parametry (w,I)?