Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Ruby Autoit script to handle javascript popups

Run this code to take care of any javascript popups or security confirmations. It will always click "OK".

require 'win32ole'

begin
  autoit = WIN32OLE.new('AutoItX3.Control')
    
  loop do
   autoit.ControlClick("Microsoft Internet Explorer",'', 'OK')
   autoit.ControlClick("Security Information",'', '&Yes')
   autoit.ControlClick("Security Alert",'', '&Yes')
   sleep(5)
  end
       
rescue Exception => e
  puts e
end


If you are using this as part of a script, you can include it using this structure.

require 'win32/process'

  @pid = Process.create(
          :app_name       => 'ruby clicker.rb', #assuming you make the above script into a file called clicker.rb
          :creation_flags  => Process::DETACHED_PROCESS
      ).process_id
     
at_exit{ Process.kill(9,@pid) }
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed