Files
Brandon Arvanaghi a8e41cba84 Restructured folders
2017-08-05 09:40:40 -04:00

34 lines
872 B
Ruby

#
# Checks if cursor is in same position after sleeping N seconds (default: 20 min), Ruby
# Module written by Brandon Arvanaghi
# Website: arvanaghi.com
# Twitter: @arvanaghi
#
require "Win32API"
secs = 1200
if ARGV.length == 1
secs = ARGV[0].to_i
end
def getPoint()
getCursorPos = Win32API.new("user32", "GetCursorPos", ['P'], 'L')
pt = "\0" * 8
getCursorPos.call(pt)
return pt.unpack('LL')
end
firstPoint = getPoint()
puts "x: " + firstPoint[0].to_s + ", y: " + firstPoint[1].to_s
sleep(secs)
secondPoint = getPoint()
puts "x: " + secondPoint[0].to_s + ", y: " + secondPoint[1].to_s
if firstPoint[0] - secondPoint[0] && firstPoint[1] - secondPoint[1] == 0
puts "The cursor has not moved in the last " + secs.to_s + " seconds. Do not proceed."
else
puts "The cursor is not in the same position as it was " + secs.to_s + " seconds ago. Proceed!"
end