bladem2003 Posted Wednesday at 09:46 AM Posted Wednesday at 09:46 AM (edited) I'm opening a new thread for https://www.autoitscript.com/forum/topic/211676-autoithelp-v33161-and-v33180-with-external-css-loading/page/7/#findComment-1549839 It's a decompressed CHM file, created with FAR HTML and a few modifications. Once compiled, it can be included in SciTE and used like AutoIt3Help.exe. AutoitHelpDark0.5.7z Edited Wednesday at 09:46 AM by bladem2003 ioa747 and WildByDesign 2
WildByDesign Posted Wednesday at 01:42 PM Posted Wednesday at 01:42 PM Fantastic work here. Each release keeps improving nicely. I have a suggestion. I personally think that you should delete any of the temp files left behind because they can add up over time. In my original suggestion, I had it waiting for that process to close and delete the single au3 temp file. I think I have a better approach instead of waiting which could be bad. Use OnAutoItExitRegister to run whatever you want when you close your AutoItHelp GUI. This is where you can delete the temp files. If we name them a bit more specifically, it will be easier to delete them without accidentally deleting some other temp files from other programs. In _ExampleTmpFile, I would suggest changing the _TempFile line to the following: $sTemplate = _TempFile(@TempDir, "~AutoItHelp~", ".au3") This way, all temp files created by your AutoItHelp program will start with ~AutoItHelp~, have random after, and end with .au3 of course. Eg. ~AutoItHelp~raxeasu.au3 So in the function that you register with OnAutoItExitRegister, you can make a line that will delete all files in Temp that begin with ~AutoItHelp~ and end with .au3. This way, a user can, for example, run 20-30 examples in your AutoItHelp program and when they close it, it will clean up those files on exit. Anyway, just a suggestion. Keep up the awesome work! bladem2003 1
argumentum Posted Wednesday at 04:48 PM Posted Wednesday at 04:48 PM (edited) The browser I came up with is simpler ( not finished yet ) Spoiler expandcollapse popup#include-once #include <GUIConstantsEx.au3> #include <WindowsStylesConstants.au3> #include <IE.au3> #include <_GUIDarkMode_v0.02mod.au3> If @ScriptName = "AHWD_WebClient_IE.au3" Then Exit AHWD_WebClient_IE() Func AHWD_WebClient_IE($sURL = "http://127.0.0.1:89/Index.htm") Local $sFormTitle = "Helping you help yourself since 1999" If WinExists("AHWD_WebClient_IE_is_running") Then WinActivate($sFormTitle) Return SetError(1, 0, 1) EndIf AutoItWinSetTitle("AHWD_WebClient_IE_is_running") DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) Opt("GUICloseOnESC", 0) ; doesn't work because of _IECreateEmbedded() Opt("GUIOnEventMode", 1) ; more responsive this way Local $iFormW = 800, $iFormH = 600 Local $hForm = GUICreate($sFormTitle, $iFormW, $iFormH, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUISetOnEvent($GUI_EVENT_CLOSE, AHWD_WebClient_IE_Close, $hForm) GUISetBkColor(0x202020) _GUISetDarkTheme($hForm) Local $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 2, 2, $iFormW - 4, $iFormH - 4) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) _IENavigate($oIE, $sURL) _IEAction($oIE, "stop") GUISetState(@SW_SHOW) ;Show GUI While 1 Sleep(100) WEnd GUIDelete() EndFunc ;==>AHWD_WebClient_IE Func AHWD_WebClient_IE_Close() GUIDelete() Exit EndFunc ..because all these GUI buttons are not going to be needed as the HTM will have all that it needs to run the examples ( also not finished, but the code works ) 8 hours ago, bladem2003 said: Once compiled, it can be included in SciTE and used like AutoIt3Help.exe. And with the server side ( also not finished ) once done, the examples will open in the editor of your choosing without any annoyances. P.S.: The OCD got me working on this 😅 Edited Wednesday at 06:13 PM by argumentum better bladem2003 and WildByDesign 2 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted Wednesday at 05:25 PM Posted Wednesday at 05:25 PM These are the changes in the HTM files that I did so far: Spoiler expandcollapse popup<!DOCTYPE html> <html> <head> <title>Function MsgBox</title> <meta charset="utf-8"> <link href="../css/default.css" rel="stylesheet"> <!-- <argumentum start> --> <meta name="AHWD-Server" content="false"> <script type="text/javascript"> function AHWD_Server_check() { const metaTag = document.querySelector('meta[name="AHWD-Server"]'); return metaTag && metaTag.content === "true"; } </script> </head> <!-- <argumentum end> --> <body> <h1 class="small">Function Reference</h1> <hr style="height:0px"> <h1>MsgBox</h1> <p class="funcdesc">Displays a simple message box with optional timeout.<br /></p> <p class="codeheader"> MsgBox ( flag, "title", "text" [, timeout = 0 [, hwnd]] )<br /> </p> <h2>Parameters</h2> <table> <tr> <td style="width:15%">flag</td> <td style="width:85%">The flag indicates the type of message box and the possible button combinations. See remarks.</td> </tr> <tr> <td>title</td> <td>The title of the message box.</td> </tr> <tr> <td>text</td> <td>The text of the message box.</td> </tr> <tr> <td>timeout</td> <td><strong>[optional]</strong> Timeout in seconds. After the timeout has elapsed the message box will close automatically. The default is 0, which is no timeout.</td> </tr> <tr> <td>hwnd</td> <td><strong>[optional]</strong> The window handle to use as the parent for this dialog.</td> </tr> </table> <h2>Return Value</h2> <table class="noborder"> <tr> <td style="width:10%" class="valign-top">Success:</td> <td style="width:90%">the ID of the button pressed.</td> </tr> <tr> <td class="valign-top">Failure:</td> <td>$IDTIMEOUT (-1) if the message box timed out.</td> </tr> </table><br /> <br /><br /> <table> <tr> <td style="width:15%"><strong>Button Pressed</strong></td> <td style="width:85%"><strong>Return Value </strong></td> </tr> <tr> <td>OK</td> <td>$IDOK (1)</td> </tr> <tr> <td>CANCEL</td> <td>$IDCANCEL (2)</td> </tr> <tr> <td>ABORT</td> <td>$IDABORT (3)</td> </tr> <tr> <td>RETRY</td> <td>$IDRETRY (4)</td> </tr> <tr> <td>IGNORE</td> <td>$IDIGNORE (5)</td> </tr> <tr> <td>YES</td> <td>$IDYES (6)</td> </tr> <tr> <td>NO</td> <td>$IDNO (7)</td> </tr> <tr> <td>TRY AGAIN</td> <td>$IDTRYAGAIN (10)</td> </tr> <tr> <td>CONTINUE</td> <td>$IDCONTINUE (11)</td> </tr> </table><br /> Constants are defined in MsgBoxConstants.au3.<br /> <h2>Remarks</h2> <p>The flag parameter can be a combination of the following values:<br /> <br /> <table> <tr> <th><strong>Constant Name</strong></th> <th><strong>Decimal flag</strong></th> <th><strong>Button-related result</strong></th> <th><strong>Hexadecimal flag</a></th> </tr> <tr> <td>$MB_OK</td> <td>0</td> <td>OK button</td> <td>0x0</td> </tr> <tr> <td>$MB_OKCANCEL</td> <td>1</td> <td>OK and Cancel</td> <td>0x1</td> </tr> <tr> <td>$MB_ABORTRETRYIGNORE</td> <td>2</td> <td>Abort, Retry, and Ignore</td> <td>0x2</td> </tr> <tr> <td>$MB_YESNOCANCEL</td> <td>3</td> <td>Yes, No, and Cancel</td> <td>0x3</td> </tr> <tr> <td>$MB_YESNO</td> <td>4</td> <td>Yes and No</td> <td>0x4</td> </tr> <tr> <td>$MB_RETRYCANCEL</td> <td>5</td> <td>Retry and Cancel</td> <td>0x5</td> </tr> <tr> <td>$MB_CANCELTRYCONTINUE</td> <td>6</td> <td>Cancel, Try Again, Continue</td> <td>0x6</td> </tr> <tr> <td>$MB_HELP</td> <td>16384</td> <td>Adds a Help button to the message box. When the user clicks the Help button or presses F1, the system sends a WM_HELP message to the owner.</td> <td>0x4000</td> </tr> <tr> <td><strong>Constant Name</strong></td> <td><strong>decimal flag</strong></td> <td><strong>Icon-related Result</strong></td> <td><strong>hexadecimal flag</a></td> </tr> <tr> <td>$MB_ICONNONE</td> <td>0</td> <td>(No icon)</td> <td>0x0</td> </tr> <tr> <td>$MB_ICONERROR</td> <td>16</td> <td>Stop-sign icon</td> <td>0x10</td> </tr> <tr> <td>$MB_ICONQUESTION</td> <td>32</td> <td>Question-mark icon</td> <td>0x20</td> </tr> <tr> <td>$MB_ICONWARNING</td> <td>48</td> <td>Exclamation-point icon</td> <td>0x30</td> </tr> <tr> <td>$MB_ICONINFORMATION</td> <td>64</td> <td>Information-sign icon consisting of an 'i' in a circle</td> <td>0x40</td> </tr> <tr> <td><strong>Constant Name</strong></td> <td><strong>decimal flag</strong></td> <td><strong>Default-related Result</strong></td> <td><strong>hexadecimal flag</a></td> </tr> <tr> <td>$MB_DEFBUTTON1</td> <td>0</td> <td>First button is default button</td> <td>0x0</td> </tr> <tr> <td>$MB_DEFBUTTON2</td> <td>256</td> <td>Second button is default button</td> <td>0x100</td> </tr> <tr> <td>$MB_DEFBUTTON3</td> <td>512</td> <td>Third button is default button</td> <td>0x200</td> </tr> <tr> <td>$MB_DEFBUTTON4</td> <td>768</td> <td>Fourth button is default button</td> <td>0x300</td> </tr> <tr> <td><strong>Constant Name</strong></td> <td><strong>decimal flag</strong></td> <td><strong>Modality-related Result</strong></td> <td><strong>hexadecimal flag</a></td> </tr> <tr> <td>$MB_APPLMODAL</td> <td>0</td> <td>Application</td> <td>0x0</td> </tr> <tr> <td>$MB_SYSTEMMODAL</td> <td>4096</td> <td>System modal (dialog has an icon)</td> <td>0x1000</td> </tr> <tr> <td>$MB_TASKMODAL</td> <td>8192</td> <td>Task modal</td> <td>0x2000</td> </tr> <tr> <td><strong>Constant Name</strong></td> <td><strong>decimal flag</strong></td> <td><strong>Miscellaneous-related Result</strong></td> <td><strong>hexadecimal flag</a></td> </tr> <tr> <td></td> <td>0</td> <td>(nothing else special)</td> <td>0x0</td> </tr> <tr> <td>$MB_DEFAULT_DESKTOP_ONLY</td> <td>131072</td> <td><a href="MsgBox.htm">MsgBox()</a> shows on the desktop of the interactive window station.</td> <td>0x20000</td> </tr> <tr> <td>$MB_RIGHT</td> <td>524288</td> <td>title and text are right-justified</td> <td>0x80000</td> </tr> <tr> <td>$MB_RTLREADING</td> <td>1048576</td> <td>Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems.</td> <td>0x100000</td> </tr> <tr> <td>$MB_SETFOREGROUND</td> <td>65536</td> <td>The message box becomes the foreground window.</td> <td>0x10000</td> </tr> <tr> <td>$MB_TOPMOST</td> <td>262144</td> <td><a href="MsgBox.htm">MsgBox()</a> has top-most attribute set</td> <td>0x40000</td> </tr> <tr> <td>$MB_SERVICE_NOTIFICATION</td> <td>2097152</td> <td>The function displays a message box on the current active desktop, even if there is no user logged on to the computer.</td> <td>0x200000</td> </tr> </table><br /> For example, to specify a SYSTEMMODAL box with the YES/NO buttons the flag value would be 4096+4 (or 4100) If using hexadecimal flags, that would be 0x1000+0x4 (or 0x1004).<br /> <br /> A message box appears centered on screen and resizes according to the text it contains. However, the title could get truncated if the SYSTEMMODAL flag (4096) is used.<br /> <br /> If "title" is equal to <a href="../keywords/Default.htm">Default keyword</a> @ScriptName is used.<br /> <br /> Special note; MsgBox does not support the use of the timeout parameter when the $MB_SERVICE_NOTIFICATION flag is used when calling MsgBox from a service. The message box window is not owned by the process calling MsgBox when $MB_SERVICE_NOTIFICATION is specified.<br /> <br /> Constants are defined in MsgBoxConstants.au3.<br /> </p> <h2>Related</h2> <p><a href="InputBox.htm">InputBox</a>, <a href="SplashTextOn.htm">SplashTextOn</a>, <a href="ToolTip.htm">ToolTip</a>, <a href="TrayTip.htm">TrayTip</a></p> <h2 class="bottom">Example</h2> <script type="text/javascript"> if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) // IE (4+) only function copyToClipboard(section) { if (window.clipboardData && clipboardData.setData) { clipboardData.setData("text", section + "\r\n"); alert("Copied to clipboard"); } } </script> <h3>Example 1</h3> <div class="codeSnippetContainer"> <div class="codeSnippetContainerTabs"> <script type="text/javascript"> <!-- <argumentum start> --> <!-- if (document.URL.match(/^mk:@MSITStore:/i)) { --> <!-- document.write('<div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr">'); --> <!-- document.write('<object id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><param name="Command" value="ShortCut"><param name="Font" value="Verdana,10pt"><param name="Text" value="Text:Open this Script"><param name="Item1" value=",Examples\\HelpFile\\MsgBox.au3,"></object>'); --> <!-- document.write('<\/div>'); --> <!-- } --> if ( AHWD_Server_check() ) { document.write('<div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr">'); document.write('<a href="Examples\\HelpFile\\MsgBox.au3" id="open-this-example-link">Open this Script</a>'); document.write('<\/div>'); } <!-- <argumentum end> --> </script> </div> <div class="codeSnippetContainerCodeContainer"> <div class="codeSnippetToolBar"> <div class="codeSnippetToolBarText"> <script type="text/javascript"> if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) // IE (4+) only document.write('<a href="#" id="copy" onclick="copyToClipboard(document.getElementById(\'copytext1\').innerText)">Copy to clipboard<\/a>'); </script> </div> </div> <div class="codeSnippetContainerCode" dir="ltr" id="copytext1"> <pre> <span><a class="codeSnippetLink" href="../keywords/include.htm"><span class="S11">#include</span></a><span class="S0"> </span><span class="S7"><MsgBoxConstants.au3></span> <a class="codeSnippetLink" href="../functions/MsgBox.htm"><span class="S4">MsgBox</span></a><span class="S8">(</span><span class="S9">$MB_SYSTEMMODAL</span><span class="S8">,</span><span class="S0"> </span><span class="S7">"Title"</span><span class="S8">,</span><span class="S0"> </span><span class="S7">"This message box will timeout after 10 seconds or select the OK button."</span><span class="S8">,</span><span class="S0"> </span><span class="S3">10</span><span class="S8">)</span> <span class="S0"></span></span> </pre> </div> </div> </div> <h3>Example 2</h3> <div class="codeSnippetContainer"> <div class="codeSnippetContainerTabs"> <script type="text/javascript"> <!-- <argumentum start> --> <!-- if (document.URL.match(/^mk:@MSITStore:/i)) { --> <!-- document.write('<div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr">'); --> <!-- document.write('<object id=hhctrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><param name="Command" value="ShortCut"><param name="Font" value="Verdana,10pt"><param name="Text" value="Text:Open this Script"><param name="Item1" value=",Examples\\HelpFile\\MsgBox[2].au3,"></object>'); --> <!-- document.write('<\/div>'); --> <!-- } --> if ( AHWD_Server_check() ) { document.write('<div class="codeSnippetContainerTab codeSnippetContainerTabSingle" dir="ltr">'); document.write('<a href="Examples\\HelpFile\\MsgBox[2].au3" id="open-this-example-link">Open this Script</a>'); document.write('<\/div>'); } <!-- <argumentum end> --> </script> </div> <div class="codeSnippetContainerCodeContainer"> <div class="codeSnippetToolBar"> <div class="codeSnippetToolBarText"> <script type="text/javascript"> if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) // IE (4+) only document.write('<a href="#" id="copy" onclick="copyToClipboard(document.getElementById(\'copytext2\').innerText)">Copy to clipboard<\/a>'); </script> </div> </div> <div class="codeSnippetContainerCode" dir="ltr" id="copytext2"> <pre> <span><a class="codeSnippetLink" href="../keywords/include.htm"><span class="S11">#include</span></a><span class="S0"> </span><span class="S7"><MsgBoxConstants.au3></span> <a class="codeSnippetLink" href="../keywords/Dim.htm"><span class="S5">Local</span></a><span class="S0"> </span><span class="S9">$iTimeout</span><span class="S0"> </span><a class="codeSnippetLink" href="../intro/lang_operators.htm"><span class="S8">=</span></a><span class="S0"> </span><span class="S3">10</span> <span class="S1">; Display a message box with a nested variable in its text.</span> <a class="codeSnippetLink" href="../functions/MsgBox.htm"><span class="S4">MsgBox</span></a><span class="S8">(</span><span class="S9">$MB_SYSTEMMODAL</span><span class="S8">,</span><span class="S0"> </span><span class="S7">"Title"</span><span class="S8">,</span><span class="S0"> </span><span class="S7">"This message box will timeout after "</span><span class="S0"> </span><span class="S8">&</span><span class="S0"> </span><span class="S9">$iTimeout</span><span class="S0"> </span><span class="S8">&</span><span class="S0"> </span><span class="S7">" seconds or select the OK button."</span><span class="S8">,</span><span class="S0"> </span><span class="S9">$iTimeout</span><span class="S8">)</span> <span class="S0"></span></span> </pre> </div> </div> </div> <!-- <argumentum start> --> <script> document.addEventListener('DOMContentLoaded', function() { var blocker = document.getElementById('click-blocker'); var links = document.querySelectorAll('div > a'); if (!blocker) { console.error("Click-blocker element not found!"); return; } for (var i = 0; i < links.length; i++) { links[i].addEventListener('click', function(e) { if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } var linkUrl = this.getAttribute('href'); blocker.style.display = 'block'; var xhr = new XMLHttpRequest(); var finalUrl = linkUrl + (linkUrl.indexOf('?') !== -1 ? "&" : "?") + "t=" + new Date().getTime(); xhr.open('GET', finalUrl, true); xhr.setRequestHeader('Cache-Control', 'no-cache'); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { setTimeout(function() { blocker.style.display = 'none'; }, 2000); } }; xhr.send(); }); } }); </script> <div id="click-blocker" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; z-index:9999; cursor:not-allowed; background:rgba(255,255,255,0);"></div> </body> <!-- <argumentum end> --> </html> that go from "<!-- <argumentum start> -->" to "<!-- <argumentum end> -->" so it will be simple for you to add to your HTM files. The server side makes AHWD_Server_check() work by changing "AHWD-Server" from "false" to "true". And that check is done so the HTM files can be loaded on any browser without creating any chaos or expectations of functions when not running from our server. When a ".au3" link, the server knows where the example files are at, and loads them in the editor. Sharing all this so that we work together. If I don't tell you what's coming, how are you gonna know As a byproduct of this, the "my examples executes without loading on the editor" complain, will be a thing of the past. bladem2003 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
bladem2003 Posted Wednesday at 05:39 PM Author Posted Wednesday at 05:39 PM That sounds great. I'll wait for your solution... If it helps you in any way, I've created a short video tutorial on how I use FAR HTML. FAR HTML VIDEO TUTORIAL argumentum 1
argumentum Posted Wednesday at 05:45 PM Posted Wednesday at 05:45 PM (edited) This is the "AHWD_WebServer.au3" Spoiler expandcollapse popup#include-once #include <MsgBoxConstants.au3> ; AutoitWebHelpDaemon = AHWD ;~ Global $g__AHWD_sHtmPath = "C:\xampp_v8.2.12\htdocs\AutoitHelpDark\AutoitHelpDark02" ; the root of your help file Global $g__AHWD_sHtmPath = "C:\xampp_v8.2.12\htdocs\AutoitHelpDark\AutoitHelpDark05\AutoitHelpDark2" ; the root of your help file ;~ Global $g__AHWD_sHtmPath = "R:\AutoIt3_TSVN_Copy\svn\trunk\udf_devs\docs\autoit\english\html" ; the root of your help file ; these will have "helper functions" to set, like: AHWD_TCPListen_Port() Global $g__AHWD_TCPListen_IPAddr = "127.0.0.1" Global $g__AHWD_TCPListen_Port = 89 ; will add helper functions for these, later. Global $g__AHWD_TCPListen_Socket = 0 Global $g__AHWD_AutoItRoot = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1) Global $g__AHWD_SciTE = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1) & "\SciTE\SciTE.exe" ;~ ConsoleWriteOut(Null) ; this will stop the "debug gui" from loading ConsoleWriteOut("http://" & $g__AHWD_TCPListen_IPAddr & ":" & $g__AHWD_TCPListen_Port & "/index.htm < to load the index" & @CRLF) ConsoleWriteOut("http://" & $g__AHWD_TCPListen_IPAddr & ":" & $g__AHWD_TCPListen_Port & "/quit < to exit the script" & @CRLF) If @ScriptName = "AHWD_WebServer.au3" Then AHWD_WebServer_Init() ConsoleWriteOut() ; this will keep the "debug gui" open after the script exited EndIf Func AHWD_WebServer_Init() If WinExists("AHWD_WebServer_is_running") Then ConsoleWriteOut("AHWD_WebServer_is_running" & @CRLF) Return SetError(1, 0, 1) EndIf AutoItWinSetTitle("AHWD_WebServer_is_running") Local $iError Opt("TCPTimeout", 5) ; make the site more responsive. Is a local host. TCPStartup() ; Start the TCP service. If @error Then $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "TCPStartup failed, Error code: " & $iError, 60) Return SetError(2, $iError, 2) EndIf ; Assign a variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions. $g__AHWD_TCPListen_Socket = TCPListen($g__AHWD_TCPListen_IPAddr, $g__AHWD_TCPListen_Port, 100) If @error Then $iError = @error ; Someone is probably already listening on this IP Address and Port (script already running?). MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError, 60) Return SetError(3, $iError, 3) EndIf ; Register OnAutoItExit to be called when the script is closed. OnAutoItExitRegister(AHWD_OnAutoItExit) ConsoleWriteOut('- AHWD_WebServer_ServeLoop: ' & AHWD_WebServer_ServeLoop() & @CRLF) AutoItWinSetTitle("AHWD_WebServer_is_not_running") Sleep(100) EndFunc ;==>AHWD_WebServer_Init Func AHWD_WebServer_ServeLoop() If Not $g__AHWD_TCPListen_Socket Then Return SetError(1, 0, 1) Local $iSocket = -1, $sHead, $sBody, $sRequestMethod, $sHTTPVersion, $sRequestTarget, $iTweakType Local $hTimerReqRcvd = TimerInit() Local $iTestSocketCount = 0 Local $sContentTypeOfFile, $buffer, $errTCPRecv, $extTCPRecv ; ..testing. Let's see it in a browser to "inspect" and use: console.log("look, I just did this") ShellExecute("http://" & $g__AHWD_TCPListen_IPAddr & ":" & $g__AHWD_TCPListen_Port & "/index.htm") While 1 If $iSocket = -1 Then $iSocket = TCPAccept($g__AHWD_TCPListen_Socket) ; here it will wait the declared "Opt('TCPTimeout', 20)" If @error Then ; If an error occurred display the error code and return False. $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError) Return SetError(2, $iError, 2) EndIf If $iSocket <> -1 Then ; SideNote: I would fork the socket right here but this is just an example $hTimerReqRcvd = TimerInit() ; so is better to not over complicate it. $iTestSocketCount += 1 ContinueLoop ; As there is a socket, lets attend to it ASAP. EndIf Else $buffer = StringToBinary("") Do If TimerDiff($hTimerReqRcvd) > 2000 Then Return SetError(7, "forgot why I placed this here =/", 7) $bReceived = TCPRecv($iSocket, 12288, 1) ; $TCP_DATA_BINARY (1) - return binary data $errTCPRecv = @error $extTCPRecv = @extended $buffer &= $bReceived Until $extTCPRecv Or $bReceived = "" ; but since this is an example, it shows that there was a connection ( good for debugging ) $hTimerReqRcvd = Round(TimerDiff($hTimerReqRcvd), 2) $hTimerResponse = TimerInit() $buffer = BinaryToString($buffer) If $errTCPRecv Then TCPCloseSocket($iSocket) ; Close the socket. $iSocket = -1 Switch $errTCPRecv Case 10054 ; WSAECONNRESET Case Else ConsoleWriteOut(@CRLF & @TAB & "# " & $iTestSocketCount & " @error,@extended = " & $errTCPRecv & "," & $extTCPRecv & @CRLF & ' >' & $bReceived & '<' & @CRLF) EndSwitch ContinueLoop ElseIf $buffer = "" Then TCPCloseSocket($iSocket) ; Close the socket. $iSocket = -1 ContinueLoop EndIf AHWD_WebServer_GetTheHttpParts($buffer, $sHead, $sBody, $sRequestMethod, $sRequestTarget, $sHTTPVersion) Switch $sRequestTarget Case "/quit" AHWD_HttpSender($iSocket, "Ok, bye bye.", "text") TCPCloseSocket($iSocket) ; Close the socket. $iSocket = -1 AHWD_OnAutoItExit() ; while debugging Return Case Else $sFilename = $g__AHWD_sHtmPath & StringReplace(StringReplace($sRequestTarget, "/", "\"), "%20", " ") $sContentTypeOfFile = AHWD_WebServer_ContentTypeOfFile($sFilename) $iTweakType = @extended Switch $sContentTypeOfFile Case "au3" AHWD_HttpSender($iSocket, "", "", "204 No Content") ; ..could make a link here to load in SciTE. ; It would not load from elsewhere because the path wouldn't be found among the help files. ; food for thought for now $sFilename = AHWD_ExampleInLink($sRequestTarget) ;~ ConsoleWriteOut('+ ' & $sRequestTarget & @TAB & "( " & $sFilename & " )" & @CRLF) Case Else If FileGetSize($sFilename) Then AHWD_HttpSender($iSocket, ($iTweakType = 99 ? AHWD_FileReadAndPatchMeta($sFilename) : FileRead($sFilename)), $sContentTypeOfFile) Else ConsoleWriteOut('! ' & $sRequestTarget & @TAB & "( " & $sFilename & " )" & @CRLF) AHWD_HttpSender($iSocket, StringToBinary("404 ( Not Found ) =(" & @CRLF & @CRLF & $sRequestTarget & @CRLF & @CRLF & "( " & $sFilename & " ) Note to self: Don't show this. 😨 ", 4), "text/plain; charset=utf-8", "404 Not Found") EndIf EndSwitch EndSwitch TCPCloseSocket($iSocket) ; Close the socket. $iSocket = -1 ;~ ConsoleWriteOut('- ' & $hTimerReqRcvd & ' / ' & Round(TimerDiff($hTimerResponse), 2) & ' >' & $sFilename & '<' & @CRLF) EndIf WEnd EndFunc ;==>AHWD_WebServer_ServeLoop Func AHWD_FileReadAndPatchMeta($sFilename) ;~ ConsoleWriteOut('+ Func AHWD_FileReadAndPatchMeta("' & $sFilename & '")' &@CRLF) Return StringReplace(FileRead($sFilename), '<meta name="AHWD-Server" content="false">', '<meta name="AHWD-Server" content="true">') EndFunc ;==>AHWD_FileReadAndPatchMeta Func AHWD_ExampleInLink($sRequestTarget, $sAutoItRoot = $g__AHWD_AutoItRoot) Local $aTemp = StringSplit($sRequestTarget, "?") $sRequestTarget = $aTemp[1] $sRequestTarget = StringReplace(StringReplace($sRequestTarget, "/", "\"), "%20", " ") $sRequestTarget = StringTrimLeft($sRequestTarget, StringInStr($sRequestTarget, "Examples") - 1) ConsoleWriteOut('>' & $sAutoItRoot & "\" & $sRequestTarget & '< ' & FileGetSize($sAutoItRoot & "\" & $sRequestTarget) & @CRLF) If FileGetSize($sAutoItRoot & "\" & $sRequestTarget) Then ShellExecute($g__AHWD_SciTE, '"' & $sAutoItRoot & "\" & $sRequestTarget & '"') EndIf EndFunc ;==>AHWD_ExampleInLink Func AHWD_WebServer_ContentTypeOfFile($sFilename) Local $aTemp = StringSplit($sFilename, "?") Local $sExt = StringTrimLeft($aTemp[1], StringInStr($aTemp[1], ".", 0, -1)) ;~ ConsoleWriteOut('= >' & $sExt & "<" & @CRLF) Switch $sExt Case "au3" Return SetError(0, 100, "au3") Case "ico" Return "image/x-icon" Case "gif" Return "image/gif" Case "png" Return "image/png" Case "jpeg", "jpg" Return "image/jpeg" Case "webp" Return "image/webp" Case "svg" Return "image/svg+xml" Case "json" Return "application/json" Case "js" Return "text/javascript" Case "css" Return "text/css" Case "htm" ; <meta name="AHWD-Server" content="false"> Return SetError(0, 99, "text/html") EndSwitch Return EndFunc ;==>AHWD_WebServer_ContentTypeOfFile Func AHWD_WebServer_GetTheHttpParts(ByRef $sBuffer, ByRef $sHead, ByRef $sBody, ByRef $sRequestMethod, ByRef $sRequestTarget, ByRef $sHTTPVersion) If Not StringInStr($sBuffer, @CRLF & @CRLF) Then Return Local $iPosBody = StringInStr($sBuffer, @CRLF & @CRLF) $sHead = StringLeft($sBuffer, $iPosBody - 1) $sBody = StringTrimLeft($sBuffer, $iPosBody + 3) $sBuffer = "" Local $aHead = StringSplit($sHead, @CRLF, 1) Local $aRequestLine = StringSplit($aHead[1] & " ", " ", 0) $sRequestMethod = $aRequestLine[1] $sRequestTarget = $aRequestLine[2] $sHTTPVersion = $aRequestLine[3] ;~ ConsoleWriteOut('> $sRequestMethod >' & $sRequestMethod & '<' & @CRLF) ;~ ConsoleWriteOut('> $sHTTPVersion >' & $sHTTPVersion & '<' & @CRLF) ;~ ConsoleWriteOut('> $sRequestTarget >' & $sRequestTarget & '<' & @CRLF) ;~ ConsoleWriteOut('> Head >' & $sHead & '<' & @CRLF) ;~ ConsoleWriteOut('> Body >' & StringToBinary($sBody) & '<' & @CRLF) EndFunc ;==>AHWD_WebServer_GetTheHttpParts ; send back a response Func AHWD_HttpSender(ByRef $iSocket, $sData, $ContentType = "text/html", $ResponseStatusCode = "200 OK") Local $bData = Binary($sData) Local $sHead = "HTTP/1.1 " & $ResponseStatusCode & @CRLF ; https://en.wikipedia.org/wiki/List_of_HTTP_status_codes $sHead &= "Content-Type: " & $ContentType & @CRLF ; ..so the client knows what is getting. $sHead &= "X-AHWD-Help-Server: True" & @CRLF ; ..to have the AJAX only run on THIS web server. ;~ $sHead &= "Cache-Control: no-cache" & @CRLF ; "IE11" tends to do "caching" of AJAX requests. This should fix that. $sHead &= "Connection: close" & @CRLF ; ..an interaction takes 5~20 ms. That is fast enought. $sHead &= "Content-Lenght: " & BinaryLen($bData) & @CRLF ; this is a must for binary file send. Might as well use it for everything. $sHead &= @CRLF ; end of header marker AHWD_TCPSendBinary($iSocket, Binary($sHead)) ; Send the head AHWD_TCPSendBinary($iSocket, $bData) ; Send the body ( html or file, as delimited by the header ) EndFunc ;==>AHWD_HttpSender Func AHWD_TCPSendBinary(ByRef $hSocket, ByRef $bData) Local $iBytesSent, $iBytesTotalSent = 0, $iBytesTotal = BinaryLen($bData) Do $iBytesSent = TCPSend($hSocket, $bData) If @error Then ExitLoop $iBytesTotalSent += $iBytesSent $bData = BinaryMid($bData, $iBytesSent + 1, BinaryLen($bData) - $iBytesSent) Until 0 = BinaryLen($bData) Return SetError(0, Int($iBytesTotalSent <> $iBytesTotal), $iBytesTotalSent) EndFunc ;==>AHWD_TCPSendBinary Func AHWD_OnAutoItExit() OnAutoItExitUnRegister(AHWD_OnAutoItExit) ; Close the Listening socket to allow afterward binds. If $g__AHWD_TCPListen_Socket > 0 Then TCPCloseSocket($g__AHWD_TCPListen_Socket) $g__AHWD_TCPListen_Socket = 0 EndIf TCPShutdown() ; Close the TCP service. EndFunc ;==>AHWD_OnAutoItExit Func ConsoleWriteOut($sStr = Default, $iErr = @error, $iExt = @extended) Local Static $hGUI = 0, $idEdit = 0, $iSciTE = StringInStr($CmdLineRaw, "/ErrorStdOut"), $hTimer = TimerInit() If $sStr = Null Then $hGUI = 1 If Not $iSciTE And $hGUI = 0 Then Local $iW = 800, $iH = 400 $hGUI = GUICreate(@ScriptName, $iW, $iH, -1, -1, 0x80CF0000) ; BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP)) GUISetFont(10, 400, 0, "Courier New") GUISetIcon(StringTrimRight(@ScriptFullPath, 4) & ".ico") $idEdit = GUICtrlCreateEdit("", 1, 1, $iW - 1, $iH - 1) GUICtrlSetResizing(-1, 0x0066) ; $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) GUISetState() GUICtrlSetData($idEdit, @CRLF) EndIf Local $iRet = "" If $sStr == Default And IsHWnd($hGUI) Then GUICtrlSetData($idEdit, @CRLF & "== DONE == ( " & Round(TimerDiff($hTimer), 4) & " ms. )", 1) Do Until GUIGetMsg() = -3 GUIDelete($hGUI) Exit Else If $sStr <> Default And $iSciTE Then $iRet = ConsoleWrite($sStr) If $idEdit Then GUICtrlSetData($idEdit, $sStr, 1) EndIf Return SetError($iErr, $iExt, $iRet) EndFunc ;==>ConsoleWriteOut #cs .well-known\appspecific\com.chrome.devtools.json { "workspace": { "uuid": "a-random-version-4-UUID", "root": "path/to/your/project/root/folder" } } https://developer.chrome.com/docs/devtools/workspaces #ce as far as today. You can use it to serve the pages modified as per my last post example and play with it. In the end, I'll do something to not need FAR for building the extra goodies it brings, because all that is really needed are the JS files, and even that I may look at and change as needed ( long after is all functional ). Edited Wednesday at 06:42 PM by argumentum better bladem2003 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted 12 hours ago Posted 12 hours ago (edited) This is a next step. There are things that we need to figure out, like what to do with the SciTE help file, take it apart and make a dark-mode one, it or call from our script ? The script runs from the AutoIt installation folder and that will be better for now ( or always ) since the help related files are there to start with. Most of the files are in "\AutoIt3\AutoIt3HelpWeb_UDFs\". There are only 2 files in the AutoIt's default folder: The launcher ( AutoIt3HelpWeb.au3 ) and the "help file selector / swapper" ( AutoIt3HelpWeb_SwapHandler.au3 ), and that is the easiest way to look at it ( is all there ). The file "AutoIt3HelpWeb.au3" will need to be edited and have your HTM files path declared in "$sHtmlIndexPath" because been in development I have copies of the whole help file structure ... everywhere. Once is all said and done we may end up using a relative path to "\AutoIt3\Extras\" and not declare anything, but we're still coding. The "AutoIt3HelpWeb_SwapHandler.au3" is the easiest thing to run: click-click and you change from the original to the script and vice-versa. Ok, that wrap's it up for now. Give it a try and let's share our ideas. P.S.: the example files used are the same as in the CHM. P.S.S.: ... the scripts in the UDF folder are not standard, but am sure that by the time we're done with this, @WildByDesign will have the dark-mode and Hi-DPI UDFs ready. Will use those then. Any questions, problems or wishes, post them here. I have a wish of my own: The link used to select the help page is "ugly". I Rather make the left iFrame click and load the right iFrame AutoIt3HelpWeb(2026.02.27).zip Edit: forgot about "while..wend", "For ...", etc. Edited 12 hours ago by argumentum donnyh13, ioa747 and bladem2003 3 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted 12 hours ago Posted 12 hours ago Exit test1() Func test1() Local $sType, $iCount = 0, $hTimer = TimerInit() Local $aData = FileReadToArray("C:\xampp_v8.2.12\htdocs\AutoitHelpDark\AutoitHelpDark05\AutoitHelpDark2\hh_toc.htm"), $u1 = UBound($aData) -1 ConsoleWrite('--- ' & $iCount & @TAB &TimerDiff($hTimer) & @CRLF) $hTimer = TimerInit() For $n = 0 To $u1 If Not StringInStr($aData[$n], 'target="right"') Then ContinueLoop $iCount += 1 $sType = "+ " If StringInStr($aData[$n], "%20") Then $sType = "! " ConsoleWrite($sType & $iCount & @TAB & $aData[$n] & @CRLF) Next ConsoleWrite('--- ' & $iCount & @TAB &TimerDiff($hTimer) & @CRLF) EndFunc The way I searched for the "CurrentWord" is slow. Making a map with the about 4000 words, keep it in a file ( that it would build itself on 1st run ) will be faster than the current strategy I implemented. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted 10 hours ago Posted 10 hours ago (edited) ..and, it works beautify in the latest StrelecPE ( a WinPE boot DVD ) ( with the small caveat that right now, it'll find "Func" but not "Return" or "EndFunc" ) Edited 9 hours ago by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted 7 hours ago Posted 7 hours ago 4 hours ago, argumentum said: I have a wish of my own: The link used to select the help page is "ugly". I Rather make the left iFrame click and load the right iFrame ... found a way. I'll have the new version tomorrow Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now