Activate Button in other application
i wan to active start button in other app, i u开发者_JS百科se spy ++ to check the button styles, i c bs_pushbutton. i try to use win api to do it.i tried WM_SETFOCUS and enter key to do it, but fail
these is my code
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)
i declare BS_PUSHBUTTON = &H1&
it is correct value for BS_PUSHBUTTON ???
how can i run the app button event??
It's unclear exactly what you're asking for in this question. I'm not sure whether you're attempting to enable a button or emulate a click to it.
Anyway, for the former you simply need to use EnableWindow():
EnableWindow( cwnd, true );
Or alternatively:
Button_Enable( cwnd, true );
For the latter you can use SetActiveWindow() and BM_CLICK:
SetActiveWindow( hwnd );
SendMessage( cwnd, BM_CLICK, 0, 0 );
精彩评论