Jump to content

Building an html application using only about:blank


Will66
 Share

Recommended Posts

Put this together so far and though others might be interested.

Basically its similar to using autoit as a server-side language and outputting the html to the browser.

There are no html files created or needed, everything is done using about:blank, frames, autoit and javascript.

The key is the hidden text field <input id=""myevent"" type=hidden> in the menu frame which acts as a seudo-browser address bar and returns events to autoit

This example is viewing data from any msaccess db from your hard drive and includes paging etc...i haven't finished with the edit functions....

#include <GUIConstants.au3>
#Include <Array.au3>
#include <Date.au3>
#include <IE.au3>
Dim $DB
_IEErrorHandlerRegister ()
Dim $oIE = _IECreateEmbedded ()
Dim $sHtml,$SQL,$RecIdName,$table
Global $page
Global $oBody 
Dim $oFrameTop
Dim $oFrameMenu
Dim $oFrameMain
Dim  $adUseClient = 3;
Dim $myevent,$oEvent
Dim $go_Button,$oEvent2



Opt("GUIOnEventMode", 1)  ; OnEvent mode
$gui = GUICreate("Amba-view", 800, 600,-1,-1,$WS_OVERLAPPEDWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISetFont (8,-1,"Arial")

Opt("GUIResizeMode", 1)
Dim $GUIActiveX = GUICtrlCreateObj($oIE, 1, 1,798,580)

_IENavigate ($oIE, "about:blank")
_build_menus()
_build_frames()
GUISetState ()

While 1
  Sleep(1000)  ; Idle around
WEnd



    Func _build_frames()
        $sHTML = ""
        Out("<HTML>")
        Out("<HEAD>")
        Out("<TITLE>Amba-view</TITLE>")
        Out("<style>FRAMESET{border:0;}</style>")
        Out("</HEAD>")
        Out("<FRAMESET cols=""150,*"">")
        Out("   <FRAME NAME=Menu SRC=about:blank>")
        Out("   <FRAME NAME=Main SRC=about:blank>")
        Out(" </FRAMESET>")
        Out("</HTML>")

        _IEDocWriteHTML ($oIE, $sHtml)
        _IEAction ($oIE, "refresh")
         $oFrameMenu = _IEFrameGetObjByName ($oIE, "Menu")
         $oFrameMain = _IEFrameGetObjByName ($oIE, "Main")
         
        Call( _Menu_Html() )
        Call( _Main_Html() )
        
    EndFunc
    
    Func _Main_Html()
        $sHtml = ""
        Out("<HTML>")
        Out("<HEAD>")
        Out("<TITLE>Main</TITLE>")
        Out("<style>body{border:0;background:#FFF;font size:8pt;font-family:arial}")
        Out("table,th,td{font size:11px;border:1px solid;}")
        Out("th{font-weight:bold;}")
        Out("A:link {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out("A:visited {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out("</style>")
        Out("</HEAD>")
        Out("<body>")
        Out("<p>Welcome. Select an <b><i>Access</b></i> database from the menu to get started....</p>")
        Out("</body>")
        Out("</HTML>")
        _IEDocWriteHTML($oFrameMain,$sHtml)
        _IEAction ($oFrameMain, "refresh")
        
    EndFunc
    
    Func _Menu_Html()
        $sHtml = ""
        Out("<HTML>")
        Out("<HEAD>")
        Out("<TITLE>Menu</TITLE>")
        Out("<style>body{border:0;background:#EEEEEE;font size:8pt;font-family:arial}>")
        Out("A:link {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out("A:visited {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out("</style>")
        Out("</HEAD>")
        Out("<body>")
        Out("<form name=""eventform"">")
        Out("<input id=""myevent"" type=hidden>") ;here is the suedo-address bar event field, inhide for testing.eg..type=text
        Out("</form>")
        Out("<div id=tables></div>")
        Out("</body>")
        Out("</HTML>")
        _IEDocWriteHTML($oFrameMenu,$sHtml)
        $myevent = _IEGetObjByName ($oFrameMenu, "myevent")
        $oEvent = ObjEvent( $myevent, "my_Event_")
    EndFunc

    
    Func my_Event_onpropertychange()
        $query=""
        $ArgumentPairs = StringSplit($myevent.value, "&")
            for $i = 1 to $ArgumentPairs[0]
                $query  = StringSplit($ArgumentPairs[$i], "=")
                ;msgbox(0,"",$query[1] & ":" & $query[2])
                Select 
                    Case $query[1]="table"
                        
                        return _train_list($query[2],1)
                    Case $query[1]="page"
                        return _train_list(0,int($query[2]))
                
                    Case $query[1]="edit"
                        if StringInStr($query[2],"|") Then $query[2] = StringReplace($query[2],"|","'")
                            ;msgbox(0,"",$query[2])
                        return _edit($query[2])
                    Case Else
                
                EndSelect       
            next
            
        
    EndFunc
    
    Func _edit($id)
        $oCon = CreateConnection(); 
        $Rec = ObjCreate("ADODB.Recordset");
        $editSQL=$SQL & " where " & $RecIdName & "=" & $id
        ;msgbox(0,"",$editSQL)
        $Rec.Open( $editSQL, $oCon);
        $sHtml=""
        Out("<table cellpadding=5>")
        while not $Rec.EOF or $Rec.BOF 
    
            
                for $i=0 to $Rec.Fields.Count -1
                    Out("<tr>");
                    Out("<td>" & $Rec.Fields($i).name & "</td>");
                    Out("<td>");            
                    $temp = $Rec.Fields($i).value;
                    if $temp="" then $temp="na"
                        if $Rec.Fields($i).type=7 then $temp = _ConvertMyDate($temp)
                        if $i=0 then 
                            $temp="<a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='page=" & $page & "';return false;"">"& $temp & "</a>"
                        Else
                            $temp= "<input type=text value=""" & $temp & """>"
                    EndIf
                    Out($temp);
                    Out("</td>");
                    Out("</tr>");
                Next
            
            $Rec.MoveNext();
        wend

        Out("</table>");        
        $Rec.Close();
        $oCon.Close();
        $oBody = _IETagNameGetCollection($oFrameMain, "body", 0)
        $oBody.innerHTML=$sHtml

    EndFunc
    
    Func _build_menus()
        $ViewMenu = GUICtrlCreateMenu ("&Database")
        GUICtrlCreateMenuitem ("Open",$ViewMenu)
        GUICtrlSetOnEvent(-1, "TablesMenu_clicked")     
        $ReportsMenu = GUICtrlCreateMenu ("&Reports")
        GUICtrlCreateMenuitem ("Open",$ReportsMenu) 
        GUICtrlSetOnEvent(-1, "ReportsMenu_clicked")   
    EndFunc
    
    Func TablesMenu_clicked()
        $var = FileOpenDialog("Select Database", @ScriptDir & "\", "db (*.mdb)", 1 + 4 )
        If @error <> 1 Then 
        $sHtml=""
        $oBody = _IETagNameGetCollection($oFrameMain, "body", 0)
        $oBody.innerHTML=$sHtml
        $DB = $var
        $oCon = CreateConnection(); 
        Dim $rs = $oCon.OpenSchema(20);
        Out("<h6>Tables</h6>");
        Out("<ul STYLE=""margin:0px;"">");
        while not $rs.EOF()
        if $rs.Fields("TABLE_TYPE").Value = "TABLE" then
            Out("<li><a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='table=" & $rs.Fields("TABLE_NAME").Value & "';return false;"">"& $rs.Fields("TABLE_NAME").Value & "</a></li>")
        EndIf
        $rs.MoveNext()
        
        wend

    $rs.Close();
    $rs = "";
    $oCon.Close();
    $oCon = "";
    Out("</ul>");
        $oBody = _IETagNameGetCollection($oFrameMenu, "body", 0)
        $oBody.document.getElementById("tables").innerHTML=$sHtml
        ;$oBody.tables.innerHTML=$sHtml
    
    EndIf
    EndFunc
    
    Func ReportsMenu_clicked()
    EndFunc

    Func Out($temp)
        $sHtml &= $temp & @CR
    EndFunc

    Func _ConvertMyDate($sString)
        Local $aString[6] = ['/','/',' ',':',':',''], $sHold
        Local $aSRE = StringRegExp($sString, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', 3)
        If IsArray($aSRE) = 0 Then Return SetError(1, 0, '')
        For $iCC = 0 To UBound($aSRE) -1
            $sHold &= $aSRE[$iCC] & $aString[$iCC]
        Next
        Return $sHold
    EndFunc
    
    Func _train_list($thisTable,$Gpage)
        if Not $thisTable=0 then $table=$thisTable
        $sHtml=""
        Local $oCon = CreateConnection();   
        $DisplayNum = 0;
        Local $recdisp = 15; //records per page
    
        Local $Rec = ObjCreate("ADODB.Recordset");
        $Rec.PageSize = $recdisp;
        $Rec.CursorLocation = $adUseClient ;
        $SQL  = "SELECT * FROM " & $table & " ";

        $Rec.Open( $SQL, $oCon);

        If $Rec.EOF Or $Rec.BOF Then
            Out("<p align=center><b>Sorry, There is no entries ... <a href=""java script:void(0);parent.document.frames[0].document.getElementById('myevent').value='add';return false;"">add new</a></b></p>");
        Else

            Local $tblHeaders
            For $tablefield in $Rec.fields()
                $tblHeaders &= "<th>" & $tablefield.name & "</th>"
                
            next
            
            $Rec.MoveFirst()
            ;paging
            Local $ipage = $Rec.PageCount();            
            $page = Int($Gpage)
            if $page < 1 then $page = 1
            if $page > $ipage then
                $page = $ipage
                $Rec.AbsolutePage = $ipage;
            else
                $Rec.AbsolutePage = $page;
            EndIf
            $nextPage = $page + 1
            if $nextPage > $ipage Then $nextPage=$ipage
            $prevPage = $page - 1
            if $prevPage < 1 Then $prevPage=1
            $pagesHtml = "<p align=left>"
            $pagesHtml &= "<b>Pages: " & $page & " of " & $ipage & " </b>";
            $pagesHtml &= " <a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='page=1';return false"">First</a> "
            $pagesHtml &= " <a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='page=" & $ipage & "';return false;"">Last</a>  "
            $pagesHtml &= " <a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='page=" & $prevPage & "';return false;""><< Prev</a> "
            $pagesHtml &= " <a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='page=" & $nextPage & "';return false;"">Next >></a>"
            $pagesHtml &= "</p>"
            Out($pagesHtml)
            
            Out("<table cellpadding=5><tr>")
            Out($tblHeaders)
            Out("</tr>")
            
            while not $Rec.EOF Or $Rec.BOF And $DisplayNum < $recdisp
                Out("<tr>");
                for $i=0 to $Rec.Fields.Count -1
                    Out("<td nowrap>");         
                    $temp = $Rec.Fields($i).value;
                    if $Rec.Fields($i).type=7 then $temp = _ConvertMyDate($temp)
                    if $Rec.Fields($i).type=205 then $temp = BinaryToString($temp)
                    if $temp="" then $temp="na"
                    if StringLen($temp) > 100 then $temp = StringLeft($temp,100)
                    if $i=0 then 
                        if $Rec.Fields($i).type=3 Then
                        $temp="<a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='edit=" & $temp & "';return false;"">"& $temp & "</a>"
                        Else
                        $temp="<a href=""java script:void(0);"" onclick=""parent.document.frames[0].document.getElementById('myevent').value='edit=|" & $temp & "|';return false;"">"& $temp & "</a>"
                        ;msgbox(0,"",$temp)
                        EndIf
                    $RecIdName=$Rec.Fields($i).name
                    EndIf
                    Out($temp);
                    Out("</td>");
                Next
                Out("</tr>")
                $DisplayNum = Int($DisplayNum) + 1;
                $Rec.MoveNext();
            wend
            Out("</table>");
        EndIf   
            
        $Rec.Close();
        $oCon.Close();
        $oBody = _IETagNameGetCollection($oFrameMain, "body", 0)
        $oBody.innerHTML=$sHtml
        ;_IEDocInsertHTML($oBody, $sHtml,"afterbegin")
        ;$oFrameMain.document.write($sHtml)
        ;_IEAction($oFrameMain,"refresh")
        ;_IEBodyWriteHTML($oFrameMain, $sHtml)
    EndFunc
    
    Func CreateConnection() 
        $Conn = ObjCreate("ADODB.Connection")
        $Conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $DB & ";");    
        $Conn.CursorLocation = $adUseClient;
        return $Conn;
    EndFunc

    Func CLOSEClicked()
        Exit   
    EndFunc
Link to comment
Share on other sites

Cool, Good start. Lays out any access db nicely... Any plans to add create db and write to db?

:) thanx

Feels a bit like cheating using IE, but i find it makes development faster using the flexability IE offers in creating (html) controls on the fly.

Because its a generic example, there would be lots of error checking and data validation code required to cover all possible data type scenarios when adding/deleting and editing db data. I've added checks for date type fields and string type id's.

Its much easier to write the code when you know what the fields and data types of a database will be rather than try cover every scenario, so for that reason, probably not for this example but willing to lend a hand if anyone decides to use a similar setup.

edit: click the records id hyper-link to the beginning of edit db fields

Edited by Will66
Link to comment
Share on other sites

Very nice! I'd love to see more examples like this.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Nice approach, this is simular to creating an HTA application isn't it ?

An HTML Application (HTA) is a Microsoft Windows application written with HTML and Dynamic HTML. The ability to write HTAs was introduced with Microsoft Internet Explorer 4.0.

HTAs can be made from regular HTML files by simply changing the file extension to .hta. An HTA runs as a fully trusted application and therefore has more privileges than a regular HTML file, which is confined to the security model of the web browser.

Source : Wikipedia

HTA Apps

Also look for the - hta_helpomatic.hta.

This will generate the HTML code automatically.

regards,

ptrex

Edited by ptrex
Link to comment
Share on other sites

Nice approach, this is simular to creating an HTA application isn't it ?

HTA Apps

Also look for the - hta_helpomatic.hta.

This will generate the HTML code automatically.

regards,

ptrex

No, its not imo.

HTA's equate to not much more than allow running vbscript/javascript using msie with no security restrictions.

There's not a whole lot of use for them apart from the security loop hole they represent to hackers.

They also don't offer a viable way of distribution because source code is freely available via any text editor and most good AV's will alert the user that hta files are a security threat.

In any case a HTA file needs to be physically located on the hard drive.

Using the method per my example no files are created OR extracted to the users HD.

The html scouce code is generated by the autoit scripting and outputted to the browser's "about:blank" DOM where its available for manipulation and resides in memory(i presume). _IE.au3/autoit takes care of the security alerts.

The only physical files in this example are the database and autoit.

Cheers

Link to comment
Share on other sites

Wysiwyg editor demo.

Icon Buttons require webdings/wingdings/wingdings 2 and wingdings 3 fonts.

#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()
Dim $oIE = _IECreateEmbedded ()
Dim $sHtml
Dim $oBody 
Dim $oFrameMenu
Dim $oFrameMain

Dim $myevent,$oEvent
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)  ; OnEvent mode
$gui = GUICreate("Frames", 800, 600,-1,-1,$WS_OVERLAPPEDWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISetFont (8,-1,"Arial")


Dim $GUIActiveX = GUICtrlCreateObj($oIE, 1, 1,798,580)
_IENavigate ($oIE, "about:blank")
;_build_menus()
_build_frames()


If $oFrameMain.document.DesignMode = "On" Then
   $oFrameMain.document.DesignMode = "Off"
Else
    $oFrameMain.document.DesignMode = "On"
        ;$IE_browser.document.execCommand("RemoveParaFormat",false,"null")
 
EndIf


GUISetState ()

While 1
  Sleep(1000)  ; Idle around
WEnd



    Func _build_frames()
        $sHTML = ""
        Out("<HTML>")
        Out("<HEAD>")
        Out("<TITLE>Amba-view</TITLE>")
        Out("<style>FRAMESET{border:0;}</style>")
        Out("</HEAD>")
        Out("<FRAMESET rows=""70,*"">")
        Out("   <FRAME NAME=Menu SRC=about:blank>")
        Out("   <FRAME NAME=Main SRC=about:blank>")
        Out(" </FRAMESET>")
        Out("</HTML>")

        _IEDocWriteHTML ($oIE, $sHtml)
        _IEAction ($oIE, "refresh")
         $oFrameMenu = _IEFrameGetObjByName ($oIE, "Menu")
         $oFrameMain = _IEFrameGetObjByName ($oIE, "Main")
         
        Call( _Menu_Html() )
        Call( _Main_Html() )
        
    EndFunc
    
    Func _Main_Html()
        $sHtml = ""
        Out("<HTML>")
        Out("<HEAD>")
        Out("<TITLE>Main</TITLE>")
        Out("<style>body{border:0;background:#FFF;font size:8pt;font-family:arial}")
        Out("table,th,td{font size:11px;border:1px solid;}")
        Out("th{font-weight:bold;}")
        Out("A:link {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out("A:visited {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out("</style>")
        Out("</HEAD>")
        Out("<body>")
        Out("<p>Frames Template</p>")
        Out("</body>")
        Out("</HTML>")
        _IEDocWriteHTML($oFrameMain,$sHtml)
        _IEAction ($oFrameMain, "refresh")
        
    EndFunc
    
    Func _Menu_Html()
        $sHtml = ""
        Out("<HTML>")
        Out("<HEAD>")
        Out("<TITLE>Menu</TITLE>")
        Out("<style>body{border:0;background:#EEEEEE;font size:8pt;font-family:arial}>")
        Out("A:link {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out("A:visited {COLOR: #0000EE;}")
        Out("A:hover {COLOR: #0000EE;}")
        Out(".button {width:28;height:28;background:#232323;COLOR:#fff;font-size:12pt;font-family:Georgia}")
        Out("</style>")
        Out("</HEAD>")
        Out("<body>")
        Out("<form name=""eventform"">")
        Out("<input id=""myevent"" type=hidden>")
        Out("</form>")
        Out("<div id=buttons>")
        Call(_BuildButtons() )
        Out("</div>")
        Out("</body>")
        Out("</HTML>")
        _IEDocWriteHTML($oFrameMenu,$sHtml)
        $myevent = _IEGetObjByName ($oFrameMenu, "myevent")
        $oEvent = ObjEvent( $myevent, "my_Event_")
    EndFunc

    
    Func _build_menus()
        $ViewMenu = GUICtrlCreateMenu ("&View")
        GUICtrlCreateMenuitem ("Tables",$ViewMenu)
        ;GUICtrlSetOnEvent(-1, "TablesMenu_clicked")        
        $ReportsMenu = GUICtrlCreateMenu ("&Reports")
        GUICtrlCreateMenuitem ("Open",$ReportsMenu) 
        ;GUICtrlSetOnEvent(-1, "ReportsMenu_clicked")   
    EndFunc
    
    Func _BuildButtons()
        Out("<button name=""bold"" class=button title=""Bold"" unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><u>B</u></button>")
Out("<button name=""undo"" title=""Undo"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">Q</font></button>")
Out("<button name=""redo"" title=""Redo"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">P</font></button>")
;Out("<input name=""undo"" value=""←"" type=button class=button unselectable=""on"" onclick=""document.forms['eventform'].myevent.value=this.name;return false;"">")
;Out("<input name=""redo"" value=""→"" type=button class=button unselectable=""on"" onclick=""document.forms['eventform'].myevent.value=this.name;return false;"">")
        Out("<button name=""strikethrough"" title=""Strikethrough"" class=button title='this.name' unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><del>S</del></button>")
        Out("<button name=""underline"" title=""Underline"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><u>U</u></button>")
        Out("<button name=""italic"" title=""Italic"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;"">I</button>")
        Out("<button name=""JustifyLeft"" title=""Justify Left"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">\</font></button>")
        Out("<button name=""JustifyCenter"" title=""Justify Center"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">X</font></button>")
        Out("<button name=""JustifyRight"" title=""Justify Right"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">]</font></button>")
        Out("<button name=""InsertUnorderedList"" title=""Unordered List"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 2"">8</font></button>")
        Out("<button name=""InsertOrderedList"" title=""Ordered List"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 2"">u</font></button>")
        Out("<button name=""Indent"" title=""Indent"" type=button class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">H</font></button>")
        Out("<button name=""Outdent"" title=""Outdent"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">I</font></button>")
        Out("<button name=""Subscript"" title=""Subscript"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">-</font></button>")
        Out("<button name=""Superscript"" title=""Superscript"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">.</font></button>")


        Out("<button name=""SaveAs"" title=""Save As"" class=button unselectable=""on"" onclick=""parent.document.frames['Menu'].document.execCommand(this.name,false,'mydoc.html');""><font face=""Wingdings""><</font></button>")
        Out("<button name=""cut"" title=""Cut"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.selection.createRange().execCommand(this.name);""><font face=Wingdings>"</font></button>")
        Out("<button name=""Copy"" title=""Copy"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.selection.createRange().execCommand(this.name);""><font face=""Wingdings"">4</font></button>")
        
        Out("<button name=""Paste"" title=""Paste"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.selection.createRange().execCommand(this.name);""><font face=""Wingdings"">2</font></button>")

    
        Out("<button name=""InsertImage"" title=""Insert Image"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');return false;""><font face=""Webdings"">Q</font></button>")
        Out("<button name=""CreateLink"" title=""Insert Link"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');return false;""><font face=""Wingdings"">*</font></button>")

        Out("<button name=""Open"" title=""Open"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');""><font face=""Wingdings"">1</font></button>")

        Out("<button name=""RemoveFormat"" title=""Remove Formatting"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');""><font face=""Wingdings 2"">Q</font></button>")
        Out("<button name=""Print"" title=""Print"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');""><font face=""Wingdings 2"">6</font></button>")
            
        Out("<button name=""ForeColor"" title=""Font Color"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'#000fff');""><font face=""Wingdings"">?</font></button>")
        Out("<button name=""BackColor"" title=""Back Color"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'#aaaecc');""><font face=""Wingdings"">!</font></button>")

        Out("<button name=br title=""Line Break"" class=button unselectable=""on"" onclick=""document.forms['eventform'].myevent.value=this.name;;""><font face=""Wingdings 3"">@</font></button>")
    
    EndFunc

    Func my_Event_onpropertychange()
        $query = StringSplit($myevent.value, "&")
        
        Select 
            Case $query[1] = "br"
                Send("+{ENTER}")
            Case Else
                ;MsgBox(0,"",$query[1])
                ;return $oFrameMain.document.execCommand($query[1],false,"null")
        EndSelect       
    EndFunc
    
    Func Out($temp)
        $sHtml &= $temp & @CR
    EndFunc
    
    Func CLOSEClicked()
        Exit   
    EndFunc
Link to comment
Share on other sites

Cool start.. was erroring out for me and found line 147 was shy on double quote added as seen here and viola! works...

#include <GUIConstants.au3>
 #include <IE.au3>
 
 _IEErrorHandlerRegister ()
 Dim $oIE = _IECreateEmbedded ()
 Dim $sHtml
 Dim $oBody
 Dim $oFrameMenu
 Dim $oFrameMain
 
 Dim $myevent,$oEvent
 Opt("GUIResizeMode", 1)
 Opt("GUIOnEventMode", 1) ; OnEvent mode
 $gui = GUICreate("Frames", 800, 600,-1,-1,$WS_OVERLAPPEDWINDOW)
 GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
 
 GUISetFont (8,-1,"Arial")
 
 
 Dim $GUIActiveX = GUICtrlCreateObj($oIE, 1, 1,798,580)
 _IENavigate ($oIE, "about:blank")
;_build_menus()
 _build_frames()
 
 
 If $oFrameMain.document.DesignMode = "On" Then
    $oFrameMain.document.DesignMode = "Off"
 Else
     $oFrameMain.document.DesignMode = "On"
        ;$IE_browser.document.execCommand("RemoveParaFormat",false,"null")
  
 EndIf
 
 
 GUISetState ()
 
 While 1
   Sleep(1000) ; Idle around
 WEnd
 
 
 
     Func _build_frames()
         $sHTML = ""
         Out("<HTML>")
         Out("<HEAD>")
         Out("<TITLE>Amba-view</TITLE>")
         Out("<style>FRAMESET{border:0;}</style>")
         Out("</HEAD>")
         Out("<FRAMESET rows=""70,*"">")
         Out("   <FRAME NAME=Menu SRC=about:blank>")
         Out("   <FRAME NAME=Main SRC=about:blank>")
         Out(" </FRAMESET>")
         Out("</HTML>")
 
         _IEDocWriteHTML ($oIE, $sHtml)
         _IEAction ($oIE, "refresh")
          $oFrameMenu = _IEFrameGetObjByName ($oIE, "Menu")
          $oFrameMain = _IEFrameGetObjByName ($oIE, "Main")
         
         Call( _Menu_Html() )
         Call( _Main_Html() )
        
     EndFunc
    
     Func _Main_Html()
         $sHtml = ""
         Out("<HTML>")
         Out("<HEAD>")
         Out("<TITLE>Main</TITLE>")
         Out("<style>body{border:0;background:#FFF;font size:8pt;font-family:arial}")
         Out("table,th,td{font size:11px;border:1px solid;}")
         Out("th{font-weight:bold;}")
         Out("A:link {COLOR: #0000EE;}")
         Out("A:hover {COLOR: #0000EE;}")
         Out("A:visited {COLOR: #0000EE;}")
         Out("A:hover {COLOR: #0000EE;}")
         Out("</style>")
         Out("</HEAD>")
         Out("<body>")
         Out("<p>Frames Template</p>")
         Out("</body>")
         Out("</HTML>")
         _IEDocWriteHTML($oFrameMain,$sHtml)
         _IEAction ($oFrameMain, "refresh")
        
     EndFunc
    
     Func _Menu_Html()
         $sHtml = ""
         Out("<HTML>")
         Out("<HEAD>")
         Out("<TITLE>Menu</TITLE>")
         Out("<style>body{border:0;background:#EEEEEE;font size:8pt;font-family:arial}>")
         Out("A:link {COLOR: #0000EE;}")
         Out("A:hover {COLOR: #0000EE;}")
         Out("A:visited {COLOR: #0000EE;}")
         Out("A:hover {COLOR: #0000EE;}")
         Out(".button {width:28;height:28;background:#232323;COLOR:#fff;font-size:12pt;font-family:Georgia}")
         Out("</style>")
         Out("</HEAD>")
         Out("<body>")
         Out("<form name=""eventform"">")
         Out("<input id=""myevent"" type=hidden>")
         Out("</form>")
         Out("<div id=buttons>")
         Call(_BuildButtons() )
         Out("</div>")
         Out("</body>")
         Out("</HTML>")
         _IEDocWriteHTML($oFrameMenu,$sHtml)
         $myevent = _IEGetObjByName ($oFrameMenu, "myevent")
         $oEvent = ObjEvent( $myevent, "my_Event_")
     EndFunc
 
    
     Func _build_menus()
         $ViewMenu = GUICtrlCreateMenu ("&View")
         GUICtrlCreateMenuitem ("Tables",$ViewMenu)
        ;GUICtrlSetOnEvent(-1, "TablesMenu_clicked")       
         $ReportsMenu = GUICtrlCreateMenu ("&Reports")
         GUICtrlCreateMenuitem ("Open",$ReportsMenu) 
        ;GUICtrlSetOnEvent(-1, "ReportsMenu_clicked")   
     EndFunc
    
     Func _BuildButtons()
         Out("<button name=""bold"" class=button title=""Bold"" unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><u>B</u></button>")
 Out("<button name=""undo"" title=""Undo"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">Q</font></button>")
 Out("<button name=""redo"" title=""Redo"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">P</font></button>")
;Out("<input name=""undo"" value=""?"" type=button class=button unselectable=""on"" onclick=""document.forms['eventform'].myevent.value=this.name;return false;"">")
;Out("<input name=""redo"" value=""?"" type=button class=button unselectable=""on"" onclick=""document.forms['eventform'].myevent.value=this.name;return false;"">")
         Out("<button name=""strikethrough"" title=""Strikethrough"" class=button title='this.name' unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><del>S</del></button>")
         Out("<button name=""underline"" title=""Underline"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><u>U</u></button>")
         Out("<button name=""italic"" title=""Italic"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;"">I</button>")
         Out("<button name=""JustifyLeft"" title=""Justify Left"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">\</font></button>")
         Out("<button name=""JustifyCenter"" title=""Justify Center"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">X</font></button>")
         Out("<button name=""JustifyRight"" title=""Justify Right"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">]</font></button>")
         Out("<button name=""InsertUnorderedList"" title=""Unordered List"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 2"">8</font></button>")
         Out("<button name=""InsertOrderedList"" title=""Ordered List"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 2"">u</font></button>")
         Out("<button name=""Indent"" title=""Indent"" type=button class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">H</font></button>")
         Out("<button name=""Outdent"" title=""Outdent"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">I</font></button>")
         Out("<button name=""Subscript"" title=""Subscript"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">-</font></button>")
         Out("<button name=""Superscript"" title=""Superscript"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');return false;""><font face=""Wingdings 3"">.</font></button>")
 
 
         Out("<button name=""SaveAs"" title=""Save As"" class=button unselectable=""on"" onclick=""parent.document.frames['Menu'].document.execCommand(this.name,false,'mydoc.html');""><font face=""Wingdings""><</font></button>")
         Out("<button name=""cut"" title=""Cut"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.selection.createRange().execCommand(this.name);""><font face=Wingdings>""</font></button>")
         Out("<button name=""Copy"" title=""Copy"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.selection.createRange().execCommand(this.name);""><font face=""Wingdings"">4</font></button>")
        
         Out("<button name=""Paste"" title=""Paste"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.selection.createRange().execCommand(this.name);""><font face=""Wingdings"">2</font></button>")
 
    
         Out("<button name=""InsertImage"" title=""Insert Image"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');return false;""><font face=""Webdings"">Q</font></button>")
         Out("<button name=""CreateLink"" title=""Insert Link"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');return false;""><font face=""Wingdings"">*</font></button>")
 
         Out("<button name=""Open"" title=""Open"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'null');""><font face=""Wingdings"">1</font></button>")
 
         Out("<button name=""RemoveFormat"" title=""Remove Formatting"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');""><font face=""Wingdings 2"">Q</font></button>")
         Out("<button name=""Print"" title=""Print"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,true,'null');""><font face=""Wingdings 2"">6</font></button>")
            
         Out("<button name=""ForeColor"" title=""Font Color"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'#000fff');""><font face=""Wingdings"">?</font></button>")
         Out("<button name=""BackColor"" title=""Back Color"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.execCommand(this.name,false,'#aaaecc');""><font face=""Wingdings"">!</font></button>")
 
         Out("<button name=br title=""Line Break"" class=button unselectable=""on"" onclick=""document.forms['eventform'].myevent.value=this.name;;""><font face=""Wingdings 3"">@</font></button>")
    
     EndFunc
 
     Func my_Event_onpropertychange()
         $query = StringSplit($myevent.value, "&")
        
         Select
             Case $query[1] = "br"
                 Send("+{ENTER}")
             Case Else
                ;MsgBox(0,"",$query[1])
                ;return $oFrameMain.document.execCommand($query[1],false,"null")
         EndSelect    
     EndFunc
    
     Func Out($temp)
         $sHtml &= $temp & @CR
     EndFunc
    
     Func CLOSEClicked()
         Exit   
     EndFunc
Link to comment
Share on other sites

Cool start.. was erroring out for me and found line 147 was shy on double quote added as seen here and viola! works...

The autoit code tags didn't display the & nbsp ; but instead replaced & nbsp ; (spaces added so it displays, remove spaces from actual script) with a single quote".

Line 147 should read:,

Out("<button name=""cut"" title=""Cut"" class=button unselectable=""on"" onclick=""parent.document.frames['Main'].document.selection.createRange().execCommand(this.name);""><font face=Wingdings>& quot;</font></button>")

cheers

edit...that button should read <font face=Wingdings>& quot;</font></button> ; not & nbsp ;

Edited by Will66
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...