单击 Win32 SendMessage 中的单选按钮
Click Radio button from Win32 SendMessage
在 C# WPF 应用程序中,我试图单击卸载屏幕上的单选按钮以单击一次应用程序。
有 2 个单选按钮
- "Restore the application to its previous state."(这个勾选了
默认情况下)
- "Remove the application from this computer."(这是
一个我想检查)。
使用一些 Win32 API,我找到了单选按钮的句柄,然后单击它。不幸的是什么也没发生(单选按钮没有被选中)。在旁注上有一个确定按钮 window 我已成功点击。
我使用 Spy++ 检查当我手动单击单选按钮时传递了哪些消息,并将它们与我通过代码发送的消息进行比较(两者相同)。
我从代码发送的 Spy++ 消息
<00001> 000D1136 S BM_SETCHECK fCheck:BST_CHECKED
<00002> 000D1136 R BM_SETCHECK
当我使用鼠标单击单选按钮时发送的 Spy++ 消息
<00099> 000D1136 S BM_SETCHECK fCheck:BST_CHECKED
<00100> 000D1136 R BM_SETCHECK
下面是我用来点击单选按钮的代码片段。
[DllImport("User32.Dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);
private const int BST_CHECKED = 0x0001;
private const int BM_SETCHECK = 0x00F1;
public static void DoRadioButtonClick(IntPtr RadioButtonHandle)
{
SendMessage(RadioButtonHandle, BM_SETCHECK, BST_CHECKED, IntPtr.Zero);
}
通过向单选按钮发送鼠标按下事件解决了问题。
SendMessage(RadioButtonHandle, 513, 0x00000001, 0x000d0026);
513 = 鼠标按下消息
不确定其他两个值。
在 C# WPF 应用程序中,我试图单击卸载屏幕上的单选按钮以单击一次应用程序。
有 2 个单选按钮
- "Restore the application to its previous state."(这个勾选了 默认情况下)
- "Remove the application from this computer."(这是 一个我想检查)。
使用一些 Win32 API,我找到了单选按钮的句柄,然后单击它。不幸的是什么也没发生(单选按钮没有被选中)。在旁注上有一个确定按钮 window 我已成功点击。
我使用 Spy++ 检查当我手动单击单选按钮时传递了哪些消息,并将它们与我通过代码发送的消息进行比较(两者相同)。
我从代码发送的 Spy++ 消息
<00001> 000D1136 S BM_SETCHECK fCheck:BST_CHECKED
<00002> 000D1136 R BM_SETCHECK
当我使用鼠标单击单选按钮时发送的 Spy++ 消息
<00099> 000D1136 S BM_SETCHECK fCheck:BST_CHECKED
<00100> 000D1136 R BM_SETCHECK
下面是我用来点击单选按钮的代码片段。
[DllImport("User32.Dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);
private const int BST_CHECKED = 0x0001;
private const int BM_SETCHECK = 0x00F1;
public static void DoRadioButtonClick(IntPtr RadioButtonHandle)
{
SendMessage(RadioButtonHandle, BM_SETCHECK, BST_CHECKED, IntPtr.Zero);
}
通过向单选按钮发送鼠标按下事件解决了问题。
SendMessage(RadioButtonHandle, 513, 0x00000001, 0x000d0026);
513 = 鼠标按下消息 不确定其他两个值。