我想将密钥发送到后台窗口。 在这种情况下,展望。 我有这个代码
[DllImport("user32.dll")]
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private void button1_Click(object sender, EventArgs e)
{
const uint WM_KEYDOWN = 0x100;
const uint WM_KEYUP = 0x0101;
string processName = "outlook";
Process[] processList = Process.GetProcesses();
foreach (Process P in processList)
{
if (P.ProcessName.Equals(processName))
{
IntPtr edit = P.MainWindowHandle;
PostMessage(edit, WM_KEYDOWN, (IntPtr)(Keys.LControlKey), IntPtr.Zero);
PostMessage(edit, WM_KEYDOWN, (IntPtr)(Keys.R), IntPtr.Zero);
PostMessage(edit, WM_KEYUP, (IntPtr)(Keys.R), IntPtr.Zero);
PostMessage(edit, WM_KEYUP, (IntPtr)(Keys.LControlKey), IntPtr.Zero);
}
}
}
这有什么问题?它应该在outlook中打开一个回复窗口,但事实并非如此。 此外,请不要回答与Outlook相关的具体内容,因为我想使用此方法来执行此操作。