# Interacting with a WPF/Winforms application

**URL:** <https://www.ruby-forum.com/t/interacting-with-a-wpf-winforms-application/145937>\
**Category:** IronRuby\
**Created:** [August 15, 2008, 9:01am UTC](https://www.ruby-forum.com/t/interacting-with-a-wpf-winforms-application/145937 "2008-08-15T09:01:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [August 15, 2008, 9:01am UTC](https://www.ruby-forum.com/t/interacting-with-a-wpf-winforms-application/145937/1 "2008-08-15T09:01:38Z")

</div>

Hi

Is there a simple way to interact with the GUI of a WPF/Winforms  
application?  
I’ll clarify a little what I would like to achieve:

when you start a console session with an environment loaded you could  
potentially type the following lines in there

> > require ‘config/boot’  
> > start\_wpf\_application  
> > System::Windows::Application.current.main\_window.my\_panel.children.add  
> > Wpf.build(TextBox, :text =\> “Very important placeholder text”)

That last line would then add a textbox to the panel while the  
application  
is running.

I could probably use threading to achieve this or different appdomains  
maybe.

any thoughts?

Cheers  
Ivan

---

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [August 15, 2008, 4:46pm UTC](https://www.ruby-forum.com/t/interacting-with-a-wpf-winforms-application/145937/2 "2008-08-15T16:46:47Z")

</div>

Running in a separate thread is what you probably want to do.

Thereâ€™s an IronPython sample that does something like this for WinForms  
â€“ itâ€™s called winforms.py and lives in the tutorial directory.  
Unfortunately, it looks like it depends on some IronPython-specific  
functionality in the command line â€“ but it wouldnâ€™t be too hard to add  
something similar to IronRuby.

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Ivan Porto  
Carrero  
Sent: Friday, August 15, 2008 12:01 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Interacting with a WPF/Winforms application

Hi

Is there a simple way to interact with the GUI of a WPF/Winforms  
application?  
I’ll clarify a little what I would like to achieve:

when you start a console session with an environment loaded you could  
potentially type the following lines in there

> > require ‘config/boot’  
> > start\_wpf\_application  
> > System::Windows::Application.current.main\_window.my\_panel.children.add Wpf.build(TextBox, :text =\> “Very important placeholder text”)

That last line would then add a textbox to the panel while the  
application is running.

I could probably use threading to achieve this or different appdomains  
maybe.

any thoughts?

Cheers  
Ivan

---

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [August 16, 2008, 9:38pm UTC](https://www.ruby-forum.com/t/interacting-with-a-wpf-winforms-application/145937/3 "2008-08-16T21:38:51Z")

</div>

FWIW, the easiest way is to rename the exe to dll,(btw, is there a  
reason we  
can’t require exes?) and then call “Thread.new { Program.main args }” 🙂
