Jump to content
dergula

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

Recommended Posts

Is there a script available that can kill a process, or kill multiple processes after the mouse has been idle for a specific amount of time?

 

Thanks for any help.

Share this post


Link to post
Share on other sites

:welcome: Yes  there is multiple.  Just google it, and gather a few scripts.  If you still need help after, post the code you got, and we will look at it.

Share this post


Link to post
Share on other sites

Thanks for the response. I was googling, but only found some scripts for system idle. I was specifically looking foe mouse idle only.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

No, I was hoping to build a script that can kill a process(s) when the mouse has been idle for an x amount of time.

Share this post


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.

Share this post


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...