Program deletes it's code and types it into notepad :D

I used gem auto_click for this small project. Note: This code is useless
and made for learning purposes.

write.rb
#note: not all special characters implemented in this version
require ‘auto_click’
def write string, latency=0
for i in 0…string.length
c = string[i]
shift = false
shift = true if c == ‘"’
shift = true if c == ‘-’
shift = true if c == ‘#’
shift = true if c == c.upcase
key_down(‘shift’) if shift
key_stroke c
key_stroke(0xDE) if c == ‘"’
key_stroke(0xBD) if c == ‘_’
key_stroke(“num3”) if c == ‘#’
key_up(‘shift’) if shift
key_stroke(‘space’) if c==" "
key_stroke(“num#{c}”) if (“0”…“9”).include? c
key_stroke(0xDE) if c == ‘’’
key_stroke(0xBD) if c == ‘-’
key_stroke 0x0D if c == “\n”
key_stroke 0xBA if c == “;”
key_stroke 0xBC if c == “,”
key_stroke 0xBE if c == “.”
key_stroke 0xBB if c == “=”
key_stroke 0xBF if c == “/”

if latency.between?(0,5)
  sleep latency if c != " "
  sleep latency/5.0 if c == " "
end

end
end

perfect_loop.rb:
require_relative ‘write’; #allows to print strings by simulating
keystrokes;
mouse_move 770, 350; #moves mouse to notepad;
sleep 0.5; #no need to hurry;
left_click; #grants focus of notepad;
print “HELLO CONSOLE”
key_down 0xA2; #presses control;
key_stroke ‘a’ #CTRL-A to select everything;
key_up 0xA2; #releases control;
sleep 0.5; #allows humans to see all selected;
while line = gets do write line, 0.12; end;#types all this code;
sleep 0.5;
key_down 0xA2; #presses control;
key_stroke ‘s’ #CTRL-S to save file;
key_up 0xA2; #releases control;
sleep 0.5;
key_down 0x5B; #presses windows key;
key_stroke “num1”; #focus to windows console;
key_up 0x5B; #releases windows key;
sleep 0.5;
write “ruby perfect_loop.rb perfect_loop.rb”;#types into console;

Tell me what do you think about my video on youtube:
https://www.youtube.com/watch?v=PKpcpdM83oI

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs