开发者

vb6: how to click buttons on another running process?

开发者 https://www.devze.com 2022-12-19 10:18 出处:网络
using vb6 is it possible to click buttons and for开发者_高级运维ms on another running process programmatically ?Look at the SendMessage() API call. This is what Windows itself uses to notify a button

using vb6 is it possible to click buttons and for开发者_高级运维ms on another running process programmatically ?


Look at the SendMessage() API call. This is what Windows itself uses to notify a button it has been clicked.

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

E.g. retval = SendMessage(hwndButton, BM_CLICK, ByVal CLng(0), ByVal CLng(0))

Tricky bit is getting the window handle of the button (hwndButton). FindWindow() and EnumChildWindows() APIs will do this. FindWindow() will return the handle of the top-level windows (e.g. Notepad). Then EnumChildWindows can be used to iterate the controls until the correct button is found.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号