Check if mouse\\keyboard is active using Batch or PowerShell

让人想犯罪 __ 提交于 2019-12-06 21:38:34

As for the mouse movement, you could check the position of the pointer and calculate if there is a change over time.

$p1 = [System.Windows.Forms.Cursor]::Position
Start-Sleep -Seconds 5  # or use a shorter intervall with the -milliseconds parameter
$p2 = [System.Windows.Forms.Cursor]::Position
if($p1.X -eq $p2.X -and $p1.Y -eq $p2.Y) {
    "The mouse did not move"
} else {
    "The mouse moved"
}

As for the keys, you might want to try a similar technique utilizing the get-keystroke script (which is basically a keylogger).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!