Tag: windows messages

使用PostMessage / SendMessage将密钥发送到c#IE WebBrowser

我试图在C#webbrowser控件和选项卡中自动填充值,然后输入并向上和向下按以在字段中移动。 这是我的PInvoke和包装函数。 我使用Spy ++在Internet Explorer中获取这些内容。 有人看到我的定义有什么问题吗? 我想使用Send和Post消息而不是SendInput,因为我不想要关注窗口… [DllImport(“user32.dll”)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); [DllImport(“user32.dll”)] static extern int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); const uint WM_KEYDOWN = 0x0100; const uint WM_KEYUP = 0x0101; const uint WM_CHAR = 0x0102; const int VK_TAB = 0x09; const int […]

当我用任务管理器杀死我的程序时,我收到了什么消息

所以我有一个C ++ DLL,我在我的c#应用程序中用于监视Windows消息。 我想知道是否发送了WM_CLOSE和WM_QUERYENDSESSION,因为我无法从C#应用程序中看到它。 如果我收到其中一条消息,我想用我的文件做一些清理,但问题是当我用TM杀死它时function不起作用。 它接缝我没有得到消息。 我认为问题是任务管理器向C#应用程序发送消息而不是c ++ dll。 一些代码: C ++: typedef void (*CLOSING_FUNCTION)(); CLOSING_FUNCTION myClosingFunction; typedef void (*SHUTDOWN_FUNCTION)(); SHUTDOWN_FUNCTION myShutdownFunction; LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CREATE: return 0; case WM_CLOSE: myClosingFunction(); return 0; case WM_QUERYENDSESSION: myShutdownFunction(); return 1; case WM_DESTROY: myClosingFunction(); PostQuitMessage(0); return 0; […]

C# – 捕获来自特定应用程序的Windows消息

我正在编写一个C#应用程序,它需要拦截另一个应用程序发出的Window Messages 。 编写我正在监控的应用程序的公司给我发了一些示例代码,但它是用C ++编写的,我真的不知道。 在C ++示例代码中,我得到了他们使用以下代码: UINT uMsg = RegisterWindowMessage(SHOCK_MESSAGE_BROADCAST); ON_REGISTERED_MESSAGE(WM_SHOCK_BROADCAST_MESSAGE, OnShockStatusMessage) LRESULT OnShockStatusMessage(WPARAM wParam, LPARAM lParam); 据我了解,这将从Windows中检索我们想要侦听的特定消息的Id。 然后我们要求C ++在拦截与Id匹配的消息时调用OnShockStatusMessage 。 经过一番研究后,我在C#中整理了以下内容 [DllImport(“user32.dll”, SetLastError = true)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport(“user32.dll”, SetLastError = true, CharSet = CharSet.Auto)] static extern uint RegisterWindowMessage(string lpString); private IntPtr _hWnd; // APS-50 class reference private […]