win32ole

Internet Explorer COM automation: Converting numeric error code to string

感情迁移 提交于 2020-01-05 04:27:10
问题 I am writing some code for driving Internet Explorer from a Perl 5 program through Win32::OLE, and I am looking for ways to convert numeric status/error codes that are delivered back to the Perl program via events (such as NavigateError) into a somewhat more human-readable form. Is there some kind of library function that converts i.e. 0x800C0005L or -2146697211 to "INET_E_RESOURCE_NOT_FOUND" or something even more readable? I have tried Win32::FormatMessage() , but that seems to work only

sending ctrl+c using sendkeys in ruby

旧时模样 提交于 2020-01-02 16:54:27
问题 I need to close the command prompt window using sendkeys function, but when I used the below code it did not work as running of some betch file is in progress so its not taking these below options. require 'win32ole' system("start cmd.exe") sleep(5) # Create an instance of the Wscript Shell: wsh = WIN32OLE.new('Wscript.Shell') # Try to activate the command window: if wsh.AppActivate('cmd.exe') sleep(1) wsh.SendKeys('cd \\') wsh.SendKeys('{ENTER}') # change the directory path where mtn folder

how do you enumerate WIN32OLE available servers?

删除回忆录丶 提交于 2019-12-24 22:16:11
问题 Wasn't able to find an easy answer to this one... Anyway I've seen some WIN32OLE code like this: WIN32OLE.new("MSVidCtl.MSVidWebDVD.1") Which works. My question is, how is it possible (in any programming language) to have figured that string out? Like enumerating all the available servers or what not? My google fu failed me here. Thanks. -r More resources (some of which answer my question, I believe--not sure why I didn't see these before) How to list all ActiveX controls? axhelper looks nice

Ruby win32ole - how to pass a VARIANT parameter?

本秂侑毒 提交于 2019-12-24 03:58:06
问题 I am trying to automate the Windows Task Scheduler using Ruby. I am using Ruby 1.8 under Windows Vista. The RegisterTaskDefintion method of the TaskFolder object takes two VARIANT parameters for the username and password. Any attempt to pass a string into these parameters results in a 'method_missing' exception: This does not work: rootFolder.RegisterTaskDefinition("Task", newTask, TASK_CREATE_OR_UPDATE, 'user', 'password', TASK_LOGON_PASSWORD, nil) This works: rootFolder

Calling a C# .dll from Ruby via COM

吃可爱长大的小学妹 提交于 2019-12-24 03:26:35
问题 I'm trying to call a few methods from C# in my Ruby code. First, I am creating a .dll in Visual Studio 2008. I'm registering for COM interop when I build. To test out this new process, I created a simple little DivideTwo method in C#- public double DivideTwo(double a, double b) { return a / b; } In Ruby, I do the following: require 'win32ole' test=WIN32OLE.new('DllAttempt.CsharpDll') x=test.DivideTwo(5,5) puts x #x=1 I get all excited because I think I've gotten it to work! I decide to return

How to install win32ole for nodejs (i.e. making node-gyp work properly)

坚强是说给别人听的谎言 提交于 2019-12-24 00:37:19
问题 Sorry, I'm a newbie of nodejs. I'd like to try the package win32ole in nodejs under Windows7, but when I run the installation command npm install win32ole in a command prompt window opened as administrator, many errors pop up. My configuration is: Windows 7 64 bit (version 6.1.7601) Microsoft Visual Studio Express 2015 for Windows Desktop - ENU (imho having to install 20GB of software to try to make node-gyp work is like a certification of failure for a certain IT model) Microsoft .NET

Register a proxy/stub in HKEY_CURRENT_USER

醉酒当歌 提交于 2019-12-22 11:47:50
问题 The MIDL compiler generates code for a proxy/stub with registration routines that write to HKEY_LOCAL_MACHINE. Is there any way (preferably without hacking the MIDL-generated code and without bypassing all that generated code in favor of custom code) to register a MIDL-generated p/s in HKEY_CURRENT_USER? Also: Will this work if both the p/s and the COM server are registered per-user like this? I just found (after a very frustrating 48 hours) that a p/s registered machine-wide will not work

How do I retrieve a custom attribute in watir?

流过昼夜 提交于 2019-12-13 02:15:58
问题 I'm trying to retrieve the "onclick" attribute value from the below link: <a onclick="test" href="myurl">aaa</a> Using link.href works fine (So I know link is the correct object) however when using link.attribute_value("onclick") what I get is a win32 object (puts shows #<WIN32OLE:0x2cbdf10> instead of the "test" string). 回答1: If you don't get a neater solution, and it's a one off(If you can make sure the development process keeps this kind of testing in mind next time).Try: onclick_value

Ruby script to read the last filled cell in a column

你说的曾经没有我的故事 提交于 2019-12-12 17:26:38
问题 i need a ruby code to read the column a and find where does the last filled cell in the column ends.In the image uploaded the last filled data is i in cell "A21". i need to know this cell address through ruby code. 回答1: I would do using the Ruby stdlib WIN32OLE . require 'win32ole' # create an instance of the Excel application object excel = WIN32OLE.new('Excel.Application') # make Excel visible excel.visible = true # open the excel from the desired path wb=excel.workbooks.open("C:\\Users\

insert image in .doc using win32ole library of Ruby

戏子无情 提交于 2019-12-12 03:07:59
问题 As the Title suggests, i am trying to find how to insert image in MS Word(.doc file) using ruby Win32Ole api. I have tried the function InsertFile of Range Object but it seems, it is only made for inserting other doc file in our file in question. Does anyone know anything related to this . It will very helpful. 回答1: You can do this by calling the Document.InlineShapes.AddPicture() method. The following example inserts an image into the active document, before the second sentence. require