Page 1 of 1

how to write mouse hook procedure with all application !!

Posted: Sun Nov 13, 2005 3:39 am
by Nueng
I see this code

Code: Select all

#WM_CAPTURECHANGED=533 

Procedure WndProc(hhWnd, uMsg, wParam, lParam) 
Select uMsg 
    Case #WM_CAPTURECHANGED 
       Debug lParam 
       Debug "Mouse Capturechanged" 
       ProcedureReturn 0 
    Case #WM_LBUTTONDOWN
        MessageRequester("Left","ok")
        ProcedureReturn 0
    Case #WM_RBUTTONDOWN
        MessageRequester("Rightt","ok")
        ProcedureReturn 0
EndSelect 
ProcedureReturn DefWindowProc_(hhWnd,uMsg,wParam,lParam) 
EndProcedure 

hwnd = OpenWindow(1,10,10,300,300,#PB_Window_SystemMenu,"") 
SetCapture_(hwnd) 
SetWindowCallback(@WndProc()) 

Repeat 
   Select WaitWindowEvent() 
      Case #WM_LBUTTONDOWN  : A$ = "Left Mouse Button pressed" 
      Case #WM_LBUTTONUP    : A$ = "Left Mouse Button released" 
      Case #WM_MOUSEMOVE    : A$ = "Mouse has moved"      
      Case #PB_EventCloseWindow: End 
   EndSelect 
   SetWindowText_(hwnd, A$): 
ForEver 
but It's work in own application not for all application

can you introduce me to fix this problem...

thank you..

Posted: Sun Nov 13, 2005 11:03 am
by lexvictory
look for info on "hooks"

Posted: Tue Nov 15, 2005 8:56 pm
by mikecaliber
you can do a google search for microsoft virtual keycodes

not sure if this is what you need but it works for these instances:


If GetAsyncKeyState_(#VK_LBUTTON)<>0

will detect if the left mouse button is down, no matter which window has the focus. #VK_LBUTTON is the virtual key code. There are other keycodes for the mouse and for keyboard, etc.

There's more about mouse events at:

viewtopic.php?t=17492

hope this helps and if not, good luck-

best,
mike

Posted: Wed Nov 16, 2005 2:38 am
by Nueng
Thank you All :)