Convert Javascript Application to Windows Application

Are there any solutions besides Adobe Air? I heard that the V8 has something there.

Just do not have time to write the entire application in another language, and then write 2 more times.

+6
source share
4 answers

Perhaps you could use jsc: Compiling JScript code from the command line .

But you will have to replace the browser-related objects with WinForms objects, which means learning a new API or using the .NET WebBrowser object (a browser widget showing only the contents of the page, without bars, except for scroll bars) in the main window (form object) and program it for loading URLs to the page with your JS code.

Here is an excerpt from MSDN:

The WebBrowser control also allows you to display content created in the application or retrieve it from a database or resource file. Use the DocumentText or DocumentStream property to retrieve or set the contents of the current document as a string or data stream.

You can also manage the contents of a web page using the Document property, which contains an HtmlDocument object that provides controlled access to the HTML document object model (DOM) for the current page. This property is useful when used in conjunction with the ObjectForScripting property to implement two-way communication between your program code (Windows) and dynamic HTML (DHTML) code on a web page, which allows you to combine Web and Windows Forms controls in a single user interface. The Document property can be used to call script code methods from your application (Windows code). Your script code can access your application through the window.external object, which is a built-in DOM provided to access the host, and which maps to the object specified for the ObjectForScripting property.

The WebBrowser control is a managed shell for the ActiveX WebBrowser control and uses any version of the control installed on the user computer.

+1
source

You can make a regular HTML file by turning into a Windows application by simply changing the file extension to ".hta"

Windows will treat your * .hta file as a winform application. This is called an "html application" - HTA.

More documentation herer:

Html application

And, of course, you can attach as much Javascript as you want in this HTA file, or even use an external * .js file by doing the following:

<script src="your file.js"></script> 
+1
source

Ok, you could try something like

Chromeless

That way you can save your code, and it at least looks like a desktop application.

0
source

http://www.adobe.com/products/air/

http://gears.google.com/

So far, I have traveled with atomic air, as it is portable and reliable (does not make it painless, tho)

0
source

Source: https://habr.com/ru/post/891279/


All Articles