Is it possible to track activity / idle time on a given monitor?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
aboose
Posts: 2
Joined: 05 Jun 2023, 18:09

Is it possible to track activity / idle time on a given monitor?

Post by aboose » 05 Jun 2023, 23:16

Code: Select all

#Requires AutoHotkey v2.0
app      := 'C:\Program Files\Nookkin\MultiscreenBlank2\MultiscreenBlank2.exe'
F13::Run app ' /toggledim75 id \\.\DISPLAY3 '
+F13::Run app ' /toggledim75 group 1 '
F14::Run app ' /toggle id \\.\DISPLAY3 '
F15::Run app ' /toggle group 1 '
Currently I have this code. I have 3 monitors.

Primary monitor: \\.\DISPLAY1
Second Monitor: \\.\DISPLAY2 (part of group 1)
Third Monitor: \\.\DISPLAY3 (part of group 1)

This program has the ability to blank out/dim monitors using command line functions. Someone kindly helped me figure out how to bind these functions to keys as shown above, now when I hit F13, I can dim my 3rd monitor, or shift F13 to dim both 2 and 3 in group 1.

My ultimate goal is to make a script that detects mouse movement on a given monitor. The desired example end state is for DISPLAY3 to blank itself (via Run app ' /toggle id \\.\DISPLAY3 ') after 60 seconds of no mouse movement or activity detected on the screen.

EG:

If there is no mouse movement / activity detected on monitor 3 for 60 seconds, then automatically run the following line: Run app ' /toggle id \\.\DISPLAY3 '

I have no clue if this kind of advanced monitoring is possible. And if it is possible, is it resource intensive.

Anyway, thanks for reading, and appreciate any advice, whether its the solution or just a comment that it's not easy/possible.

Rohwedder
Posts: 7613
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Is it possible to track activity / idle time on a given monitor?

Post by Rohwedder » 06 Jun 2023, 09:51

Hallo,
create a Timer SetTimer that checks every second (1000 ms) if the cursor is on area of monitor 3 CoordMode "Mouse", "Screen"
MouseGetPos &x, &y
and remembers when it was there the last time. If this time is more than 1 minute ago, then monitor 3 off.
This determined and shows the areas of your monitors:

Code: Select all

#Requires AutoHotkey v2.0
MonitorCount := MonitorGetCount()
Left :=[], Top :=[], Right :=[], Bottom :=[]
Left.length := Top.length := Right.length := Bottom.length := MonitorCount
Loop MonitorCount {
    MonitorGetWorkArea(N := A_Index, &Var1, &Var2, &Var3, &Var4)    
    Left[N] := Var1, Top[N] := Var2, Right[N] := Var3, Bottom[N] := Var4
    MsgBox "Monitor:`t#" N "`nLeft: " Left[N] "`t`tTop: "
    . Top[N] "`nRight: " Right[N] "`tBottom: " Bottom[N]
}

Post Reply

Return to “Ask for Help (v2)”