在其他应用程序中激活按钮

时间:2011-07-13 07:53:53

标签: vb.net winapi

我想在其他应用程序中激活启动按钮,我使用间谍++检查按钮样式,我c bs_pushbutton。我尝试使用win api来做它。我试过WM_SETFOCUS并输入密钥来做它,但是失败了

这些是我的代码

    Dim hwnd As Int32 = apiFindWindowEx(HWND_DESKTOP, 0, Nothing, "Open File -     Security Warning")
    Dim cwnd As Int32 = apiFindWindowEx(hwnd, 0, Nothing, "&Run")
    Dim i As Integer = SendMessage(cwnd, BS_PUSHBUTTON, 0, 0)

Dim hwnd As Int32 = apiFindWindowEx(HWND_DESKTOP, 0, Nothing, "Open File - Security Warning") Dim cwnd As Int32 = apiFindWindowEx(hwnd, 0, Nothing, "&Run") Dim i As Integer = SendMessage(cwnd, BS_PUSHBUTTON, 0, 0) 我宣布 它是BS_PUSHBUTTON ???的正确值

我怎样才能运行app按钮事件?

1 个答案:

答案 0 :(得分:0)

目前还不清楚你在这个问题中究竟要求什么。我不确定您是在尝试启用按钮还是模拟点击它。

无论如何,对于前者,您只需使用EnableWindow()

EnableWindow( cwnd, true );

或者:

Button_Enable( cwnd, true );

对于后者,您可以使用SetActiveWindow()BM_CLICK

SetActiveWindow( hwnd );
SendMessage( cwnd, BM_CLICK, 0, 0 );