# How to control another TK application

**URL:** <https://www.ruby-forum.com/t/how-to-control-another-tk-application/118267>\
**Category:** Ruby\
**Created:** [October 25, 2007, 8:48am UTC](https://www.ruby-forum.com/t/how-to-control-another-tk-application/118267 "2007-10-25T08:48:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![goal1860](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6a8cbe/32.png) [@goal1860](https://www.ruby-forum.com/u/goal1860)\
**Post date:** [October 25, 2007, 8:48am UTC](https://www.ruby-forum.com/t/how-to-control-another-tk-application/118267/1 "2007-10-25T08:48:06Z")

</div>

I want to validate strings displayed in a TK application, how can I  
write rb program to communicate to it and extract the messages from GUI?  
Any module is good for that?

---

<div class="post-metadata">

**Author:** ![goal1860](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6a8cbe/32.png) [@goal1860](https://www.ruby-forum.com/u/goal1860)\
**Post date:** [October 25, 2007, 9:47am UTC](https://www.ruby-forum.com/t/how-to-control-another-tk-application/118267/2 "2007-10-25T09:47:08Z")

</div>

From: Liang He [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: How to control another TK application  
Date: Thu, 25 Oct 2007 15:48:09 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> I want to validate strings displayed in a TK application, how can I  
> write rb program to communicate to it and extract the messages from GUI?  
> Any module is good for that?

Do you mean about validation on TkEntry widgets?  
If so, please read ‘tk/sample/demos-en/entry3.rb’.

---

<div class="post-metadata">

**Author:** ![goal1860](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6a8cbe/32.png) [@goal1860](https://www.ruby-forum.com/u/goal1860)\
**Post date:** [October 25, 2007, 10:07am UTC](https://www.ruby-forum.com/t/how-to-control-another-tk-application/118267/3 "2007-10-25T10:07:06Z")

</div>

Hidetoshi NAGAI wrote:

> From: Liang He [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Subject: How to control another TK application  
> Date: Thu, 25 Oct 2007 15:48:09 +0900  
> Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> > I want to validate strings displayed in a TK application, how can I  
> > write rb program to communicate to it and extract the messages from GUI?  
> > Any module is good for that?
> 
> Do you mean about validation on TkEntry widgets?  
> If so, please read ‘tk/sample/demos-en/entry3.rb’.

Hi,  
We have a separate tk based application running(can be initialed by Ruby  
script), my task is to write a Ruby program to take the control of it  
and validate the display, function, and browse from gui to gui. It is  
much like how Watir do to web browser. Do you have any idea how can I  
implement it?

Thanks!

---

<div class="post-metadata">

**Author:** ![goal1860](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6a8cbe/32.png) [@goal1860](https://www.ruby-forum.com/u/goal1860)\
**Post date:** [October 25, 2007, 9:34pm UTC](https://www.ruby-forum.com/t/how-to-control-another-tk-application/118267/4 "2007-10-25T21:34:42Z")

</div>

From: Liang He [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: How to control another TK application  
Date: Thu, 25 Oct 2007 17:07:04 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> We have a separate tk based application running(can be initialed by Ruby  
> script), my task is to write a Ruby program to take the control of it  
> and validate the display, function, and browse from gui to gui. It is  
> much like how Watir do to web browser. Do you have any idea how can I  
> implement it?

Hmm…  
If your environment is Unix/X and Tcl/Tk’s “send” command is  
available, ‘remote-tk.rb’ may help you.  
Then, please read ‘ext/tk/sample/remote-ip\_sample.rb’ and  
‘ext/tk/sample/remote-ip\_sample2.rb’.

If you use Windows, you may need Tcl/Tk’s “dde” command.  
Please read Tcl/Tk’s manual of “dde”.  
On Ruby/Tk, call “require ‘tk/winpkg’”.  
TkWinDDE module supports it.  
To control your Tk based application, you will have to modify  
your application to register it as a DDE server.
