国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

目錄 搜尋
Ruby用戶指南 3、開始 4、簡單的例子 5、字符串 6、正則表達式 7、數(shù)組 8、回到那些簡單的例子 9、流程控制 10、迭代器 11、面向?qū)ο笏季S 12、方法 13、類 14、繼承 15、重載方法 16、訪問控制 17、單態(tài)方法 18、模塊 19、過程對象 20、變量 21、全局變量 22、實變量 23、局部變量 24、類常量 25、異常處理:rescue 26、異常處理:ensure 27、存取器 28、對象的初始化 29、雜項 RGSS入門教程 1、什么是RGSS 2、開始:最簡單的腳本 3、數(shù)據(jù)類型:數(shù)字 4、數(shù)據(jù)類型:常量與變量 5、數(shù)據(jù)類型:字符串 6、控制語句:條件分歧語句 7、控制語句:循環(huán) 8、函數(shù) 9、對象與類 10、顯示圖片 11、數(shù)組 12、哈希表(關聯(lián)數(shù)組) 13、類 14、數(shù)據(jù)庫 15、游戲?qū)ο?/a> 16、精靈的管理 17、窗口的管理 18、活動指令 19、場景類 Programming Ruby的翻譯 Programming Ruby: The Pragmatic Programmer's Guide 前言 Roadmap Ruby.new 類,對象和變量 容器Containers,塊Blocks和迭代Iterators 標準類型 深入方法 表達式Expressions 異常,捕捉和拋出(已經(jīng)開始,by jellen) 模塊 基本輸入輸出 線程和進程 當遭遇挫折 Ruby和它的世界 Ruby和Web開發(fā) Ruby Tk Ruby 和微軟的 Windows 擴展Ruby Ruby語言 (by jellen) 類和對象 (by jellen) Ruby安全 反射Reflection 內(nèi)建類和方法 標準庫 OO設計 網(wǎng)絡和Web庫 Windows支持 內(nèi)嵌文檔 交互式Ruby Shell 支持 Ruby參考手冊 Ruby首頁 卷首語 Ruby的啟動 環(huán)境變量 對象 執(zhí)行 結(jié)束時的相關處理 線程 安全模型 正則表達式 字句構造 程序 變量和常數(shù) 字面值 操作符表達式 控制結(jié)構 方法調(diào)用 類/方法的定義 內(nèi)部函數(shù) 內(nèi)部變量 內(nèi)部常數(shù) 內(nèi)部類/模塊/異常類 附加庫 Ruby變更記錄 ruby 1.6 特性 ruby 1.7 特性 Ruby術語集 Ruby的運行平臺 pack模板字符串 sprintf格式 Marshal格式 Ruby FAQ Ruby的陷阱
文字

Microsoft Windows Support



The three libraries documented in this chapter turn Ruby into a powerful and convenient Windows scripting language. Now you have the power to control your applications, but in a controlled, object-oriented environment.

class WIN32OLE
Parent: Object
Version: 1.6

Index:

connect const_load new [ ] [ ]= each invoke


require?'win32ole'
ie?=?WIN32OLE.new('InternetExplorer.Application')
ie.visible?=?true
ie.gohome

WIN32OLE provides a client interface to Windows 32 OLE Automation servers. See the tutorial description on page 164 for more information.

constants
WIN32OLE::VERSION Current version number

class methods
connect WIN32OLE.connect( aString ) -> wapi

Returns a new OLE automation client connected to an existing instance of the named automation server.

const_load WIN32OLE.const_load( wapi, [ aClass=WIN32OLE ] ) -> nil

Defines the constants from the specified automation server as class constants in aClass.

new WIN32OLE.new( aString ) -> wapi

Returns a new OLE automation client connected to a new instance of the automation server named by aString.

instance methods
[ ] wapi[ aString ] -> anObject

Returns the named property from the OLE automation object.

[ ]= wapi[ aString ] = aValue -> nil

Sets the named property in the OLE automation object.

each wapi.each {| anObj | block }

-> nil

Iterates over each item of this OLE server that supports the IEnumVARIANT interface.

invoke wapi.invoke ( aCmdString, [ args ]*) -> anObject

Invokes the command given in aCmdString with the given args. args may be a Hash of named parameters and values. You don't need to call invoke explicitly; this class uses method_missing to forward calls through invoke, so you can simply use the OLE methods as methods of this class.

class WIN32OLE_EVENT
Parent: Object
Version: 1.6

Index:

message_loop new on_event


This (slightly modified) example from the Win32OLE 0.1.1 distribution shows the use of an event sink.

require?'win32ole'

$urls?=?[]

def?navigate(url) ??$urls?<<?url end

def?stop_msg_loop ??puts?"IE?has?exited..." ??throw?:done end

def?default_handler(event,?*args) ??case?event ??when?"BeforeNavigate" ????puts?"Now?Navigating?to?#{args[0]}..." ??end end

ie?=?WIN32OLE.new('InternetExplorer.Application') ie.visible?=?TRUE ie.gohome ev?=?WIN32OLE_EVENT.new(ie,?'DWebBrowserEvents')

ev.on_event?{|*args|?default_handler(*args)} ev.on_event("NavigateComplete")?{|url|?navigate(url)} ev.on_event("Quit")?{|*args|?stop_msg_loop}

catch(:done)?{ ??loop?{ ????WIN32OLE_EVENT.message_loop ??} }

puts?"You?Navigated?to?the?following?URLs:?" $urls.each_with_index?do?|url,?i| ??puts?"(#{i+1})?#{url}" end

WIN32OLE_EVENT is used in conjunction with the WIN32OLE class to add callbacks for Windows 32 events.
class methods
message_loop WIN32OLE_EVENT.message_loop -> nil

Executes the Windows event loop, translating and dispatching events.

new WIN32OLE_EVENT.new ( anOle, aName ) -> wapi

Returns a new WIN32OLE_EVENT (an event sink) for the given WIN32OLE object and named event source. If aName is nil, it will attempt to use the default source and will raise a RuntimeError if it cannot find one.

instance methods
on_event wapi.on_event ( [ anEvent ] ) {| args | block }

-> nil

Defines a callback for the named anEvent. If anEvent is nil, then this callback is associated with all events. The block will be given any arguments appropriate for this event.

class Win32API
Parent: Object
Version: 1.6

Index:

new call Call


This example is from the Ruby distribution, in ext/Win32API:

require?'Win32API'

getCursorPos?=?Win32API.new("user32",?"GetCursorPos",?['P'],?'V')

lpPoint?=?"?"?*?8?#?store?two?LONGs getCursorPos.Call(lpPoint) x,?y?=?lpPoint.unpack("LL")?#?get?the?actual?values

print?"x:?",?x,?"\n" print?"y:?",?y,?"\n"

ods?=?Win32API.new("kernel32",?"OutputDebugString",?['P'],?'V') ods.Call("Hello,?World\n")

GetDesktopWindow?=?Win32API.new("user32",?"GetDesktopWindow",?[],?'L') GetActiveWindow?=?Win32API.new("user32",?"GetActiveWindow",?[],?'L') SendMessage?=?Win32API.new("user32",?"SendMessage",?['L']?*?4,?'L') SendMessage.Call(GetDesktopWindow.Call,?274,?0xf140,?0)

The Win32API module allows access to any arbitrary Windows 32 function. Many of these functions take or return a Pointer datatype---a region of memory corresponding to a C string or structure type.

In Ruby, these pointers are represented using class String, which contains a sequence of 8-bit bytes. It is up to you to pack and unpack the bits in the String. See the reference section for unpack on page 378 and pack on page 286 for details.
class methods
new Win32API.new( dllname, procname, importArray, export ) -> wapi

Returns a new object representing a Windows 32 API function. dllname is the name of the DLL containing the function, such as ``user32'' or ``kernel32.'' procname is the name of the desired function. importArray is an array of strings representing the types of arguments to the function. export is a string representing the return type of the function. Strings ``n'' and ``l'' represent numbers, ``i'' represent integers, ``p'' represents pointers to data stored in a string, and ``v'' represents a void type (used for export parameters only). These strings are case-insensitive.

instance methods
call wapi.call( [ args ]*) -> anObject

Calls this API function with the given arguments, which must match the signature specified to new.

Call wapi.Call( [ args ]*) -> anObject

Synonym for Win32API#call.


Extracted from the book "Programming Ruby - The Pragmatic Programmer's Guide"
Copyright
上一篇: 下一篇: