📜 ⬆️ ⬇️

Browserless Javascript Applications (HTA)

One of the most powerful tools of Donkey (starting with the fifth (!) Version) - HTA or HTML Application (browser-free applications), allows you to create Windows-based applications using HTML, CSS and Javascript / VBscript. Just want to note that this article uses only Javascript.

From the user's point of view, the “program” created by anything but the extension (* .hta) is no different from any other program: the window title, icon, display on the taskbar, and most importantly, no warnings when accessing computer files. With all this, you do not have to install any individual applications or plug-ins, Internet Explorer is enough!


')
The following is the code for a simple HTA program. Copy it to any text editor, before saving, be sure to check all the quotes generated by the habr-editor, and write “HTA: Application” in one place without spaces (because the habr-editor puts a space after the colon) ! Next, save with the extension * .hta and run.

ATTENTION! A space or a line break before the backslash "/>" is also required!

<html><head><title>
</title>
<hta:application id=myHta
applicationName=myApp />
</head>
<body bgcolor=buttonface
style="border: none;
font: 8pt sans-serif"
scroll=no text=buttontext>
Hello world!
</body></html>


The difference is only in one <HTA: Application ... /> header tag, and in the * .hta extension. And what is the result?

The parameters of the HTA: Application tag allow you to control the view of the application created. If the tag and / or parameters are not specified, the parameter values ​​are assigned by default.

Parameter in HTMLin JScriptValue (i)
( default )
Designation
APPLICATIONNAMEapplicationNameline
( no )
The unique name of the application.
INNERBORDERinnerBorderyes, no
( yes )
The presence of an internal curb.
BORDERSTYLEborderStylenormal, complex, raised, static, sunken
( normal )
Internal type of curb.
BORDERborderthick, dialog, thin, none
( thick )
External type of curb.
CAPTIONcaptionyes, no
( yes )
The presence of the title.
NotcommandLineOnly for reading.
( full path to this "* .hta" )
Command line content
CONTEXTMENUcontextMenuyes, no
( yes )
Right-click context menu.
SELECTIONselectionyes, no
( yes )
The ability to select text within the HTA .
ICONiconURL
( no )
Path to the icon ( * .ico ).
MAXIMIZEBUTTONmaximizeButtonyes, no
( yes )
Existence of the "expand" button.
MINIMIZEBUTTONminimizeButtonyes, no
( yes )
The presence of the "collapse" button.
SCROLLscrollyes, no, auto
( yes )
The presence of scrolling.
SCROLLFLAT ( IE 5.5+ )scrollFlatyes, no
( no )
Scrolling style.
SHOWINTASKBARshowInTaskBaryes, no
( yes )
Display in the taskbar.
SINGLEINSTANCEsingleInstanceyes, no
( no )
Prohibit the launch of the second instance.
SYSMENUsysMenuyes, no
( no )
The presence of the system menu.
VERSIONversionline
( no )
HTA version.
WINDOWSTATEwindowStatenormal, minimize, maximize
( normal )
The initial state of the window.
NAVIGABLE ( IE 5.5+ )navigableyes, no
( no )
Clicking the link will happen in the HTA window.


Note :
If you do not specify the BORDER parameter or specify BORDER="thick" , then the program window size can be changed with the mouse, in other cases ( BORDER = thin || dialog || none ), the window size cannot be changed.


As you can see, MS-sheep forgot to add the most necessary parameters of the type, in my opinion: winWidth , winHeight , winPositionX and winPositionY . But you can cure it yourself.

In the example, I will try to show that minimum to at least entice you ...

<html><head>
<hta:application id=hta_id
applicationName=hta_name
showInTaskBar=no
caption=no
innerBorder=no
selection=no
scroll=no
contextmenu=no />
<script language=javascript>
var winWidth=450; //
var winHeight=120; //
//
window.resizeTo(winWidth, winHeight);

//
var winPosX=screen.width/2-winWidth/2;
var winPosY=screen.height/2-winHeight/2;
window.moveTo(winPosX, winPosY);
</script>
</head>
<body bgcolor=buttonface text=buttontext
style="padding: 2px;font: 8pt 'MS Sans serif'">
<div> ...
, , ...<br>
, ...<br>
, ? ;).</div>
<div align=right><br> ALT+F4.</div>
</body></html>


Today, that's all.

For more information, see the MSDN Library .

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


All Articles