39 lines
1.1 KiB
AutoHotkey
39 lines
1.1 KiB
AutoHotkey
#Requires AutoHotkey v2.0
|
|
#SingleInstance Force
|
|
|
|
; Configuration
|
|
logFile := "MousePositions.log" ; Log file name
|
|
interval := 2000 ; 2 seconds in milliseconds
|
|
|
|
; Main timer
|
|
SetTimer LogMousePosition, interval
|
|
|
|
; Hotkey to stop the script (Ctrl+Alt+S)
|
|
^!s:: {
|
|
SetTimer LogMousePosition, 0 ; Turn off timer
|
|
MsgBox "Mouse logging stopped. Data saved to " logFile
|
|
ExitApp
|
|
}
|
|
|
|
LogMousePosition() {
|
|
; Get current mouse position (screen coordinates)
|
|
MouseGetPos &x, &y
|
|
|
|
; Get active window info
|
|
activeWin := WinGetTitle("A")
|
|
activeWin := activeWin ? activeWin : "No active window"
|
|
|
|
; Format: Timestamp | Screen X,Y | Window Title
|
|
logEntry := FormatTime(, "yyyy-MM-dd HH:mm:ss") " | " x "," y " | " activeWin
|
|
|
|
; Append to log file
|
|
try {
|
|
FileAppend logEntry "`n", logFile
|
|
} catch as e {
|
|
MsgBox "Error writing to log file: " e.Message
|
|
}
|
|
|
|
; Optional: Show tooltip with current position (for debugging)
|
|
ToolTip "Logged: " x "," y, x+20, y+20
|
|
SetTimer () => ToolTip(), -1000 ; Remove tooltip after 1 second
|
|
} |