Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem Implementing mouse hook
#1
Is there a way to make a hook?

I am trying to make a window follows the pointer all the time, i have found a way to do that making a thread that starts with that dialog, for example using this:


Code:
Copy      Help
spe -1

rep
    if (moving=1)
        int px(xm) py(ym)
        mov (xm-30) (ym-95) act
    else
        break;

But there is a problem because it is running all the time, i've tried to use the variable 'moving' to start this thread and when that variable changes it stop with the break statement, however it reduces the performance of the computer by running all the time. So my question is that is there a way to implement a mouse movement hook?, i have seen a lot of information to do that with MFC, but it's still complicated making a library and so on.

I know that there are a lot of triggers but that triggers on QM detects only when i do a click(right or left) i just want to catch mose move event all the time (where is the cursor) on the screen, is there a way to do that without reducing performance? (maybe it is very closely asociated with the way QuickMacros detects 'screen' mouse coordinates at status bar all the time)

Thanks.
#2
thanks to:
I want to use mouse event..

Code to disable both keyboard and mouse temporarily


I am using this code that i take from your hook posts.


function:
WE_CreatedWindowInstall
Code:
Copy      Help
function [off]

dll user32 #SetWindowsHookEx idHook lpfn hmod dwThreadId
dll user32 #UnhookWindowsHookEx hHook
dll user32 #CallNextHookEx hHook ncode wParam !*lParam
def WH_MOUSE_LL 14
;Installs/uninstalls hooks that will call WE_CreatedWindowProc whenever an object is created.
;This function does not need to be modified.

int+ hook
if(off) if(hook) UnhookWindowsHookEx(hook); hook=0
else
    if(getopt(nthreads)>1) mes "Already running. If in QM, use Threads dialog to end thread. If in exe, thread will end automatically." "" "i"; ret
    hook=SetWindowsHookEx(WH_MOUSE_LL &WE_CreatedWindowProc _hinst 0)
    atend WE_CreatedWindowInstall 1
    opt waitmsg 1
    wait -1


function:

WE_CreatedWindowProc
Code:
Copy      Help
;/WE_Main
function nCode wParam MSLLHOOKSTRUCT*lParam

out lParam.pt.x




ret CallNextHookEx(hook nCode wParam lParam)

out lParam.pt.x will return the x mouse cordinates and wParam the action.
thanks for your previous posts.


Forum Jump:


Users browsing this thread: 1 Guest(s)