Jump to content

Script to kill process when mouse is idle for x amount of time.


Recommended Posts

I see.  Then my personal approach would be to hook the mouse with something like this:

Global $g_hStub_MouseProc = DllCallbackRegister("_MouseProc", "long", "int;wparam;lparam")
Global $hMod = _WinAPI_GetModuleHandle(0)
Global $g_hHook2 = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($g_hStub_MouseProc), $hMod)

Google those functions, you will get plenty of examples using them.

Link to post
Share on other sites
1 hour ago, Davidowicza said:

Start off by looking at MouseGetPos(), TimerInit(), and ProcessClose() functions.

Yep, those are the basics for what OP wants to achieve.  I would be careful though with MouseGetPos in that it is only valid as long as the mouse moves.  What if the mouse is clicked without moving or mouse wheel is used without moving ?  If OP is fine with it, then MouseGetPos is not a bad solution.  But to be honest, I think a hook is more robust as it will catch all activities on the mouse, whatever it is.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...