c# - 在 C# 中获取 Outlook 事件窗口句柄 hwnd

标签 c# outlook sendmessage hwnd

我想在 C# 中获取 Outlook 事件窗口句柄 (hwnd)。我想将此用于 SendMessage() 方法,该方法将 hwnd 作为第一个参数。 Outlook 已打开且未最小化。尝试这样做.. 动态 winHwnd= Globals.ThisAddIn.Application.ActiveWindow(); 由于类型不匹配而不起作用。即使我转换它也不起作用。有人可以建议我得到这个处理程序..

最佳答案

您可能想要使用 GetActiveWindow api 函数。

[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();

IntPtr handle = GetActiveWindow();

尝试最小化窗口以查看是否获得正确的句柄。

private const int SW_SHOWMINIMIZED = 2;

[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow)

ShowWindowAsync(hWnd, SW_SHOWMINIMIZED);

关于c# - 在 C# 中获取 Outlook 事件窗口句柄 hwnd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36788251/

相关文章:

ios - MSAL库登录无响应

python - 如何使用规则在 outlook 中触发 python 脚本?

javascript - 如何从网站向 Telegram APP 发送消息

c# - 如何批量更新 Entity Framework 中的记录?

c# - 在 Entity Framework 中使用 bindingSource 过滤器

python - 如何在 Outlook (2010) 全局地址列表中搜索多个姓名?

c++ - Windows Mobile WAP 唤醒

python - 将文本编码为 win32api.SendMessage() 的 WPARAM

c# - 如何从应用程序中删除(32 位) - 以任务管理器结尾

c# - 在 Linux 上使用 Jenkins 运行用 C# 编写的 NUnit 测试