Created
May 7, 2025 18:15
-
-
Save 0mj/4711b1c1d8de8c11a2452899bffb4ffe to your computer and use it in GitHub Desktop.
ruby sendkeys during hours
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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