Skip to content

Instantly share code, notes, and snippets.

@0mj
Created May 7, 2025 18:15
Show Gist options
  • Select an option

  • Save 0mj/4711b1c1d8de8c11a2452899bffb4ffe to your computer and use it in GitHub Desktop.

Select an option

Save 0mj/4711b1c1d8de8c11a2452899bffb4ffe to your computer and use it in GitHub Desktop.
ruby sendkeys during hours
current_hour = Time.now.hour
i = 0
while current_hour < 17 && current_hour >= 8
# Using system command with a simple command-line utility
if RUBY_PLATFORM =~ /mswin|mingw|windows/
# For Windows using PowerShell SendKeys
system('powershell', '-Command', '(New-Object -ComObject WScript.Shell).SendKeys("{SCROLLLOCK}")')
else
# For Linux using xdotool (needs to be installed)
system('xdotool key Scroll_Lock')
end
print "#{rand(1...1000000) + i } "
i += 1
sleep 590
current_hour = Time.now.hour
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment