using vb6 is it possible to click buttons and forms on another running process programmatically ?
A:
Will these links help? http://www.vbforums.com/showthread.php?t=345259 and http://forums.devx.com/showthread.php?t=37153
kor_
2010-02-09 12:27:51
i found a better solution! use autoit.
bkbkbk
2010-02-09 20:22:24
+1
A:
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.
Paul Williams
2010-02-09 21:50:39
+1. For finding the hWnd, I recommend Karl E Peterson's excellent VB6 code sample FindPart, which finds hWnds based on searching for the window caption. http://vb.mvps.org/samples/FindPart/
MarkJ
2010-02-10 11:59:57