Jump to content

Text Editor


Recommended Posts

Outlook Signature Editor:

*Added features: Added LDAP properties for insertion

#include <GUIConstants.au3>
#include <File.au3>
#include <GuiEdit.au3>
#include <IE.au3>
Dim $state
Dim $current 
Dim $Edit
Dim $ret
Global _
        $null, _
        $file, _
        $current
       
$s_html = ""
$s_html &= "<HTML>" & @CRLF
$s_html &= "<HEAD>" & @CRLF
$s_html &= "<TITLE>_IE_Introduction ('basic')</TITLE>" & @CRLF
$s_html &= "</HEAD>" & @CRLF
$s_html &= "<BODY>" & @CRLF
$s_html &= "<font face='Arial'>" & @CRLF
$s_html &= "<table border=1 width=600 id='table1' cellspacing=6 cellpadding=6>" & @CRLF
$s_html &= "<tr>" & @CRLF
$s_html &= "<td>" & @CRLF
$s_html &= "<h1>Welcome to IE.au3</font></h1>" & @CRLF
$s_html &= "IE.au3 is a UDF (User Defined Function) library for the " & @CRLF
$s_html &= "<a href='http://www.autoitscript.com'>AutoIt</a> scripting language." & @CRLF
$s_html &= "<p>  " & @CRLF
$s_html &= "IE.au3 allows you to either create or attach to an Internet Explorer browser and do " & @CRLF
$s_html &= "just about anything you could do with it interactively with the mouse and " & @CRLF
$s_html &= "keyboard, but do it through script." & @CRLF
$s_html &= "<p>" & @CRLF
$s_html &= "You can navigate to pages, click links, fill and submit forms etc. You can " & @CRLF
$s_html &= "also do things you cannot do interactively like change or rewrite page " & @CRLF
$s_html &= "content and Javascripts, read, parse and save page content and monitor and act " & @CRLF
$s_html &= "upon browser 'events'.<p>" & @CRLF
$s_html &= "IE.au3 uses the COM interface in AutoIt to interact with the Internet Explorer " & @CRLF
$s_html &= "object model and the DOM (Document Object Model) supported by the browser." & @CRLF
$s_html &= "<p>" & @CRLF
$s_html &= "You can find much more information at the <a href='http://msdn1.microsoft.com/'>MSDN (Microsoft Developer Network)</a> " & @CRLF
$s_html &= "website and more specifically for the " & @CRLF
$s_html &= "<a href='http://search.msdn.microsoft.com/search/Redirect.aspx?title=InternetExplorer+Object+(Internet+Explorer+-+WebBrowser)"
$s_html &= "&url=http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp'>Internet Explorer Object Model</a> and the " & @CRLF
$s_html &= "<a href='http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp'>Document Object Model</a>." & @CRLF
$s_html &= "</td>" & @CRLF
$s_html &= "</tr>" & @CRLF
$s_html &= "</table>" & @CRLF
$s_html &= "</font>" & @CRLF
$s_html &= "</BODY>" & @CRLF
$s_html &= "</HTML>"

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()
$state = _GUICtrlEditGetModify ($Edit)
$GUItg = GUICreate("HTML Editor", 1230, 768, 190, 114)
GUICtrlCreateObj($oIE, 605, 10, 630, 600)
$Edit = GUICtrlCreateEdit("", 5, 10, 600, 600)
$MenuItem1 = GUICtrlCreateMenu("&File")
$menunew = GUICtrlCreateMenuitem("New", $MenuItem1)
$menuopen = GUICtrlCreateMenuitem("Open", $MenuItem1)
$menusave = GUICtrlCreateMenuitem("Save", $MenuItem1)
$menusaveas = GUICtrlCreateMenuitem("Save As", $MenuItem1)
$menuexit = GUICtrlCreateMenuitem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Edit")
$menuundo = GUICtrlCreateMenuitem("Undo", $MenuItem2)
$menucopy = GUICtrlCreateMenuitem("Copy", $MenuItem2)
$menucut = GUICtrlCreateMenuitem("Cut", $MenuItem2)
$menupaste = GUICtrlCreateMenuitem("Paste", $MenuItem2)
$menudelete = GUICtrlCreateMenuitem("Delete", $MenuItem2)
$menuoptions = GUICtrlCreateMenu("&Options")
$MenuItem3 = GUICtrlCreateMenu("&Insert")
$menusalutation = GUICtrlCreateMenuitem("Salutation", $MenuItem3)
$menufullname = GUICtrlCreateMenuitem("Full Name", $MenuItem3)
$menudepartment = GUICtrlCreateMenuitem("Department", $MenuItem3)
$menuofficenumber = GUICtrlCreateMenuitem("Office Number", $MenuItem3)
$menumobilenumber = GUICtrlCreateMenuitem("Mobile Number", $MenuItem3)
$menuemailaddress = GUICtrlCreateMenuitem("Email Address", $MenuItem3)
$menustreetaddress = GUICtrlCreateMenuitem("Street Address", $MenuItem3)
$menucity = GUICtrlCreateMenuitem("City", $MenuItem3)
$menustate = GUICtrlCreateMenuitem("State", $MenuItem3)
$menuzipcode = GUICtrlCreateMenuitem("Zipcode", $MenuItem3)
$menucountry = GUICtrlCreateMenuitem("Country", $MenuItem3)
$menudisclaimer = GUICtrlCreateMenuitem("Disclaimer", $MenuItem3)
$menufirstname = GUICtrlCreateMenuitem("First Name", $MenuItem3)
$menulastname = GUICtrlCreateMenuitem("Last Name", $MenuItem3)
$menufaxnumber = GUICtrlCreateMenuitem("Fax Number", $MenuItem3)
$MenuItem4 = GUICtrlCreateMenu("&About")
$menuabout = GUICtrlCreateMenuitem("About", $MenuItem4)
GUISetState()

_IENavigate($oIE, "about:blank")

GUICtrlSetData($Edit, $s_html)
_Update()


While 1
$msg = GUIGetMsg()
       $state = _GUICtrlEditGetModify ($Edit)
   If ($state <> $current) Then
      If ($state == 0) Then

    
        Else
            _Update()
      EndIf
  EndIf
    $ret = _GUICtrlEditCanUndo($Edit)
    Select
        Case $msg = $menuexit
            Exit
        Case $msg = $menusaveas
            $file = FileSaveDialog("Choose a file to save", "", "All Files (*.*)", 16)
            $path = _PathSplit($file, $null, $null, $null, $null)
            If $path[4] = "" Then
                $file = $file & ".txt"
                _FileCreate($file)
                FileWrite($file, GUICtrlRead($Edit))
                _Update()
            Else
                _FileCreate($file)
                FileWrite($file, GUICtrlRead($Edit))
                _Update()
            EndIf
        Case $msg = $menusave
            If $file = "" Then
                $file = FileSaveDialog("Choose a file to save", "", "All Files (*.*)", 16)
                $path = _PathSplit($file, $null, $null, $null, $null)
                If $path[4] = "" Then
                    $file = $file & ".txt"
                    FileOpen($file, 2)
                    _FileCreate($file)
                    FileWrite($file, GUICtrlRead($Edit))
                    _Update()
                Else
                    _FileCreate($file)
                    FileWrite($file, GUICtrlRead($Edit))
                    _Update()
                EndIf
            Else
                FileOpen($file, 2)
                FileWrite($file, GUICtrlRead($Edit))
                _Update()
            EndIf
        Case $msg = $menunew
            GUICtrlSetData($Edit, "")
            $file = ""
        Case $msg = $menuopen
            $file = FileOpenDialog("Open a file", "", "All Files (*.*)")
            GUICtrlSetData($Edit, FileRead($file))
            _Update()
        Case $msg = $menusalutation
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;salutation&gt;")
            _Update()
        Case $msg = $menufullname
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;fullname&gt;")
            _Update()
        Case $msg = $menudepartment
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;department&gt;")
            _Update()
        Case $msg = $menuemailaddress
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;emailaddress&gt;")
            _Update()
        Case $msg = $menuofficenumber
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;officenumber&gt;")
            _Update()
        Case $msg = $menumobilenumber
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;mobilenumber&gt;")
            _Update()
        Case $msg = $menustreetaddress
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;streetaddress&gt;")
            _Update()
        Case $msg = $menucity
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;city&gt;")
            _Update()
        Case $msg = $menustate
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;state&gt;")
            _Update()
        Case $msg = $menuzipcode
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;zipcode&gt;")
            _Update()
        Case $msg = $menucountry
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;country&gt;")
            _Update()
        Case $msg = $menudisclaimer
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;disclaimer&gt;")
            _Update()
        Case $msg = $menufirstname
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;firstname&gt;")
            _Update()
        Case $msg = $menulastname
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;lastname&gt;")
            _Update()
        Case $msg = $menufaxnumber
            _GUICtrlEditReplaceSel ( $Edit, 1, "&lt;faxnumber&gt;")
            _Update()
        Case $msg = $menuundo
            If ($ret <> $current) Then
                If $ret == 0 Then
                    MsgBox(0, "Error", "Nothing to Undo")
                Else
                    _GUICtrlEditUndo($Edit)
                    $ret = $current
                EndIf
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd


Func Gui()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
EndFunc   ;==>Gui

Func _Update()
        _IEBodyWriteHTML($oIE, GUICtrlRead($Edit))
EndFunc   ;==>_Update
Edited by joshiieeii
Link to comment
Share on other sites

  • Moderators

The code is horrible, but it does what you are wanting.

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

Global _
        $null, _
        $file, _
        $current
        
$s_html = ""
$s_html &= "<HTML>" & @CRLF
$s_html &= "<HEAD>" & @CRLF
$s_html &= "<TITLE>_IE_Introduction ('basic')</TITLE>" & @CRLF
$s_html &= "</HEAD>" & @CRLF
$s_html &= "<BODY>" & @CRLF
$s_html &= "<font face='Arial'>" & @CRLF
$s_html &= "<table border=1 width=600 id='table1' cellspacing=6 cellpadding=6>" & @CRLF
$s_html &= "<tr>" & @CRLF
$s_html &= "<td>" & @CRLF
$s_html &= "<h1>Welcome to IE.au3</font></h1>" & @CRLF
$s_html &= "IE.au3 is a UDF (User Defined Function) library for the " & @CRLF
$s_html &= "<a href='http://www.autoitscript.com'>AutoIt</a> scripting language." & @CRLF
$s_html &= "<p>  " & @CRLF
$s_html &= "IE.au3 allows you to either create or attach to an Internet Explorer browser and do " & @CRLF
$s_html &= "just about anything you could do with it interactively with the mouse and " & @CRLF
$s_html &= "keyboard, but do it through script." & @CRLF
$s_html &= "<p>" & @CRLF
$s_html &= "You can navigate to pages, click links, fill and submit forms etc. You can " & @CRLF
$s_html &= "also do things you cannot do interactively like change or rewrite page " & @CRLF
$s_html &= "content and Javascripts, read, parse and save page content and monitor and act " & @CRLF
$s_html &= "upon browser 'events'.<p>" & @CRLF
$s_html &= "IE.au3 uses the COM interface in AutoIt to interact with the Internet Explorer " & @CRLF
$s_html &= "object model and the DOM (Document Object Model) supported by the browser." & @CRLF
$s_html &= "<p>" & @CRLF
$s_html &= "You can find much more information at the <a href='http://msdn1.microsoft.com/'>MSDN (Microsoft Developer Network)</a> " & @CRLF
$s_html &= "website and more specifically for the " & @CRLF
$s_html &= "<a href='http://search.msdn.microsoft.com/search/Redirect.aspx?title=InternetExplorer+Object+(Internet+Explorer+-+WebBrowser)"
$s_html &= "&url=http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp'>Internet Explorer Object Model</a> and the " & @CRLF
$s_html &= "<a href='http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp'>Document Object Model</a>." & @CRLF
$s_html &= "</td>" & @CRLF
$s_html &= "</tr>" & @CRLF
$s_html &= "</table>" & @CRLF
$s_html &= "</font>" & @CRLF
$s_html &= "</BODY>" & @CRLF
$s_html &= "</HTML>"

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()

$GUItg = GUICreate("HTML Editor", 800, 600, 190, 114)
GUICtrlCreateObj($oIE, 10, 10, 780, 370)
$Edit = GUICtrlCreateEdit("", 10, 390, 780, 180)
$MenuItem1 = GUICtrlCreateMenu("&File")
$menunew = GUICtrlCreateMenuitem("New", $MenuItem1)
$menuopen = GUICtrlCreateMenuitem("Open", $MenuItem1)
$menusave = GUICtrlCreateMenuitem("Save", $MenuItem1)
$menusaveas = GUICtrlCreateMenuitem("Save As", $MenuItem1)
$menuexit = GUICtrlCreateMenuitem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Edit")
$menuundo = GUICtrlCreateMenuitem("Undo", $MenuItem2)
$menucopy = GUICtrlCreateMenuitem("Copy", $MenuItem2)
$menucut = GUICtrlCreateMenuitem("Cut", $MenuItem2)
$menupaste = GUICtrlCreateMenuitem("Paste", $MenuItem2)
$menudelete = GUICtrlCreateMenuitem("Delete", $MenuItem2)
$menuoptions = GUICtrlCreateMenu("&Options")
$MenuItem3 = GUICtrlCreateMenu("&About")
$menuabout = GUICtrlCreateMenuitem("About", $MenuItem3)
GUISetState()

_IENavigate($oIE, "about:blank")

GUICtrlSetData($Edit, $s_html)
While 1
    $msg = GUIGetMsg()
    Menu()
    Gui()
    _Update()
    Sleep(10)
WEnd

Func Menu()
    $ret = _GUICtrlEditCanUndo($Edit)
    Select
        Case $msg = $menuexit
            Exit
        Case $msg = $menusaveas
            $file = FileSaveDialog("Choose a file to save", "", "All Files (*.*)", 16)
            $path = _PathSplit($file, $null, $null, $null, $null)
            If $path[4] = "" Then
                $file = $file & ".txt"
                _FileCreate($file)
                FileWrite($file, GUICtrlRead($Edit))
            Else
                _FileCreate($file)
                FileWrite($file, GUICtrlRead($Edit))
            EndIf
        Case $msg = $menusave
            If $file = "" Then
                $file = FileSaveDialog("Choose a file to save", "", "All Files (*.*)", 16)
                $path = _PathSplit($file, $null, $null, $null, $null)
                If $path[4] = "" Then
                    $file = $file & ".txt"
                    FileOpen($file, 2)
                    _FileCreate($file)
                    FileWrite($file, GUICtrlRead($Edit))
                Else
                    _FileCreate($file)
                    FileWrite($file, GUICtrlRead($Edit))
                EndIf
            Else
                FileOpen($file, 2)
                FileWrite($file, GUICtrlRead($Edit))
            EndIf
        Case $msg = $menunew
            GUICtrlSetData($Edit, "")
            $file = ""
        Case $msg = $menuopen
            $file = FileOpenDialog("Open a file", "", "All Files (*.*)")
            GUICtrlSetData($Edit, FileRead($file))
        Case $msg = $menuabout
            MsgBox(0, "About", "Testing")
        Case $msg = $menuundo
            If ($ret <> $current) Then
                If $ret == 0 Then
                    MsgBox(0, "Error", "Nothing to Undo")
                Else
                    _GUICtrlEditUndo($Edit)
                    $ret = $current
                EndIf
            EndIf
    EndSelect
EndFunc   ;==>Menu

Func Gui()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
EndFunc   ;==>Gui

Func _Update()
    _IEBodyWriteHTML($oIE, GUICtrlRead($Edit))
EndFunc   ;==>_Update
Link to comment
Share on other sites

  • Moderators

Awesome, Thanks Big Daddy!! **wait...that sounds kinda weird...lol :whistle:

*Edit: It's really cool that it's a real time HTML editor BTW..

Yeah I know, you had a good idea there. If and when I get some free time (our Exchange Server is down) I might try to add something like that to Vals IE Builder.
Link to comment
Share on other sites

Well, I have another reason....I am trying to make a signature creator for my Outlook Project below....I have to be make an interface so that it is a bit easier to create the signature code. For instance, I have to relplace all the <,>,& with their rich text code for so that OWA can use it. I am attempting to automate this so I don't have to edit so much manually.

Link to comment
Share on other sites

There are a large group of WYSIWYG editors listed here

Many are free Javascript, client side implementations that I have wanted to test out in integration with IE.au3 for some time but have not had the time to devote.

Take a look and see if any of them inspire you...

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

There are a large group of WYSIWYG editors listed here

Many are free Javascript, client side implementations that I have wanted to test out in integration with IE.au3 for some time but have not had the time to devote.

Take a look and see if any of them inspire you...

Dale

Hmm... I am checking it out now, I will see what I can come up with. :whistle:

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...