RubyWin32Api Win32OLE】的更多相关文章

#ruby提供了多种运行外部程序的方法 #1.%x %x不需要使用引号包含. #2. system方法 #3.exec类似system但是会中断当前的代码执行 #system和exec不能捕获执行程序的输出. list=%x(dir d:\\) #捕获到输出结果 system('notepad') p 'system' exec('notepad') p 'exec'#被exec中断,不会执行下面的代码 require 'Win32API'#调用Win32api get_cur=Win32API…
Win32ole为标准Ruby发行版的一部分.Win32ole是访问Windows自动化的接口,可以让Ruby和Windows应用进行交互.具体说来Win32ole可以操作Word,Excel,IE,Outlook等. 以下均为代码片段 Word 创建一个Word文件 Ruby代码     require 'win32ole'     word = WIN32OLE.new('Word.Application')     word.visible=true #是否打开文件     word.Do…
ruby中的win32ole是一个标准库,使用的时候只要添加require 'win32ole'就行. 下面是一段模拟一个登陆的代码 require 'win32ole' ie = WIN32OLE.new('internetExplorer.application') ie.visible = true ie.navigate('www.***.cn') sleep(0.2) until ie.busy == false ie.Document.getElementById('loginId'…
require "win32ole" #包含库 ie = WIN32OLE.new('internetExplorer.Application') ie.visible = true #这个时候就可以看到一个ie的界面出来了 ie.navigate('http://mail.163.com') #转到这个页面 sleep(0.1) until ie.busy == false #sleep 直到ie.busy为false 页面完全载入为止 ie.Document.getElementB…
Similar Threads 1. WIN32OLE - failed to create WIN32OLE 2. WIN32OLE#[] and WIN32OLE#[]= method in Ruby 1.9 (or later)  For example,    excel = WIN32OLE.excel("Excel.Application")   excel["Visible"] = true is NG. Instead, You must write…
class WIN32OLE   def list_ole_methods     method_names = ole_methods.collect {|m| m.name}     puts method_names.sort.uniq   end end WIN32OLE.new('Shell.Application').list_ole_methods   得到如下方法: AddRef AddToRecent Application BrowseForFolder CanStartSt…
一.为什么选择Ruby []完全开源. []多平台:Ruby可以运行在Linux, UNIX, Windows, MS-DOS, BeOS, OS/.. []多线程:线程就是指在一个程序中处理若干控制流的功能.与OS提供的进程不同的是,线程可以共享内存空间. []完全面向对象. []不需要内存管理:具有垃圾回收(Garbage Collect, GC)功能,能自动回收不再使用的对象. []解释执行:其程序无需编译即可轻松执行. []功能强大的字符串操作/正则表达式. []具有异常处理功能. []…
# -*-coding:utf-8 -*-#author:kanlijunrequire 'win32ole'require 'fileutils'class ResultAnalyse @@i=0 @@f=0 def initialize path excel =WIN32OLE.new('excel.application') @workbook =excel.WorkBooks.open(path) @worksheet=@workbook.Worksheets(1) end #获取exc…
watir自动化捕获上传图片元素: require 'watir' include Watir require 'test/unit' class TC_recorded < Test::Unit::TestCase def test_recorded puts "First Line" ie=Watir::IE.new puts "Open IE" ie.goto("http://localshot:8082") ie.file_fiel…
测试工作中,批量的数据通常会放到excel表格中,测试输出的数据写回表格中,这样输入输出易于管理,同时清晰明了 使用ruby来操作excel文件首先需要在脚本里包含以下语句 require'win32ole' 把win32ole包含进来后,就可以通过和windows下的excelapi进行交互来对excel文件进行读写了. 打开excel文件,对其中的sheet进行访问: excel =WIN32OLE::new('excel.Application') workbook =excel.Work…