FUNCTION Test(cText)
LOCAL hWnd, oWnd, nTry:=0, cMyFile, cLink, cText_Esas
cText_Esas :="Test Button on Dialog"
cMyFile:="C:\fwh\samples\testbtnz.exe"
SHELLEXECUTE( 0, "open", cMyFile, 0, 0, 1 )
do while nTry<10 .AND. EMPTY(hWnd)
SysWait(1)
hWnd := FindWindow( 0, cText_Esas)
nTry++
Enddo
IF EMPTY(hWnd)
MsgAlert("Cannot find hWnd","Error")
RETURN
ENDIF
? hWnd, nTry
BringWindowToTop( hWnd )
SysWait(1)
Ob_MouseMove(hWnd, 100, 100)
Ob_LButtonDown(hWnd, 100, 100)
SysWait(.1)
Ob_LButtonUp(hWnd, 100, 100)
RETURN
FUNCTION Ob_MouseMove(hWnd, nYY, nXX)
LOCAL nX, nY, hCtrl, aPos
nX = nXX + GetWndRect( hWnd )[ 2 ]
nY = nYY + GetWndRect( hWnd )[ 1 ]
SetCursorPos( nX, nY )
hCtrl = WindowFromPoint( nX, nY )
LogFile( "TestJava.log", { "MM", nX, nY, hCtrl, GetClassName( hCtrl ) } )
aPos = ScreenToClient( hCtrl, { nX, nY } )
PostMessage( hCtrl, WM_MOUSEMOVE, aPos[ 1 ], aPos[ 2 ] )
RETURN
FUNCTION Ob_LButtonDown(hWnd, nYY, nXX)
LOCAL nX, nY, hCtrl, aPos
nX = nXX + GetWndRect( hWnd )[ 2 ]
nY = nYY + GetWndRect( hWnd )[ 1 ]
SetCursorPos( nX, nY )
hCtrl = WindowFromPoint( nX, nY )
LogFile( "TestJava.log", { "MD", nX, nY, hCtrl, GetClassName( hCtrl ) } )
aPos = ScreenToClient( hCtrl, { nX, nY } )
PostMessage( hCtrl, WM_LBUTTONDOWN, aPos[ 1 ], aPos[ 2 ] )
RETURN
FUNCTION Ob_LButtonUp(hWnd, nYY, nXX)
LOCAL nX, nY, hCtrl, aPos
nX = nXX + GetWndRect( hWnd )[ 2 ]
nY = nYY + GetWndRect( hWnd )[ 1 ]
SetCursorPos( nX, nY )
hCtrl = WindowFromPoint( nX, nY )
LogFile( "TestJava.log", { "MU", nX, nY, hCtrl, GetClassName( hCtrl ) } )
aPos = ScreenToClient( hCtrl, { nX, nY } )
PostMessage( hCtrl, WM_LBUTTONUP, aPos[ 1 ], aPos[ 2 ] )
RETURN