Can I write text to a notepad and save the file through ruby

Hi,

After invoking notepad through ruby, I wanted to know if I could type
some text in that notepad (which was just invoked using `notepad`) and
save it using a ruby code.

Can anyone please help me with the ruby code in this regard?

Thanks,
Anukul

···

--
Posted via http://www.ruby-forum.com/.

Anukul Singhal wrote:

Hi,

After invoking notepad through ruby, I wanted to know if I could type
some text in that notepad (which was just invoked using `notepad`) and
save it using a ruby code.

Can anyone please help me with the ruby code in this regard?

Look into a free tool called AutoItX. It is a COM and DLL thing that you can script to drive Win32 applications.

You can use Ruby's Win32OLE lib to load the COM object, then control it using Ruby code instead of the AutoIt scripting language.

···

--
James Britt

"In physics the truth is rarely perfectly clear, and that is certainly
  universally the case in human affairs. Hence, what is not surrounded by
  uncertainty cannot be the truth."
  - R. Feynman

Anukul Singhal wrote:

Hi,

After invoking notepad through ruby, I wanted to know if I could type
some text in that notepad (which was just invoked using `notepad`) and
save it using a ruby code.

Can anyone please help me with the ruby code in this regard?

Thanks,
Anukul

Do you really need to invoke notepad? Why not just write the text to the
file directly?

File.open('foo.txt','w') do |out|
  out << 'some text to write to the file, blah blah blah'
end

···

--
Posted via http://www.ruby-forum.com/\.

kind regards -botp

···

On Thu, Mar 20, 2008 at 11:31 PM, Anukul Singhal <anukul.singhal@gmail.com> wrote:

After invoking notepad through ruby, I wanted to know if I could type
some text in that notepad (which was just invoked using `notepad`) and
save it using a ruby code.

Drew Olson wrote in post #648910:

Anukul Singhal wrote:

Hi,

After invoking notepad through ruby, I wanted to know if I could type
some text in that notepad (which was just invoked using `notepad`) and
save it using a ruby code.

Can anyone please help me with the ruby code in this regard?

Thanks,
Anukul

Do you really need to invoke notepad? Why not just write the text to the
file directly?

File.open('foo.txt','w') do |out|
  out << 'some text to write to the file, blah blah blah'
end

Here, after creating the files, you can launch/open this file by using
the below command
system('start foo.txt')

Hope it helps

Thanks
RRP

···

--
Posted via http://www.ruby-forum.com/\.