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

Anukul S. 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

Anukul S. 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 B.

“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

On Thu, Mar 20, 2008 at 11:31 PM, Anukul S.
[email protected] 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.

kind regards -botp

Drew O. wrote in post #648910:

Anukul S. 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