2525
2626; ===[ CONSTANTS ]======================================================================================================
2727 SCRIPTNAME := " DocsEmbedder"
28- SCRIPTVERSION := " 0.1"
28+ SCRIPTVERSION := " 0.1.1 "
2929 HELPWIDTH := 1024
3030 HELPHEIGHT := 500
3131 DOCPATH := ( A_IsCompiled ) ? " res://" A_ScriptFullPath " /index.html" : A_ScriptDir " \docs\site\index.html"
@@ -51,7 +51,7 @@ If ( A_IsCompiled )
5151 GoSub , 1ADDPICTURE
5252Else
5353 ; Gui width: 500. Logo width: 376. To center it (500-376)/2 = 67.
54- Gui , 1 :Add , Picture , x67, %A_ScriptDir %\Logo .png
54+ Gui , 1 :Add , Picture , x67, %A_ScriptDir %\res\logo .png
5555
5656Gui , 1 :Add , GroupBox , w480 h120 x10 y+ 15 , Required Parameters:
5757Gui , 1 :Add , Text , w60 x20 yp + 30 , PE File:
@@ -75,15 +75,15 @@ Return
75751ADDPICTURE :
7676 ; Code based on http://www.autohotkey.com/forum/viewtopic.php?p=147052
7777 Gui , 1 :Add , Text , w376 h110 x67 + 0xE hwnd1TEXT_A_HWND
78- szData := 0 , pData := UpdRes_LockResource(" LOGO.PNG" , 10 , szData)
78+ szData := 0 , pData := UpdRes_LockResource(0 , " RES\ LOGO.PNG" , 10 , szData)
7979 hBitmap := BinGet_Bitmap(pData, szData)
8080 SendMessage , 0x172 , 0 , hBitmap,, ahk_id %1TEXT_A_HWND% ; 0x172 = STM_SETIMAGE, 0 = IMAGE_BITMAP
8181 GuiControl , 1 :Move , %1TEXT_A_HWND%, w376 h110
8282 Return
8383; 1ADDPICTURE
8484
85851DUMMY :
86- FileInstall , Logo .png, DUMMY
86+ FileInstall , res\logo .png, DUMMY
8787 Return
8888; 1DUMMY
8989
@@ -111,13 +111,15 @@ Return
111111 GuiControl , 1 :Disable , 1BTN_C
112112 sFinalFile := 1EDIT_A, sFinalDir := 1EDIT_B
113113
114- If ( sFinalFile == "" || sFinalDir == "" ) {
114+ If ( sFinalFile == "" || sFinalDir == "" )
115+ {
115116 MsgBox , 0x10 , %SCRIPTNAME%, PE File or/ and Html Folder missing.
116117 GuiControl , 1 :Enable , 1BTN_C
117118 Return
118119 }
119120
120- If ( (sErrMsg := CheckDirAndFilenames(sFinalDir, 1CBOX_A)) ! = "" ) {
121+ If ( (sErrMsg := CheckDirAndFilenames(sFinalDir, 1CBOX_A)) ! = "" )
122+ {
121123 MsgBox , 0x10 , %SCRIPTNAME%, %sErrMsg%
122124 GuiControl , 1 :Enable , 1BTN_C
123125 Return
@@ -134,7 +136,7 @@ Return
134136 , PECreateEmpty(sFinalFile)
135137
136138 SB_SetText (" Embedding resources..." )
137- ; 0 = DELETE OLD, 23 = RT_HTML, 0 = NEUTRAL LANG ID
139+ ; DELETE OLD = 0, RT_HTML = 23, NEUTRAL LANG ID = 0
138140 UpdRes_UpdateDirOfResources(sFinalDir, sFinalFile, 0 , 23 , 0 )
139141
140142 ; Remove the temporary folder if the checkboxes are both selected.
@@ -182,14 +184,16 @@ GUICLOSE:
182184; ======================================================================================================================
183185
184186; Check if a directory contains any file.
185- IsDirEmpty (sDir, nRecur:=0 ) {
187+ IsDirEmpty(sDir, nRecur:=0 )
188+ {
186189 Loop , %sDir%\* , 0 , %nRecur%
187190 Return 0
188191 Return 1
189192}
190193
191194; Check directory for emptyness and files for malformed file names (e.g. only numbers).
192- CheckDirAndFilenames (sDir, bFlatten ) {
195+ CheckDirAndFilenames(sDir, bFlatten)
196+ {
193197 sRegex = iS)^ [\d\W]+ (?! \w)
194198
195199 bFlagFlatt := IsDirEmpty(sDir)
@@ -209,10 +213,12 @@ CheckDirAndFilenames(sDir, bFlatten) {
209213}
210214
211215; Move all the files to the root directory, flattening it.
212- FlattenFiles (sDir, sTempDir:="" ) {
216+ FlattenFiles(sDir, sTempDir:="" )
217+ {
213218 If ( isDirEmpty(sDir, 1 ) )
214219 Return 0
215- If ( sTempDir ! = "" ) {
220+ If ( sTempDir ! = "" )
221+ {
216222 If ( InStr (FileExist (sTempDir), " D" ) )
217223 FileRemoveDir , %sTempDir%, 1
218224 FileCopyDir , %sDir%, %sTempDir%, 1
@@ -232,15 +238,17 @@ FlattenFiles(sDir, sTempDir:="") {
232238
233239; Replace the href/src/url attributes inside html and css files.
234240; The directory must be flattened.
235- ReplaceHrefs (sDir ) {
241+ ReplaceHrefs(sDir)
242+ {
236243 sRegex_htm = iS)(?:(href| src)\s* =\s* (" |')\s*[^:" ']* (?:\/| \\))(?=[^ \/ \\:" ']+\s*[" '])
237244 sSubst_htm = $1 =$2
238245 sRegex_css = iS)(?:url\s* \((" |')\s*[^:" ']* (?:\/| \\))(?=[^ \/ \\:" ']+\s*[" '])
239246 sSubst_css = url($1
240247
241248 Loop , %sDir%\* .* ; No recursion.
242249 {
243- If ( InStr (A_LoopFileExt , " htm" ) || InStr (A_LoopFileExt , " css" ) ) {
250+ If ( InStr (A_LoopFileExt , " htm" ) || InStr (A_LoopFileExt , " css" ) )
251+ {
244252 FileRead , sContent, %A_LoopFileLongPath %
245253 sRegex := ( InStr (A_LoopFileExt , " htm" ) ) ? sRegex_htm : sRegex_css
246254 sSubst := ( InStr (A_LoopFileExt , " htm" ) ) ? sSubst_htm : sSubst_css
@@ -252,7 +260,8 @@ ReplaceHrefs(sDir) {
252260}
253261
254262; Show a res:// url in an embedded WebBrowser ActiveX object.
255- ShowBrowser (nW, nH, sGuiName, sResUrl ) {
263+ ShowBrowser(nW, nH, sGuiName, sResUrl)
264+ {
256265 Static 2AX_A, 2AX_A_HWND
257266
258267 Gui , 2 :Destroy
0 commit comments