>#define GW_HWNDFIRST 0 >#define GW_HWNDLAST 1 >#define GW_HWNDNEXT 2 >#define GW_HWNDPREV 3 >#define GW_OWNER 4 >#define GW_CHILD 5 > >#define GWL_EXSTYLE -20 >#define GWL_STYLE -16 > >#define WS_EX_APPWINDOW 0x00040000 > >#define WS_VISIBLE 0x10000000 >#define WS_POPUP 0x80000000 > >#define WM_SETTEXT 0x000C >#define WM_GETTEXT 0x000D > >#define BM_CLICK 0x00F5 > > PROCEDURE ClickDlgButton(tvWind, tcButton) > LOCAL lhWndDialog, lhWnd, lcText, lnLen, lcBuff, llClicked > > IF VARTYPE(tvWind) = "N" > lhWndDialog = tvWind > ELSE > lhWndDialog = FindWindow(0, tvWind) > ENDIF > > IF lhWndDialog = 0 > RETURN .F. > ENDIF > > * Loop through controls until find the button > > lhWnd = GetWindow(lhWndDialog, GW_CHILD) > > llClicked = .F. > > DO WHILE lhWnd > 0 > lcBuff = SPACE(512) > lnLen = SendMessage(lhWnd, WM_GETTEXT, 512, @lcBuff) > lcText = LEFT(lcBuff, lnLen) > IF UPPER(CHRTRAN(lcText, "&", "")) == UPPER(tcButton) > = SetForegroundWindow(lhWndDialog) > = SendMessage(lhWnd, BM_CLICK, 0, 0) > llClicked = .T. > EXIT > ENDIF > > lhWnd = GetWindow(lhWnd, GW_HWNDNEXT ) > ENDDO > > RETURN llClicked > >>>I was trying to use FindWindowEx to get a handle to a button and then SendMessage to click on it but could not get it working. If that is corect approach could you help with that?