Thank you WJR for helping.
My problem all along has been getting the handle from the
program that I want to get data from. I have absolutely no
control over it. Program [A].
My program works with a mouse click but it is to slow to use.
So if an api requires hWnd from program A before I have retrieved it
I don't see how I can get around that. (ex: SetCapture)
Below is my latest attempt and it doesn't work.
I sign on to program A. Then sign on to program B.
Move the mouse over program A and right click and it doesn't
work. No error message is generated.
.const
POINT STRUCT
Px dd 0
Py dd 0
POINT ENDS
savehWnd dq 0
.WM_RBUTTONDOWN
cmp D[iMsg],WM_RBUTTONDOWN
jne >>.WM_LBUTTONDOWN
; GHSwh swh to control right mouse clicks
cmp b[GHSwh],0
jne >>.ClearForNextRound ; Player hit the Claim button
mov b[GHSwh],1 ; set to clear for next round
mov rax,Q[lParam] ; loword
and eax,0FFFFh
mov d[pt.Px],eax
mov rax,Q[lParam] ; hiword
shr eax,16
mov d[pt.Py],eax
;???? invoke WindowFromPoint, [pt.Px],[pt.Py] ; this should get
; the handle from program A
invoke GetCapture ; this should get the handle from program A
; but I don't know if the mouse is pointing to program A
mov [hWnd],rax
mov [savehWnd],rax ; Handle for program A
cmp q[savehWnd],0h
jne >>
;??????msg3 'WindowFromPoint failed',0
;msg3 'GetCapture failed',0
invoke MessageBox, NULL,addr msg3,addr msg3,MB_OK
cmp eax,IDOK
jne >>.GetOut
:
;? invoke ScreenToClient, [hWnd],addr pt
invoke ClientToScreen, [savehWnd],addr pt
cmp q[savehWnd],0h
jne >>
;msg1 db 'Client To Screen failed',0
invoke MessageBox, NULL,addr msg1,addr msg1,MB_OK
cmp eax,IDOK
jne >>.GetOut
:
ret
.WM_LBUTTONDOWN
cmp D[iMsg],WM_LBUTTONDOWN
jne >>.WM_PAINT