Hi!
Today I was playing with Iczelion's mouse hook tutorial for the first time. I wanted to show the mouse coordinates in my program, so I replaced this:
with this:
This code is only working when I move the mouse over my window, but as soon as I move the cursor to a non-client area, the mouse coordinates aren't changing any more.
What can I do to get the mouse coordinates all the time?:confused:
/Delight
Today I was playing with Iczelion's mouse hook tutorial for the first time. I wanted to show the mouse coordinates in my program, so I replaced this:
MouseProc proc nCode:DWORD,wParam:DWORD,lParam:DWORD
invoke CallNextHookEx,hHook,nCode,wParam,lParam
mov edx,lParam
assume edx:PTR MOUSEHOOKSTRUCT
invoke WindowFromPoint,.pt.x,.pt.y
invoke PostMessage,hWnd,WM_MOUSEHOOK,eax,0
assume edx:nothing
xor eax,eax
ret
MouseProc endp
invoke CallNextHookEx,hHook,nCode,wParam,lParam
mov edx,lParam
assume edx:PTR MOUSEHOOKSTRUCT
invoke WindowFromPoint,.pt.x,.pt.y
invoke PostMessage,hWnd,WM_MOUSEHOOK,eax,0
assume edx:nothing
xor eax,eax
ret
MouseProc endp
with this:
MouseProc proc nCode:DWORD,wParam:DWORD,lParam:DWORD
invoke CallNextHookEx,hHook,nCode,wParam,lParam
mov edx,lParam
assume edx:PTR MOUSEHOOKSTRUCT
invoke PostMessage,hWnd,WM_MOUSEHOOK,.pt.x,.pt.y ;wParam=x lParam=y
assume edx:nothing
xor eax,eax
ret
MouseProc endp
invoke CallNextHookEx,hHook,nCode,wParam,lParam
mov edx,lParam
assume edx:PTR MOUSEHOOKSTRUCT
invoke PostMessage,hWnd,WM_MOUSEHOOK,.pt.x,.pt.y ;wParam=x lParam=y
assume edx:nothing
xor eax,eax
ret
MouseProc endp
This code is only working when I move the mouse over my window, but as soon as I move the cursor to a non-client area, the mouse coordinates aren't changing any more.
What can I do to get the mouse coordinates all the time?:confused:
/Delight
Hello
The problem is that you took away the WindowFromPoint function.
Check out the Win32 Programmer?s Reference :
The WindowFromPoint function retrieves the handle of the window that contains the specified point.
HWND WindowFromPoint(
POINT Point // structure with point
);
The problem is that you took away the WindowFromPoint function.
Check out the Win32 Programmer?s Reference :
The WindowFromPoint function retrieves the handle of the window that contains the specified point.
HWND WindowFromPoint(
POINT Point // structure with point
);
Hejsan!
Thanks for your fast reply NoException, but I think you missunderstand my question....or maybe I wasn't clear enough....or maybe I don't understand your answer :) , but it's not a window handle I want, it's the cursor's coordinates on the screen.
/Delight
Thanks for your fast reply NoException, but I think you missunderstand my question....or maybe I wasn't clear enough....or maybe I don't understand your answer :) , but it's not a window handle I want, it's the cursor's coordinates on the screen.
/Delight
Sorry, I just misunderstood!
My computer crashed when I tried to change the files.
Maybe hooking is dangerous.:eek:
My computer crashed when I tried to change the files.
Maybe hooking is dangerous.:eek:
So...does anyone else know how to get the mouse coordinates using a mouse hook?????
/Delight
/Delight
you have to capture the mouse...
hm don't know the exact name of the api... i think
it was like SetCapture and ReleaseCapture...
edit: duh!... sorry, hook related... uhm i wrote a
similar prog back then... it wasn't so hard... just
play around a little bit... i will get through my
sources :)
ok... forget about hooks... just capture the mouse
at the start of your prog and wait for WM_MOUSEMOVE
msg's... don't forget to release the mouse...
hm don't know the exact name of the api... i think
it was like SetCapture and ReleaseCapture...
edit: duh!... sorry, hook related... uhm i wrote a
similar prog back then... it wasn't so hard... just
play around a little bit... i will get through my
sources :)
ok... forget about hooks... just capture the mouse
at the start of your prog and wait for WM_MOUSEMOVE
msg's... don't forget to release the mouse...
.IF UMSG == WM_MOUSEMOVE
mov ecx,lParam
movzx eax,cx
shr ecx,16
;eax=x ecx=y
Mob, I would like my program to receive a wm_mousemove message even if it's not in focus or if it's only shown in the system tray. To do that I think I must use a mouse hook. Am I right?
/Delight
/Delight
yeah but if you capture the mouse all mouse
input IS directed to your app without any hooks...
wtf, whats going on with me... just create a timer
and use GetCursorPos... no hooks, no capturing
no windows_messages...
input IS directed to your app without any hooks...
wtf, whats going on with me... just create a timer
and use GetCursorPos... no hooks, no capturing
no windows_messages...
Hi Delight
If you need to hook the mouse and get its position then this RadASM project will show a way to do it.
KetilO
If you need to hook the mouse and get its position then this RadASM project will show a way to do it.
KetilO
It's late, forgot the zip.