Jump to content

concept assistance needed


Recommended Posts

I got it running on my home rig with no issues. Hmmm, my laptop needs work.

When I ran it, it gave this in the output field:

>Running:(3.1.1.128):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Program Files\AutoIt3\helptool.au3"    
--> IE.au3 Error from function _IETagNameGetCollection, $_IEStatus_NoMatch
--> COM Error Encountered in helptool.au3
----> $IEComErrorScriptline = 70
----> $IEComErrorNumberHex = 000000A9
----> $IEComErrorNumber = 169
----> $IEComErrorWinDescription = Variable must be of type 'Object'.
----> $IEComErrorDescription = 0
----> $IEComErrorSource = 0
----> $IEComErrorHelpFile = 0
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0

--> IE.au3 Error from function _IETagNameGetCollection, $_IEStatus_NoMatch
--> COM Error Encountered in helptool.au3
----> $IEComErrorScriptline = 70
----> $IEComErrorNumberHex = 000000A9
----> $IEComErrorNumber = 169
----> $IEComErrorWinDescription = Variable must be of type 'Object'.
----> $IEComErrorDescription = 0
----> $IEComErrorSource = 0
----> $IEComErrorHelpFile = 0
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0

C:\Program Files\AutoIt3\beta\Include\IE_T2.0_4.au3 (2216) : ==> Object referenced outside a "With" statement.: 
Case $i_index > - 1 And $i_index < $oTemp.GetElementsByTagName ($s_TagName).length 
Case $i_index > - 1 And $i_index < $oTemp.GetElementsByTagName ($s_TagName)^ ERROR
+>AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 210.082

When I switched between items quickly, it crashed.

I had it running, but from the looks of the code, is it supposed to provide a button to allow for the addition of comments?

Edited by vollyman
Link to comment
Share on other sites

  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Moderators

I got it running on my home rig with no issues. Hmmm, my laptop needs work.

When I ran it, it gave this in the output field:

When I switched between items quickly, it crashed.

I had it running, but from the looks of the code, is it supposed to provide a button to allow for the addition of comments?

The com error is normal, but when you are on a function or keyword you should be getting something like this at the bottom of the page.

Posted Image

Link to comment
Share on other sites

  • Moderators

Ahh! :D now I see. NICE!!! This will work nicely. We should add this to scripts and scraps. GOOD WORK! I need to study to see just on how you did it, for I'm still trying to learn this stuff.

Thanks! I'd like to do some fine tuning before we add it to scripts and scraps. One thing I'd like to add is a separate codebox for the custom example, however I need to talk to JdeB to see what he uses to convert the examples to help file format.
Link to comment
Share on other sites

I noticed on line 22 you had Run("hh.exe " & @ProgramFilesDir & "\AutoIt3\beta\AutoIt.chm") commented out with a note on could not get the below and button to work together. I removed the comment, and it seem to work fine for me. Is this something you fixed and didn't remove the comment, or am I missing something?

edit: I think I understand what you meant. I wonder why the script needs to be running after the helpfile is open.

I did this, and it seemed to fix the problem:

Global _
        $oIE, _
        $sFuncName = "", _
        $sLastName = "", _
        $oButton1, $oParent, _
        $sInstallPath = RegRead("HKEY_LOCAL_MACHINESOFTWAREAutoIt v3AutoIt", "betaInstallDir"), _
        $sExamplePath = $sInstallPath & "ExamplesHelpfileExamples", _
        $sCommentPath = $sInstallPath & "ExamplesHelpfileComments"

IF WinExists("AutoIt Help") = 0 then 
    Run("hh.exe " & @ProgramFilesDir & "AutoIt3betaAutoIt.chm")
    sleep(3000)
endif
WinActivate("AutoIt Help")

HotKeySet("{Esc}", "_Exit")

edit2: I spoke too soon. The buttons stopped working again...sigh..I will try to figure it out, but it will take a while....

Edited by vollyman
Link to comment
Share on other sites

  • Moderators

I actually figured it out the other day, just forgot to update the code. The run command needs a working directory.

; Check to see that the helpfile is open
If Not WinExists("AutoIt Help") Then
    Run("hh.exe " & $sInstallPath & "\AutoIt.chm", $sInstallPath)
    WinWait("AutoIt Help")
EndIf
WinActivate("AutoIt Help")
WinWaitActive("AutoIt Help")
Link to comment
Share on other sites

I would like to add one thing: It would be nice to be able to add more than one example for a custom. I did this, which works fine, but someone with more experience (such as yourself) could be able to shorten the code.

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

Global _
        $oIE, _
        $oButton1, $oParent, _
        $sInstallPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "betaInstallDir"), _
        $sExamplePath = $sInstallPath & "\Examples\Helpfile\Examples\", _
        $sCommentPath = $sInstallPath & "\Examples\Helpfile\Comments\"

HotKeySet("{Esc}", "_Exit")

; Create the directory stores if they don't already exist
DirCreate($sExamplePath)
DirCreate($sCommentPath)

; Check to see that the helpfile is open
If Not WinExists("AutoIt Help") Then
    Run("hh.exe " & $sInstallPath & "\AutoIt.chm", $sInstallPath)
    WinWait("AutoIt Help")
EndIf
WinActivate("AutoIt Help")
WinWaitActive("AutoIt Help")

; Register the IE.au3 Error Handler
_IEErrorHandlerRegister ()

; Attach to the helpfile browser window
$oIE = _IEAttach ("AutoIt Help", "Embedded")
If Not IsObj($oIE) Then
    MsgBox(48, "Error", "Could not attach to the help file.")
    Exit
EndIf

; Set up an event sink so that we can trigger on page loads
$oEvent = ObjEvent($oIE, "Evt_")

; The inital page load is already done... refresh so that event fires
_IEAction ($oIE, "refresh")

; Keep the script running as long as $oIE is a browser object
While __IEIsObjType ($oIE, "browserdom")
    Sleep(50)
WEnd

Func Evt_onload()
   
    ; This function will be fired whenever a new help page loads
   
    ; Get a reference to the first H1 tag, then its text
    Local $o_object = @COM_EventObj
    Local $oSection = _IETagNameGetCollection ($o_object, "h1", 0)
    Local $sSectionName = $oSection.innerText
   
    ; When Section is "Function Reference", the next element is the function name
    ; Get a reference to the function name, then its text
    Local $oFunction = $oSection.nextSibling
    Local $sFuncName = $oFunction.innerText
   
    ; Get a reference to the "Open this Script" button
    ; Then get a reference to its parent which is the codebox
    $oButton1 = _IETagNameGetCollection ($oIE, "OBJECT", 0)
    $oParent = $oButton1.parentElement
   
    Switch $sSectionName
        Case "Introduction"
            Annotate($oSection, "This is an example of helpfile annotation through AutoIt and IE.au3")
        Case "Software License"
            Annotate($oSection, "It doesn't get any better than this...")
        Case "Function Reference", "Keyword Reference"
            Annotate($oSection, "This script allows you to do two things...<br><br>" & _
                    "1. Create a comment for each function.<br>" & _
                    "2. Add your own custom example for each function.")
            _CreateFiles($sFuncName)
            _CreateComment($sFuncName)
            _CreateExample($sFuncName)
            _CreateExample2($sFuncName)
            _CreateExample3($sFuncName)
        Case Else
            ;;;
    EndSwitch
EndFunc   ;==>Evt_onload

Func _CreateFiles($s_FuncName)
    $sExampleFile = $sExamplePath & $s_FuncName & "_Custom_1.au3"
    $sCommentFile = $sCommentPath & $s_FuncName & ".txt"
    If Not FileExists($sExampleFile) Then
        _FileCreate($sExampleFile)
    EndIf
    If Not FileExists($sCommentFile) Then
        _FileCreate($sCommentFile)
    EndIf
EndFunc   ;==>_CreateFiles

Func _CreateExample($s_FuncName)
    ; Create a new element to hold the button
    $oButton2 = $oIE.document.createElement ("")
   
    ; Build the HTML for the button
    If Not IsObj($oButton2) Then Return 0
    $sHTML = "&nbsp;"
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Open Custom Script 1">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Examples\' & $s_FuncName & '_Custom_1.au3,">'
    $sHTML &= '</OBJECT>'
    With $oButton2
        .innerHTML = $sHTML
    EndWith
    ; Insert the button as the next child of the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.appendChild ($oButton2)
   
    Return 1
EndFunc   ;==>_CreateExample

Func _CreateExample2($s_FuncName)
    ; Create a new element to hold the button
    $oButton3 = $oIE.document.createElement ("")
   
    ; Build the HTML for the button
    If Not IsObj($oButton3) Then Return 0
    $sHTML = "&nbsp;"
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Open Custom Script 2">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Examples\' & $s_FuncName & '_Custom_2.au3,">'
    $sHTML &= '</OBJECT>'
    With $oButton3
        .innerHTML = $sHTML
    EndWith
    ; Insert the button as the next child of the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.appendChild ($oButton3)
   
    Return 1
EndFunc   ;==>_CreateExample

Func _CreateExample3($s_FuncName)
    ; Create a new element to hold the button
    $oButton4 = $oIE.document.createElement ("")
   
    ; Build the HTML for the button
    If Not IsObj($oButton4) Then Return 0
    $sHTML = "&nbsp;"
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Open Custom Script 3">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Examples\' & $s_FuncName & '_Custom_3.au3,">'
    $sHTML &= '</OBJECT>'
    With $oButton4
        .innerHTML = $sHTML
    EndWith
    ; Insert the button as the next child of the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.appendChild ($oButton4)
   
    Return 1
EndFunc   ;==>_CreateExample

Func _CreateComment($s_FuncName)
    ; Create a new element to hold the codebox
    $oComment = $oIE.document.createElement ("")
   
    ; Gather previous comments if they exist
    $sCommentFile = $sCommentPath & $s_FuncName & ".txt"
    $sFuncComment = FileRead($sCommentFile)
    If @error Then $sFuncComment = ""
   
    ; Build the HTML for the commentbox
    If Not IsObj($oComment) Then Return 0
    $sHTML = ''
    $sHTML &= '<p><b>Comment</b></p>'
    $sHTML &= '<p class="codebox">'
    $sHTML &= '<br>'
    $sHTML &= $sFuncComment
    $sHTML &= '<br><br>'
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Add Comment">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Comments\' & $s_FuncName & '.txt,">'
    $sHTML &= '</OBJECT>'
    With $oComment
        .innerHTML = $sHTML
    EndWith
   
    ; Insert the commentbox after the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.insertAdjacentElement ("afterEnd", $oComment)
   
    Return 1
EndFunc   ;==>_CreateComment

Func Annotate(ByRef $o_object, $s_text)
    Local $sHTML = ""
    $sHTML &= "<table width=100% bgcolor=yellow>"
    $sHTML &= "<tr bgcolor=blue>"
    $sHTML &= "<td><font size=+1 color=white>Custom Annotation</font></td>"
    $sHTML &= "</tr>"
    $sHTML &= "<tr>"
    $sHTML &= "<td>" & $s_text & "</td>"
    $sHTML &= "</tr>"
    $sHTML &= "</table><br>"
    $o_object.insertAdjacentHTML ("AfterEnd", $sHTML)
    Return 1
EndFunc   ;==>Annotate

Func _Exit()
    Exit
EndFunc   ;==>_Exit
Link to comment
Share on other sites

  • 6 months later...

I haven't used this in a while, but I was trying to go back to it. It used to work, but now, the buttons won't work. Not sure why.

edit: I read in previous post about the buttons not working. I made sure that was added in, and it still doesn't work right.

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

Global _
        $oIE, _
        $oButton1, $oParent, _
        $sInstallPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "betaInstallDir"), _
        $sExamplePath = $sInstallPath & "\Examples\Helpfile\Examples\", _
        $sCommentPath = $sInstallPath & "\Examples\Helpfile\Comments\"

HotKeySet("{Esc}", "_Exit")

; Create the directory stores if they don't already exist
DirCreate($sExamplePath)
DirCreate($sCommentPath)

; Check to see that the helpfile is open
If Not WinExists("AutoIt Help") Then
    Run("hh.exe " & $sInstallPath & "\AutoIt.chm", $sInstallPath)
    WinWait("AutoIt Help")
EndIf
WinActivate("AutoIt Help")
WinWaitActive("AutoIt Help")

; Register the IE.au3 Error Handler
_IEErrorHandlerRegister ()

; Attach to the helpfile browser window
$oIE = _IEAttach ("AutoIt Help", "Embedded")
If Not IsObj($oIE) Then
    MsgBox(48, "Error", "Could not attach to the help file.")
    Exit
EndIf

; Set up an event sink so that we can trigger on page loads
$oEvent = ObjEvent($oIE, "Evt_")

; The inital page load is already done... refresh so that event fires
_IEAction ($oIE, "refresh")

; Keep the script running as long as $oIE is a browser object
While __IEIsObjType ($oIE, "browserdom")
    Sleep(50)
WEnd

Func Evt_onload()
    
    ; This function will be fired whenever a new help page loads
    
    ; Get a reference to the first H1 tag, then its text
    Local $o_object = @COM_EventObj
    Local $oSection = _IETagNameGetCollection ($o_object, "h1", 0)
    Local $sSectionName = $oSection.innerText
    
    ; When Section is "Function Reference", the next element is the function name
    ; Get a reference to the function name, then its text
    Local $oFunction = $oSection.nextSibling
    Local $sFuncName = $oFunction.innerText
    
    ; Get a reference to the "Open this Script" button
    ; Then get a reference to its parent which is the codebox
    $oButton1 = _IETagNameGetCollection ($oIE, "OBJECT", 0)
    $oParent = $oButton1.parentElement
    
    Switch $sSectionName
        Case "Function Reference", "Keyword Reference"
            _CreateFiles($sFuncName)
            _CreateComment($sFuncName)
            _CreateExample($sFuncName)
        Case Else
            ;;;
    EndSwitch
EndFunc   ;==>Evt_onload

Func _CreateFiles($s_FuncName)
    $sExampleFile = $sExamplePath & $s_FuncName & "_Custom.au3"
    $sCommentFile = $sCommentPath & $s_FuncName & ".txt"
    If Not FileExists($sExampleFile) Then
        _FileCreate($sExampleFile)
    EndIf
    If Not FileExists($sCommentFile) Then
        _FileCreate($sCommentFile)
    EndIf
EndFunc   ;==>_CreateFiles

Func _CreateExample($s_FuncName)
    ; Create a new element to hold the button
    $oButton2 = $oIE.document.createElement ("")
    
    ; Build the HTML for the button
    If Not IsObj($oButton2) Then Return 0
    $sHTML = "&nbsp;"
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Open Custom '& $s_FuncName &' Script">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Examples' & $s_FuncName & '_Custom.au3,">'
    $sHTML &= '</OBJECT>'
    With $oButton2
        .innerHTML = $sHTML
    EndWith
    ; Insert the button as the next child of the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.appendChild ($oButton2)
    
    Return 1
EndFunc   ;==>_CreateExample

Func _CreateComment($s_FuncName)
    ; Create a new element to hold the codebox
    $oComment = $oIE.document.createElement ("")
    
    ; Gather previous comments if they exist
    $sCommentFile = $sCommentPath & $s_FuncName & ".txt"
    $sFuncComment = FileRead($sCommentFile)
    If @error Then $sFuncComment = ""
    
    ; Build the HTML for the commentbox
    If Not IsObj($oComment) Then Return 0
    $sHTML = ''
    $sHTML &= '<p><b>Comment</b></p>'
    $sHTML &= '<p class="codebox">'
    $sHTML &= '<br>'
    $sHTML &= $sFuncComment
    $sHTML &= '<br><br>'
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Add Comment">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Comments' & $s_FuncName & '.txt,">'
    $sHTML &= '</OBJECT>'
    With $oComment
        .innerHTML = $sHTML
    EndWith
    
    ; Insert the commentbox after the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.insertAdjacentElement ("afterEnd", $oComment)
    
    Return 1
EndFunc   ;==>_CreateComment

Func _Exit()
    Exit
EndFunc   ;==>_Exit
Edited by Volly
Link to comment
Share on other sites

  • Moderators

I looks like my post with this code in it got screwed up during the forum upgrade (stripped out two "\"s). I clicked edit on the post and they were already there, so I clicked complete edit and they showed up.

p.s. Why not just reference my post with the code rather than reposting it.

Link to comment
Share on other sites

I had made some small changes to it, so I wanted to post what I was using. If you look at the last script, I had cut out some of it that isn't used.

Func Annotate(ByRef $o_object, $s_text)
    Local $sHTML = ""
    $sHTML &= "<table width=100% bgcolor=yellow>"
    $sHTML &= "<tr bgcolor=blue>"
    $sHTML &= "<td><font size=+1 color=white>Custom Annotation</font></td>"
    $sHTML &= "</tr>"
    $sHTML &= "<tr>"
    $sHTML &= "<td>" & $s_text & "</td>"
    $sHTML &= "</tr>"
    $sHTML &= "</table><br>"
    $o_object.insertAdjacentHTML ("AfterEnd", $sHTML)
    Return 1
EndFunc   ;==>AnnotateoÝ÷ Øbëaz'^jâµ»­!Ømz0-¢f¤z+l (ºWfjG¬¢g­Ê¨~ X اÚ(ØZ·
.Ù^¶g¡em¢{ayùr{ax*Þj×Å©©çîËb¢r©àyÛayú%"   b殶­sbb33c·4DÔÂf׳Òb33²fÇCµ$ÒæÖSÒgV÷C´'WGFöâgV÷C²fÇVSÒgV÷CµFWC¤÷Vâ7W7FöÒ67&BgV÷C²fwC²b33oÝ÷ ÚÚ-+ºÚ"µÍÌÍÜÒS  [ÏH    ÌÎNÉÔTSH[YOI][ÝÐ]Û][ÝÈ[YOI][ÝÕ^Ü[ÝÝÛH    ÌÎNÉ[È  ÌÍÜ×Ñ[Ó[YH    [ÉÌÎNÈØÜ  ][ÝÉÝÉÌÎNoÝ÷ ÚÚ-+ºÚ"µÍÝÚ]Ú ÌÍÜÔÙXÝ[Û[YBØÙH    ][ÝÑ[Ý[ÛY[ÙI][ÝË ][ÝÒÙ^]ÛÜY[ÙI][ÝÂÐÜX]Q[Ê ÌÍÜÑ[Ó[YJBÐÜX]PÛÛ[Y[
    ÌÍÜÑ[Ó[YJBÐÜX]Q^[J   ÌÍÜÑ[Ó[YJBØÙH[ÙBÎÎÂ[ÝÚ]Ú

The reason behind this was I didn't know how to address the highlighting on the fly thing. I was hoping to have the highlighting thing work something like this

  • You would highlight what you want with your mouse - basically selecting the text you want as you would in cutting and pasting
  • have a button you click, and the text would then be highlighted in yellow.
I wouldn't know how to do something like that. I see the example of how the text is added, and changed to yellow, but how do you get what you highlighted, and know where to place the highlight? (And make it bulletproof no less) :)

Thanks for the fix for the buttons. I owe you one on that one. :D

Link to comment
Share on other sites

That would work, but how would we keep the changes? Maybe have it write to a txt file the source, then have it reload the next time the page is viewed? or so a compare of the source and the txt file (In case it changed due to a update, and the text was changed in some manner) hmmm...this requires some thought on the best way to approach it :)

Link to comment
Share on other sites

  • 1 year later...

I pulled this oldie but a goodie out of storage, and discovered to my dismay I'm getting a error in IE.au3

>"E:\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\a4mh3\Desktop\autoit scrips\helpPlus\helpPlus.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams  
+>12:57:27 Starting AutoIt3Wrapper v.1.9.2
>Running AU3Check (1.54.10.0)  from:C:\Program Files\AutoIt3
+>12:57:27 AU3Check ended.rc:0
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\a4mh3\Desktop\autoit scrips\helpPlus\helpPlus.au3"  
C:\Program Files\AutoIt3\Include\IE.au3 (4088) : ==> Subscript used with non-Array variable.: 
If IsObj($aRet[4]) Then 
If IsObj($aRet^ ERROR
->12:57:29 AutoIT3.exe ended.rc:1
+>12:57:31 AutoIt3Wrapper Finished
>Exit code: 1   Time: 3.652

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

Global  $oIE, _
        $oButton1, $oParent, _
        $sInstallPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "betaInstallDir"), _
        $sExamplePath = $sInstallPath & "\Examples\Helpfile\Examples\", _
        $sCommentPath = $sInstallPath & "\Examples\Helpfile\Comments\"

HotKeySet("{Esc}", "_Exit")

; Create the directory stores if they don't already exist
DirCreate($sExamplePath)
DirCreate($sCommentPath)

; Check to see that the helpfile is open
If Not WinExists("AutoIt Help") Then
    Run("hh.exe " & $sInstallPath & "\AutoIt.chm", $sInstallPath)
    WinWait("AutoIt Help")
EndIf
WinActivate("AutoIt Help")
WinWaitActive("AutoIt Help")

; Register the IE.au3 Error Handler
_IEErrorHandlerRegister ()

; Attach to the helpfile browser window
$oIE = _IEAttach ("AutoIt Help", "Embedded")
If Not IsObj($oIE) Then
    MsgBox(48, "Error", "Could not attach to the help file.")
    Exit
EndIf

; Set up an event sink so that we can trigger on page loads
$oEvent = ObjEvent($oIE, "Evt_")

; The inital page load is already done... refresh so that event fires
_IEAction ($oIE, "refresh")

; Keep the script running as long as $oIE is a browser object
While __IEIsObjType ($oIE, "browserdom")
    Sleep(50)
WEnd

Func Evt_onload()
    
   ; This function will be fired whenever a new help page loads
    
   ; Get a reference to the first H1 tag, then its text
    Local $o_object = @COM_EventObj
    Local $oSection = _IETagNameGetCollection ($o_object, "h1", 0)
    Local $sSectionName = $oSection.innerText
    
   ; When Section is "Function Reference", the next element is the function name
   ; Get a reference to the function name, then its text
    Local $oFunction = $oSection.nextSibling
    Local $sFuncName = $oFunction.innerText
    
   ; Get a reference to the "Open this Script" button
   ; Then get a reference to its parent which is the codebox
    $oButton1 = _IETagNameGetCollection ($oIE, "OBJECT", 0)
    $oParent = $oButton1.parentElement
    
    Switch $sSectionName
        Case "Introduction"
            Annotate($oSection, "This is an example of helpfile annotation through AutoIt and IE.au3")
        Case "Software License"
            Annotate($oSection, "It doesn't get any better than this...")
        Case "Function Reference", "Keyword Reference"
            Annotate($oSection, "This script allows you to do two things...<br><br>" & _
                    "1. Create a comment for each function.<br>" & _
                    "2. Add your own custom example for each function.")
            _CreateFiles($sFuncName)
            _CreateComment($sFuncName)
            _CreateExample($sFuncName)
        Case Else
           ;;;
    EndSwitch
EndFunc  ;==>Evt_onload

Func _CreateFiles($s_FuncName)
    $sExampleFile = $sExamplePath & $s_FuncName & "_Custom.au3"
    $sCommentFile = $sCommentPath & $s_FuncName & ".txt"
    If Not FileExists($sExampleFile) Then
        _FileCreate($sExampleFile)
    EndIf
    If Not FileExists($sCommentFile) Then
        _FileCreate($sCommentFile)
    EndIf
EndFunc  ;==>_CreateFiles

Func _CreateExample($s_FuncName)
   ; Create a new element to hold the button
    $oButton2 = $oIE.document.createElement ("")
    
   ; Build the HTML for the button
    If Not IsObj($oButton2) Then Return 0
    $sHTML = "&nbsp;"
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Open Custom Script">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Examples' & $s_FuncName & '_Custom.au3,">'
    $sHTML &= '</OBJECT>'
    With $oButton2
        .innerHTML = $sHTML
    EndWith
   ; Insert the button as the next child of the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.appendChild ($oButton2)
    
    Return 1
EndFunc  ;==>_CreateExample

Func _CreateComment($s_FuncName)
   ; Create a new element to hold the codebox
    $oComment = $oIE.document.createElement ("")
    
   ; Gather previous comments if they exist
    $sCommentFile = $sCommentPath & $s_FuncName & ".txt"
    $sFuncComment = FileRead($sCommentFile)
    If @error Then $sFuncComment = ""
    
   ; Build the HTML for the commentbox
    If Not IsObj($oComment) Then Return 0
    $sHTML = ''
    $sHTML &= '<p><b>Comment</b></p>'
    $sHTML &= '<p class="codebox">'
    $sHTML &= '<br>'
    $sHTML &= $sFuncComment
    $sHTML &= '<br><br>'
    $sHTML &= '<OBJECT id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=58 height=57>'
    $sHTML &= '<PARAM name="Command" value="ShortCut">'
    $sHTML &= '<PARAM name="Button" value="Text:Add Comment">'
    $sHTML &= '<PARAM name="Item1" value=",Examples\HelpFile\Comments' & $s_FuncName & '.txt,">'
    $sHTML &= '</OBJECT>'
    With $oComment
        .innerHTML = $sHTML
    EndWith
    
   ; Insert the commentbox after the codebox
    If Not IsObj($oParent) Then Return 0
    $oParent.insertAdjacentElement ("afterEnd", $oComment)
    
    Return 1
EndFunc  ;==>_CreateComment

Func Annotate(ByRef $o_object, $s_text)
    Local $sHTML = ""
    $sHTML &= "<table width=100% bgcolor=yellow>"
    $sHTML &= "<tr bgcolor=blue>"
    $sHTML &= "<td><font size=+1 color=white>Custom Annotation</font></td>"
    $sHTML &= "</tr>"
    $sHTML &= "<tr>"
    $sHTML &= "<td>" & $s_text & "</td>"
    $sHTML &= "</tr>"
    $sHTML &= "</table><br>"
    $o_object.insertAdjacentHTML ("AfterEnd", $sHTML)
    Return 1
EndFunc  ;==>Annotate

Func _Exit()
    Exit
EndFunc  ;==>_Exit
Link to comment
Share on other sites

Caused by a bug in DllCall in 3.2.10.0

It will work with the 3.2.11.* beta.

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

From what I can figure out, the HTML for the _CreateExample($s_FuncName) and _CreateComment($s_FuncName) are not being inserted into the page. In reading, I understand for CreateExample,

With $oButton2

.innerHTML = $sHTML

EndWith

should inject the code into the page, making the button work. For some reason, the code isn't being put into the page. I'm lost on how to fix it.

Edit: I'm noticing the buttons are there, but they are not working. When viewing the source code, you don't se any reference to the button, but it is there. I look at the $sHTML and see the code for it. This is just wierd.

Edited by Volly
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...