[Done] HTML/CSS elements in Custom Dialogs

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

User avatar
Grovkillen
Automation Wizard
Posts: 1023
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Sep 10, 2013 6:42 pm

Thanks for showing this Rain. Will use it for now... it involves writing a ".hta"-file to a temp folder which is not what I'd like but it'll do for now. Thanks again Rain for helping me. :)
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue Sep 10, 2013 10:03 pm

Grovkillen wrote:Thanks for showing this Rain. Will use it for now... it involves writing a ".hta"-file to a temp folder which is not what I'd like but it'll do for now. Thanks again Rain for helping me. :)
You're welcome.
You can create the HTA file in any directory you want just replace %TEMP_DIR% with the directory of your choice.

User avatar
Grovkillen
Automation Wizard
Posts: 1023
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Wed Sep 11, 2013 12:17 pm

Hi there,

I'm not sure how to make use of the .hta window. It cannot be dynamic as far as I can tell. It's not possible to throw stuff to it the same way as to Message> for example:

Code: Select all

  Let>DOT_TO_DISPLAY=
  Let>NUMBER_OF_DOTS=0
  Let>k=0
  Repeat>k
    Let>k=k+1
        Wait>1
        Let>NUMBER_OF_DOTS=%NUMBER_OF_DOTS%+1
        Let>DOT_TO_DISPLAY=%DOT_TO_DISPLAY%.
        Let>MESSAGE_TEXT=%NUMBER_OF_DOTS%%CRLF%%DOT_TO_DISPLAY%
        Message>%MESSAGE_TEXT%
  Until>k=10
Please tell me if there's a way. Thanks!
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Sep 11, 2013 1:09 pm

The HTA will not run macro scheduler codes...instead use VBScript or Javascript inside the HTA if you want it to handle dynamic codes. Google Free Javascript Examples OR Free VBscript Examples

I personally would use an HTA to display results created by a macro. Isn't that what you were looking for, a way to display a result and highlight certain parts?
An HTML Application (HTA) is a Microsoft Windows program whose source code consists of HTML, Dynamic HTML, and one or more scripting languages supported by Internet Explorer, such as VBScript or JScript. The HTML is used to generate the user interface, and the scripting language is used for the program logic. An HTA executes without the constraints of the internet browser security model; in fact, it executes as a "fully trusted" application.
Source: http://en.wikipedia.org/wiki/HTML_Application

AND
HTML Applications (HTAs) are full-fledged applications. These applications are trusted and display only the menus, icons, toolbars, and title information that the Web developer creates. In short, HTAs pack all the power of Windows Internet Explorer—its object model, performance, rendering power, protocol support, and channel–download technology—without enforcing the strict security model and user interface of the browser. HTAs can be created using the HTML and Dynamic HTML (DHTML) that you already know.
Source: http://msdn.microsoft.com/en-us/library ... 85%29.aspx

User avatar
Grovkillen
Automation Wizard
Posts: 1023
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Wed Sep 11, 2013 1:23 pm

Thanks Rain for your help. I will read more about it... I'm kinda freaked out by the fact that I would need to involve more script languages = might be hard to over look when searching for errors. But I'll give it a shot. Thanks once again!
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Sep 11, 2013 2:08 pm

Here is an example that will get some of your system info, write the info to an HTA file and display them inside a dialog. I hope this will point you in the right direction or give you some ideas.

Code: Select all


Dialog>Dialog1
object Dialog1: TForm
  Left = 247
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'System Info'
  ClientHeight = 440
  ClientWidth = 620
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSButton1: tMSButton
    Left = 16
    Top = 404
    Width = 113
    Height = 25
    Caption = 'Get System Info'
    TabOrder = 0
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,LoadSysInfo
AddDialogHandler>Dialog1,,OnClose,ExitScript
Show>Dialog1,





SRT>LoadSysInfo

IfWindowOpen>HTA Dialog Example
  CloseWindow>HTA Dialog Example
ENDIF

Let>HTMLCode=
ConCat>HTMLCode,%CRLF%<head>
ConCat>HTMLCode,%CRLF%<title>HTA Dialog Example</title>
ConCat>HTMLCode,%CRLF%<script>
//Set size of hta window
ConCat>HTMLCode,%CRLF%window.resizeTo(600, 400);
//Load hta window off screen
ConCat>HTMLCode,%CRLF%window.moveTo(-5000, -5000);
ConCat>HTMLCode,%CRLF%</script>
//Set hta properties (Source: http://msdn.microsoft.com/en-us/library/ms536495%28v=VS.85%29.aspx)
ConCat>HTMLCode,%CRLF%<HTA:APPLICATION
ConCat>HTMLCode,%CRLF%ID=oHTA
ConCat>HTMLCode,%CRLF%CAPTION="no"
ConCat>HTMLCode,%CRLF%ICON=""
ConCat>HTMLCode,%CRLF%CONTEXTMENU="no"
ConCat>HTMLCode,%CRLF%SHOWINTASKBAR="yes"
ConCat>HTMLCode,%CRLF%NAVIGABLE="no"
ConCat>HTMLCode,%CRLF%MINIMIZEBUTTON="no"
ConCat>HTMLCode,%CRLF%MAXIMIZEBUTTON="no"
ConCat>HTMLCode,%CRLF%SCROLL="no"
ConCat>HTMLCode,%CRLF%WINDOWSTATE="normal" />
  
ConCat>HTMLCode,%CRLF%</head>


//Check Screen Resolution
GetScreenRes>xRes,yRes
ConCat>HTMLCode,%CRLF%Screen Resolution: <b>%xRes%x%yRes%</b><br>

//Check Color Quality
Let>BITSPIXEL=12
LibFunc>User32,GetDC,hDC,0
LibFunc>GDI32,GetDeviceCaps,ColorQualityRes,hDC,BITSPIXEL
ConCat>HTMLCode,%CRLF%Color Quality: <b>%ColorQualityRes%</b> Bit<br>


//FONT SMOOTHING
let>font_setting=N/A
RegistryReadKey>HKEY_CURRENT_USER,Control Panel\Desktop,FontSmoothing,smooth_fonts
IF>smooth_fonts=0
ConCat>HTMLCode,%CRLF%Font Smoothing: <b>Disabled</b><br>
ENDIF
IF>smooth_fonts=1
ConCat>HTMLCode,%CRLF%Font Smoothing: <b>Enabled</b><br>
ENDIF
IF>smooth_fonts=2
ConCat>HTMLCode,%CRLF%Font Smoothing: <b>Enabled</b><br>
ENDIF




//IE VERSION
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Internet Explorer,svcVersion,IE_VERSION
IF>IE_VERSION=
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Internet Explorer,Version,IE_VERSION
ENDIF
ConCat>HTMLCode,%CRLF%Internet Explorer Version: <b>%IE_VERSION%</b><br>



//Operating system info
VBSTART
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
  OSCaption = "Operating System: " & objOS.Caption 'Name
  OSVersion = "Version: " & objOS.Version 'Version & build
  OSServicePack =  "Service Pack: " & objOS.ServicePackMajorVersion & "." & _
  objOS.ServicePackMinorVersion
  OSCaptionD4 = "OS: " & objOS.Caption 'Name
  OSVersionD4 = "V. " & objOS.Version 'Version & build
  OSServicePackD4 =  "SP " & objOS.ServicePackMajorVersion & "." & _
  objOS.ServicePackMinorVersion
Next
VBEND

VBEval>OSCaption,OSCaptionRes
ConCat>HTMLCode,%CRLF%%OSCaptionRes%<br>

VBEval>OSVersion,OSVersionRes
ConCat>HTMLCode,%CRLF%%OSVersionRes%<br>

VBEval>OSServicePack,OSServicePackRes
ConCat>HTMLCode,%CRLF%%OSServicePackRes%<br>

ConCat>HTMLCode,%CRLF%Operating System Platform: <b>%OS_PLATFORM%</b><br>



VBSTART
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each objOSItem In colOSItems
  SystemDrive = "System Drive: " & objOSItem.SystemDrive
  SystemDriveD4 = objOSItem.SystemDrive
Next
VBEND
VBEval>SystemDrive,SystemDriveRes
ConCat>HTMLCode,%CRLF%%SystemDriveRes%\<br>


ConCat>HTMLCode,%CRLF%Windows Directory Path: <b>%WIN_DIR%</b><br>

ConCat>HTMLCode,%CRLF%Windows System Directory Path: <b>%SYS_DIR%</b><br>

ConCat>HTMLCode,%CRLF%Native System Directory Path: <b>%SYS_NATIVE%</b><br>

ConCat>HTMLCode,%CRLF%Windows Temp Directory Path: <b>%TEMP_DIR%</b><br>

ConCat>HTMLCode,%CRLF%Desktop  Path: <b>%DESKTOP_DIR%</b><br>

ConCat>HTMLCode,%CRLF%Documents Path: <b>%USERDOCUMENTS_DIR%</b><br>

ConCat>HTMLCode,%CRLF%Program Files Path: <b>%PROGRAM_FILES%</b><br>

ConCat>HTMLCode,%CRLF%Native Program Files Path: <b>%PROGRAM_FILES_NATIVE%</b><br>



//Load HTA window inside Dialog1
DeleteFile>%TEMP_DIR%ExampleDialog.hta
WriteLn>%TEMP_DIR%ExampleDialog.hta,r,%HTMLCode%
Exe>%TEMP_DIR%ExampleDialog.hta
WaitWindowOpen>HTA Dialog Example
GetWindowHandle>HTA Dialog Example,hIEWnd
LibFunc>user32,SetParent,r,hIEWnd,DIALOG1.HANDLE
LibFunc>user32,SetWindowLongA,sres,hIEWnd,-16,524288
SetFocus>HTA Dialog Example
MoveWindow>HTA Dialog Example,0,0

END>LoadSysInfo





SRT>ExitScript
  Exit>1
END>ExitScript



Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts