7

Is it possible to create Windows desktop applications in JavaScript?

I am aware of HTA (HTML Application) programs, but was wondering if there were a newer .NET or other solution where I could make use of the DLL libraries included with Visual Studio.

posfan12
  • 2,541
  • 8
  • 35
  • 57
  • I don't know much about .NET but Actionscript is very similar to Javascript. With Flex/AIR, you can create desktop applications. – zawhtut Jan 24 '11 at 10:39
  • Possible duplicate of [Can you do Desktop Development using JavaScript?](https://stackoverflow.com/questions/109399/can-you-do-desktop-development-using-javascript) – Emile Bergeron Nov 11 '19 at 21:05
  • @EmileBergeron Actually, this one seems to be pretty .net-specific and not a dupe – Bergi Nov 11 '19 at 21:12
  • @Bergi It's quite old, but it also sounds a lot like an XY problem, where OP thought that leveraging .NET was the solution. – Emile Bergeron Nov 11 '19 at 21:38
  • 1
    @EmileBergeron I understood the ability to call .net APIs from the application as a requirement, not as a solution idea. But yeah, it's old and probably still off-topic, so let's just leave it at that. – Bergi Nov 11 '19 at 22:24
  • @EmileBergeron is correct, except that this thread has better answers. – posfan12 Nov 12 '19 at 21:44
  • Yes, the answers are divided between a lot of different questions and I don't believe any deserve to be removed, but definitely linked together (I chose the oldest as the dupe target but newer questions tends to have more relevant answers) – Emile Bergeron Nov 13 '19 at 16:03

5 Answers5

5

Latest .NET version doesn't have such feature, but you've options to do it:

a) A WebBrowserObject in a WPF or Windows Forms application (it'll be an embedded Internet Explorer).

b) Opera Widgets, which is a Opera browser-based presentation engine which lets you implement desktop applications with standard Web technologies and it follows the W3C widgets standard. These applications can run standalone, meaning that user won't need to open Opera to run them. There's a counterpart: Opera must be installed in user's machine.

There're other options like Mozilla XUL but its limited support for desktop application development would prevent you from using it.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • 1
    Looks like I'll be trying the Windows Forms application by following this tutorial: http://www.webreference.com/js/column117/index.html. Thanks! – posfan12 Jan 24 '11 at 10:43
5

I know this question is a bit old, but I thought I'd answer for the googlers out there.

You could use this project. Its basically a javascript interepter that has access to the .Net framework.

So you could do something like:

jish.assembly('path/to/System.Windows.Forms.dll');

var mb = jish.create('System.Windows.Forms.MessageBox');
mb.Show('Hello World');

And it works, I've not however tried more complex winforms apps so can't say whether it will fall down eventually.

Let me know if anyone tries it.

Edit 1: Well I tried it with a slightly more complex example and it worked also. Try this:

jish.assembly('path/to/System.Drawing.dll')
jish.assembly('path/to/System.Windows.Forms.dll')

var app = jish.create('System.Windows.Forms.Application');
var form = jish.create('System.Windows.Forms.Form');
var lbl = jish.create('System.Windows.Forms.Label');
form.Text = lbl.Text = 'Hello World!';
lbl.Location = jish.create('System.Drawing.Point', 50, 50);
form.Controls.Add(lbl);

app.Run(form);

Guido

gatapia
  • 3,574
  • 4
  • 40
  • 48
3

There are a few solutions out there that will let you package javascript/html/css code into a cross-platform "native" application, usually complete with an installer and updating mechanism.

Off the top of my head:

  • Mozilla Prism, not under active development anymore, apparently. open source.
  • Adobe AIR, which doesn't actually have to use Flash, contrary to popular belief. actively developed, closed source.
  • Appcelerator Titanium Desktop, which is both open source and actively developed.
Metal
  • 883
  • 5
  • 6
  • How do you create a GUI in AIR without Flash? Doesn't Flash handle all the graphical elements? Also, do I need to purchase the Adobe IDE in order to develop in AIR? Note that I am not so much concerned with cross-platform compatibility, though it's a plus. – posfan12 Jan 24 '11 at 10:50
  • 1
    the AIR runtime actually includes webkit. Here's an old blog post showing how to make an "hello world" pure HTML air app: http://filchiprogrammer.wordpress.com/2008/03/12/creating-a-sample-hello-world-adobe-air-application-with-html-and-javascript/ - as far as compiling AIR apps, you can do it with Adobe's free Air SDK (http://www.adobe.com/products/air/sdk/ ). If you want a free IDE, FlashDevelop is probably the best option currently out there. – Metal Jan 24 '11 at 11:15
  • 1
    Let's not forget about Nokia's popular Qt. Their latest Qt 5 implemented the GUI widget framework Qt Quick 2, which allows defining the windows, controls, and event handlers in Javascript, so simple apps (no persistence, no sockets, etc., but there is a graphics device) could be developed in Javascript only, but classes that allow persistence etc. could be exposed to Javascript from C++. For example a calculator could be made in Javascript alone, I think. Oh and Qt is cross-platform and builds cross-platform apps, and it's free to use for open-source projects. – bitoolean May 09 '18 at 14:29
  • 1
    Oh and there's also [Qt WebEngine] (http://doc.qt.io/qt-5/qtwebengine-overview.html) you can use to display web content inside desktop applications, which is more along the lines of your description. Of course, these components (Qt Quick and WebEnginge) did probably not exist at the time of your comment in 2011. – bitoolean May 09 '18 at 15:04
2

You could use Mozilla's XULRunner environment to utilize local JavaScript in an application you build. Mozilla's environment can take advantage of XPCOM components, and XPCOM components can be developed using C++.

Therefore, one option could be to use this tried and tested environment to build your application using JavaScript and XUL, and use the power of C++ and DLL's in the XPCOM components.

Examples of desktop applications developed on this platform include:

jamesmortensen
  • 33,636
  • 11
  • 99
  • 120
1

You can use WebKit in a WinForms application (the HTML engine used in Safari and Google Chrome).

.Net control: http://webkitdotnet.sourceforge.net/

jgauffin
  • 99,844
  • 45
  • 235
  • 372