0

I'm new to VBS. I am trying to get the timestamp of the last activity on the keyboard or mouse. This script will run on loop in backend and store the timestamps in a log.

I discovered these documentations but have no idea how to use them in my code:

KeyPress event

MouseDown, MouseUp events

My code will be something like:

Dim keyTS, mouseTS, nowTS

while(1)
    keyTS = 'some code to get the timestamp of last key pressed'
    mouseTS = 'some code to get the timestamp of the last time mouse was clicked'
    nowTS = Now 'stores the current timestamp at every loop

    ' store keyTS, mouseTS and nowTS in a log file
    wscript.sleep 60000 ' 1 min gap
wend
  • You [can't](https://stackoverflow.com/questions/16207461/visual-basic-script-keypress-detection) – Rno Mar 18 '23 at 20:35
  • Can you please suggest which tool I should use? Like Python or something? – Rounak Kumar Mar 21 '23 at 17:19
  • I'd do it in c# but that's because that's what I know best. – Rno Mar 22 '23 at 21:25
  • PowerShell may be an option. Here's a [PowerShell keylogger](https://gist.github.com/dasgoll/7ca1c059dd3b3fbc7277) to get started, but it only saves key strokes without any time stamps. – LesFerch Mar 22 '23 at 23:13

0 Answers0