
FrancoBordin
Members-
Posts
7 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
FrancoBordin's Achievements

Seeker (1/7)
0
Reputation
-
Hi there. I don't exactly know whether this post of mine should be classified as a "suggestion" or "help-request" 😀 Maybe s'thing in between. I hoped i could use " _WD_ExecuteCDPCommand" to call the cdp command "Network.Headers" in order to retrieve the request/response headers of the page/tab currently opened in (and controlled by) a webdriver session (similar to what i usually do for cookies with "_WD_Cookies"). Unfortunately i saw that "Network.Headers" is listed as a "Type" (not as a "method") in the official cdp documentation linked in your post, so i'm currently unable to translate it into actual autoit code in order to perform a test. Here's my sample code Local $sCapabilities = "" If FileExists("geckodriver.exe") Then _WD_UpdateDriver('Firefox') $sCapabilities = Call(SetupGecko, False) ElseIf FileExists("chromedriver.exe") Then _WD_UpdateDriver('Chrome') $sCapabilities = Call(SetupChrome, False) ElseIf FileExists("msedgedriver.exe") Then _WD_UpdateDriver('MSEdge') $sCapabilities = Call(SetupEdge, False) ElseIf FileExists("operadriver.exe") Then _WD_UpdateDriver('Opera') $sCapabilities = Call(SetupOpera, False) EndIf If not StringIsSpace($sCapabilities) Then Local $iWebDriver_PID = _WD_Startup() Local $sSession = _WD_CreateSession($sCapabilities) _WD_Window($sSession, "Maximize") _WD_Navigate($sSession, "http://www.somesite.com") If MsgBox($MB_OKCANCEL + $MB_SYSTEMMODAL + $MB_TOPMOST, "Awaiting confirmation", "Please click <OK> as soon as navigation is completed") = $idOk Then ;retrieving session cookies Local $cCookiesJson = _WD_Cookies($sSession, "GETALL") ;retrieving session last response headers (currently i'm unable to do this) ????????? Endif _WD_DeleteSession($sSession) _WD_Shutdown($iWebDriver_PID) Endif Is that already possible? If not so, here's my implicit suggestion 😀 Ciao Franco P.S.: obviously it would not be a big deal even if should be possibile only on chrome
-
WebDriver UDF (W3C compliant version) - 2024/09/21
FrancoBordin replied to Danp2's topic in AutoIt Example Scripts
Hi there. Yes, in particular something like the first link you posted, but looks like that isn't immediately obtainable from webdriver itself, due to their policy. Quoted from there: "Unfortunately, it doesn't look like you can do that with selenium alone in an automated fashion, as this is against their design principles for selenium. I don't agree that it is (since it supports getting cookie information -- what user actually goes through and parses through their cookies?). I'm actually afraid that what i'm looking for is something out of the autoit udf's developer(s) control due to webdriver API limitations about that specific session info. Hope i'm wrong. Thanks again -
WebDriver UDF (W3C compliant version) - 2024/09/21
FrancoBordin replied to Danp2's topic in AutoIt Example Scripts
Thanks for the answer I need to do that from within a webdriver session because the specific login process must be done interactively with a regular browser. Only after that interactive action by the browser (controlled by webdriver), i need to retrieve some cookies entries as well as some response-headers entries to be subsequently used in winhttp calls. I was obviously already able to retrieve cookies with "_WD_Cookies()", but not the response headers Here's my code: Local $sCapabilities = "" If FileExists("geckodriver.exe") Then _WD_UpdateDriver('Firefox') $sCapabilities = Call(SetupGecko, False) ElseIf FileExists("chromedriver.exe") Then _WD_UpdateDriver('Chrome') $sCapabilities = Call(SetupChrome, False) ElseIf FileExists("msedgedriver.exe") Then _WD_UpdateDriver('MSEdge') $sCapabilities = Call(SetupEdge, False) ElseIf FileExists("operadriver.exe") Then _WD_UpdateDriver('Opera') $sCapabilities = Call(SetupOpera, False) EndIf If not StringIsSpace($sCapabilities) Then Local $iWebDriver_PID = _WD_Startup() Local $sSession = _WD_CreateSession($sCapabilities) _WD_Window($sSession, "Maximize") _WD_Navigate($sSession, "http://www.somesite.com") If MsgBox($MB_OKCANCEL + $MB_SYSTEMMODAL + $MB_TOPMOST, "Awaiting confirmation", "Please click <OK> as soon as navigation is completed") = $idOk Then ;retrieving session cookies Local $cCookiesJson = _WD_Cookies($sSession, "GETALL") ;retrieving session last response headers (currently i'm unable to do this) ????????? Endif _WD_DeleteSession($sSession) _WD_Shutdown($iWebDriver_PID) Endif Thanks again in advance to anybody -
WebDriver UDF (W3C compliant version) - 2024/09/21
FrancoBordin replied to Danp2's topic in AutoIt Example Scripts
Hi Already tried a thorough search of the string "headers" all around the various webdriver related topics (previous 1 to 4 plus this one) The only thing i found was this unanswered question: Since i didn't find a specific webdriver function able to retrieve sent/received headers of the current active webdriver session (something corresponding to the "_WinHttpQueryHeaders" function in the winhttp library), i was wondering wether somebody came up with a workaround for that or not. Thanks in advance -
Hi guys! Using Christian and Tamer ideas i came up with this function to render a text file in pdf with automatic and/or forced pageskipping and basic "inline" color/graphic properties. Let me know if it's useful. P.S.: the only thing i wasn't able to do is to make the pdf "fully saved": once it is created and then opened (with a reader), while closing it, the reader always asks if it has to be saved. I can't find any help on the internet on which tag/objet to put in the pdf in order to be already "saved" ; Function Name: _FileTxtToPDF() ; Description: Creates enriched PDF File from text file ; Parameter(s): $cFileTxt = Path of the txt file to be rendered ; $cFilePdf = Path of the pdf file to be produced (warning: if already existing, it'll be overwritten) ; $cPaperSize = Paper size ("A4" or "A3, default "A4") ; $lLandScape = Use landscape orientation (default False) ; $nVMargin = Top Margin (default (20 mm) ; $nHMargin = Left Margin (default (24 mm) ; $cFont = Font ("Courier", "Times" or "Helvetica") (default "Courier") ; $lBold = (default False) ; $lItalic = (default False) ; $nFontSize = Font size (default = 12) ; $nVSpacing = Vertical spacing (if 0 it'll be calculated from $nFontSize) ; $nHScale = Horizontal scale percentage (stretch/enlarge, default 100) ; $nMaxLines = Max lines per page (if 0 it'll be calculated; if it exceeds the calculated value, the latter will be used) ; $cAuthor = Author (default "unknown") ; $cTitle = Title (default "MyPDF") ; $cPage = "Page number" description for the footer. If null or empty string (which is the default value): no footer; example: "Page n. " ; $cPages = "Total pages" for the footer. If null or empty string (which is the default value): no total pages shown in the footer; example " of " ; $cFollow = Header description for showing the previous page number in the header of each page (excluding the first one). If null or empty string (which is the default value): no header; example: "...follows from page " ; $lEasyRead = (default True) The function places a watermark on pages with horizontal stripes in light cyan in order to improve readability ; $lUtf8 = (default False) That's experimental. The function tries a conversion for utf8 encoded input files in order to properly show special characters ; warning: this process is pretty slow (it processes between 50 and 150 lines per seconds depending on computer performance) ; Syntax for a very basic enrichment of the pdf graphic aspect: ; every line of the input file could include one of more of the following tags: ; {[(bold)]} = force the line to be displayed/printed in "bold" ; {[(italic)]} = force the line to be displayed/printed in "italic" ; {[(normal)]} = force the line to be displayed/printed in "normal" even if the function was called with the bold and/or italic parameter "True" ; {[(red)]} = force the line to be displayed/printed in red stroke ; {[(green)]} = force the line to be displayed/printed in green stroke ; {[(byellow)]} = force the line to be displayed/printed with yellow background ; {[(bgreen)]} = force the line to be displayed/printed with green background ; ; The above tags can be all combined. If one of more of them are identified, they are processed accordingly and then stripped from the output line ; ; {[(newpage)]} = force a new page (be aware that the function forces a newpage by himself everytime the end of page is reached) ; warning: "newpage" tag is the only one that cannot be combined at all and must be the only string in the line (every other line contents are ignored) ; ; Author: www.syse.it ; Based on ideas of Christian Korittke <Christian_Korittke@web.de> and Tamer Hosgör <Tamer@TamTech.info> #include-once #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <Math.au3> #include <File.au3> #include <String.au3> Func _FileTxtToPDF($cFileTxt, $cFilePdf, $cPaperSize = "A4", $lLandScape = False, $nVMargin = 20, $nHMargin = 24, $cFont = "Courier", $lBold = False, $lItalic = False, $nFontSize = 12, $nVSpacing = 0, $nHScale = 100, $nMaxLines = 0, $cAuthor = "unknown", $cTitle = "MyPDF", $cPage = "", $cPages = "", $cFollow = "", $lEasyRead = True, $lUtf8 = False) Global $nConversion = 2.834175 Global $cBlack = "0 0 0" Global $cRed = "1 0 0" Global $cGreen = "0 0.5 0" Global $cbYellow = "1 1 0" Global $cbGreen = "0.4 1 0.4" Global $cbCyan = "0.8 1 1" Global $nFontObjs = 5 ;total number of fonts' objs declared Global $nFixedObjs = 5 ;total number of fixed objs declared Global $nGap = 0 ; difference between filesetpos() returned value and the actual offset needed in xref Local $nRetVal = 2 Local $nCount = 0 Local $aReference[0][2] If $cPaperSize = Default Then $cPaperSize = "A4" Endif If $lLandScape = Default Then $lLandScape = False Endif If $nVMargin = Default Then $nVMargin = 20 Endif If $nHMargin = Default Then $nHMargin = 24 Endif If $cFont = Default Then $cFont = "Courier" Endif If $lBold = Default Then $lBold = False Endif If $lItalic = Default Then $lItalic = False Endif If $nFontSize = Default Then $nFontSize = 12 Endif If $nVSpacing = Default Then $nVSpacing = 0 Endif If $nHScale = Default Then $nHScale = 100 Endif If $nHScale = Default Then $nHScale = 100 Endif If $nMaxLines = Default Then $nMaxLines = 100 Endif If $cAuthor = Default Then $cAuthor = "unknown" Endif If $cTitle = Default Then $cTitle = "MyPdf" Endif If $cPage = Default Then $cPage = "" Endif If $cPages = Default Then $cPages = "" Endif If $cFollow = Default Then $cFollow = "" Endif If $lEasyRead = Default Then $lEasyRead = True Endif If $lUtf8 = Default Then $lUtf8 = False Endif If FileExists($cFileTxt) Then If $cPaperSize = "A4" Then If $lLandScape Then $nHsize = 297 $nVsize = 210 Else $nHsize = 210 $nVsize = 297 EndIf ElseIf $cPaperSize = "A3" Then If $lLandScape Then $nHsize = 420 $nVsize = 297 Else $nHsize = 297 $nVsize = 420 EndIf EndIf Local $cBold = $cFont & "-Bold" Local $cItalic = $cFont & "-Oblique" If $cFont = "Times" Then $cItalic = $cFont & "-Italic" EndIf Local $cBoldItalic = $cFont & "-BoldOblique" If $cFont = "Times" Then $cBoldItalic = $cFont & "-BoldItalic" $cFont = "Times-Roman" ;ElseIf $cFont = "Helvetica" Then ;$cBoldItalic = $cItalic EndIf Local $cNormal = $cFont If $lBold Then If $lItalic Then $cFont = $cBoldItalic Else $cFont = $cBold EndIf ElseIf $lItalic Then $cFont = $cItalic EndIf If $nVSpacing = 0 Then ; default vertical spacing if not declared otherwise If $nFontSize = 8 Then $nVSpacing = 9 ElseIf $nFontSize = 9 Then $nVSpacing = 11 ElseIf $nFontSize = 10 Then $nVSpacing = 12 ElseIf $nFontSize = 11 Then $nVSpacing = 13 ElseIf $nFontSize = 12 Then $nVSpacing = 15 ElseIf $nFontSize = 14 Then $nVSpacing = 17 ElseIf $nFontSize = 16 Then $nVSpacing = 19 ElseIf $nFontSize = 18 Then $nVSpacing = 21 ElseIf $nFontSize = 20 Then $nVSpacing = 24 ElseIf $nFontSize = 22 Then $nVSpacing = 26 ElseIf $nFontSize = 24 Then $nVSpacing = 28 ElseIf $nFontSize = 26 Then $nVSpacing = 30 ElseIf $nFontSize = 28 Then $nVSpacing = 32 ElseIf $nFontSize = 36 Then $nVSpacing = 41 ElseIf $nFontSize = 48 Then $nVSpacing = 55 Else $nVSpacing = Round($nFontSize * 1.18) EndIf EndIf Local $nMaxLinesCalculated = Int(($nVsize - $nVMargin) / $nVSpacing * $nConversion) - 1 If $nMaxLines > 0 Then $nMaxLines = _Min($nMaxLines, $nMaxLinesCalculated) Else $nMaxLines = $nMaxLinesCalculated EndIf Local $nNumOut = FileOpen($cFilePdf, $FO_OVERWRITE + $FO_ANSI) ;MsgBox($MB_SYSTEMMODAL, "show starting offset", FileGetPos($nNumOut)) Local $nNumIn = FileOpen($cFileTxt, $FO_ANSI) ; Umrechnung $nVsize = Round($nVsize * $nConversion) $nHsize = Round($nHsize * $nConversion) $nVMargin = Round($nVMargin * $nConversion) $nHMargin = Round($nHMargin * $nConversion) FileWriteLine($nNumOut, "%PDF-1.2") FileWriteLine($nNumOut, "%âãÏÓ") _ArrayAdd($aReference, "1|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, "1 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Author (" & $cAuthor & ")") FileWriteLine($nNumOut, "/CreationDate (D:" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ")") FileWriteLine($nNumOut, "/Creator (Ahnungslos)") FileWriteLine($nNumOut, "/Producer (Ahnungslos)") FileWriteLine($nNumOut, "/Title (" & $cTitle & ")") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") Local $nObjProg = $nFixedObjs + 1 _ArrayAdd($aReference, String($nObjProg) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nObjProg) & " 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Font") FileWriteLine($nNumOut, "/Subtype /Type1") FileWriteLine($nNumOut, "/Name /STANDARD") FileWriteLine($nNumOut, "/Encoding 4 0 R") FileWriteLine($nNumOut, "/BaseFont /" & $cFont) FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") $nObjProg += 1 _ArrayAdd($aReference, String($nObjProg) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nObjProg) & " 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Font") FileWriteLine($nNumOut, "/Subtype /Type1") FileWriteLine($nNumOut, "/Name /BOLD") FileWriteLine($nNumOut, "/Encoding 4 0 R") FileWriteLine($nNumOut, "/BaseFont /" & $cBold) FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") $nObjProg += 1 _ArrayAdd($aReference, String($nObjProg) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nObjProg) & " 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Font") FileWriteLine($nNumOut, "/Subtype /Type1") FileWriteLine($nNumOut, "/Name /ITA") FileWriteLine($nNumOut, "/Encoding 4 0 R") FileWriteLine($nNumOut, "/BaseFont /" & $cItalic) FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") $nObjProg += 1 _ArrayAdd($aReference, String($nObjProg) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nObjProg) & " 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Font") FileWriteLine($nNumOut, "/Subtype /Type1") FileWriteLine($nNumOut, "/Name /BLDITA") FileWriteLine($nNumOut, "/Encoding 4 0 R") FileWriteLine($nNumOut, "/BaseFont /" & $cBoldItalic) FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") $nObjProg += 1 _ArrayAdd($aReference, String($nObjProg) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nObjProg) & " 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Font") FileWriteLine($nNumOut, "/Subtype /Type1") FileWriteLine($nNumOut, "/Name /NORMAL") FileWriteLine($nNumOut, "/Encoding 4 0 R") FileWriteLine($nNumOut, "/BaseFont /" & $cNormal) FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") _ArrayAdd($aReference, "4|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, "4 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Encoding") FileWriteLine($nNumOut, "/BaseEncoding /WinAnsiEncoding") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") _ArrayAdd($aReference, "5|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, "5 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Font <<") FileWriteLine($nNumOut, "/STANDARD " & String($nFixedObjs + 1) & " 0 R") FileWriteLine($nNumOut, "/BOLD " & String($nFixedObjs + 2) & " 0 R") FileWriteLine($nNumOut, "/ITA " & String($nFixedObjs + 3) & " 0 R") FileWriteLine($nNumOut, "/BLDITA " & String($nFixedObjs + 4) & " 0 R") FileWriteLine($nNumOut, "/NORMAL " & String($nFixedObjs + 5) & " 0 R") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, " /ProcSet [ /PDF /Text ]") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") Local $nLine = 0 Local $nPage = 1 Local $cLine = "" Local $cCodFont = "" ;Local $nTotPages = Int((_FileCountLines($nNumIn) - 1) / $nMaxLines) + 1 FileSetPos($nNumIn, 0, $FILE_BEGIN) Local $nStart = 0 While True $cLine = FileReadLine($nNumIn) If @error = 0 Then Local $lBoldLine = False Local $lItalicLine = False Local $lNormalLine = False Local $lNewPage = False Local $lRed = False Local $lGreen = False Local $lbYellow = False Local $lbGreen = False AnalizeLine($cLine, $lBoldLine, $lItalicLine, $lNewPage, $lRed, $lGreen, $lbYellow, $lbGreen, $lNormalLine) If Not $lNewPage Then $nLine += 1 EndIf If Not $nRetVal = 0 Then $nStart = CreatePageObjects($nNumOut, 0, $aReference, $cFollow, $nVsize, $nVSpacing) $nRetVal = 0 ElseIf $lNewPage Or $nLine > $nMaxLines Then ClosePageObj($nNumOut, $aReference, $nStart, $cPage, $cPages, $nPage, $lEasyRead, $nLine, $nMaxLines, $nVsize, $nVMargin, $nVSpacing, $nHsize) $nStart = CreatePageObjects($nNumOut, $nPage, $aReference, $cFollow, $nVsize, $nVSpacing) $nPage += 1 If $lNewPage Then $nLine = 0 Else $nLine = 1 EndIf EndIf If Not $lNewPage Then $cCodFont = "STANDARD" If $lNormalLine Then $cCodFont = "NORMAL" ElseIf $lBoldLine Then If $lItalicLine Then $cCodFont = "BLDITA" Else $cCodFont = "BOLD" EndIf ElseIf $lItalicLine Then $cCodFont = "ITA" EndIf ;$cCodFont = "2" If $lbYellow Or $lbGreen Or ($lEasyRead And Mod($nLine, 2) = 1) Then Local $cColor = $cbCyan If $lbGreen Then $cColor = $cbGreen ElseIf $lbYellow Then $cColor = $cbYellow EndIf FileWriteLine($nNumOut, $cColor & " rg") FileWriteLine($nNumOut, "0 " & ($nVsize - $nVMargin - ($nVSpacing * $nLine)) - ($nVSpacing / 4) & " " & $nHsize & " " & $nVSpacing & " re") FileWriteLine($nNumOut, "F") EndIf If $lRed Then $cColor = $cRed ElseIf $lGreen Then $cColor = $cGreen Else $cColor = $cBlack EndIf FileWriteLine($nNumOut, "BT") FileWriteLine($nNumOut, $cColor & " rg") FileWriteLine($nNumOut, "/" & $cCodFont & " " & $nFontSize & " Tf") FileWriteLine($nNumOut, $nHScale & " Tz") FileWriteLine($nNumOut, "1 0 0 1 " & $nHMargin & " " & $nVsize - $nVMargin - $nVSpacing * $nLine & " Tm") If $lUtf8 Then $cLine=Utf8toAnsi($cLIne) Endif FileWriteLine($nNumOut, "(" & $cLine & ") Tj") FileWriteLine($nNumOut, "ET") EndIf Else ExitLoop EndIf WEnd FileClose($nNumIn) If $nRetVal = 0 Then ClosePageObj($nNumOut, $aReference, $nStart, $cPage, $cPages, $nPage, $lEasyRead, $nLine, $nMaxLines, $nVsize, $nVMargin, $nVSpacing, $nHsize) EndIf _ArrayAdd($aReference, "2|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, "2 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Catalog") FileWriteLine($nNumOut, "/Pages 3 0 R") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") _ArrayAdd($aReference, "3|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, "3 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Pages") FileWriteLine($nNumOut, "/Count " & String($nPage)) FileWriteLine($nNumOut, "/MediaBox [ 0 0 " & $nHsize & " " & $nVsize & " ]") FileWriteLine($nNumOut, "/Kids [") For $nCount = 0 To ($nPage - 1) FileWriteLine($nNumOut, String($nFixedObjs + $nFontObjs + 1 + ($nCount * 3)) & " 0 R") Next FileWriteLine($nNumOut, "]") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") For $nCount = 0 To UBound($aReference) - 1 $aReference[$nCount][0] = Number($aReference[$nCount][0]) $aReference[$nCount][1] = Number($aReference[$nCount][1]) Next ;_ArrayDisplay($aReference,"before sort") _ArraySort($aReference) ;_ArrayDisplay($aReference,"after sort") Local $nRefPos = FileGetPos($nNumOut) + $nGap FileWriteLine($nNumOut, "xref") FileWriteLine($nNumOut, "0 " & String(UBound($aReference) + 1)) FileWriteLine($nNumOut, "0000000000 65535 f ") For $nCount = 0 To UBound($aReference) - 1 FileWriteLine($nNumOut, StringRight(_StringRepeat("0", 10) & String(Int($aReference[$nCount][1])), 10) & " 00000 n ") Next FileWriteLine($nNumOut, "trailer") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Size " & String(UBound($aReference) + 1)) FileWriteLine($nNumOut, "/Root 2 0 R") FileWriteLine($nNumOut, "/Info 1 0 R") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "startxref") FileWriteLine($nNumOut, String($nRefPos)) FileWriteLine($nNumOut, "%%EOF") FileClose($nNumOut) If Not StringIsSpace($cPage) And Not StringIsSpace($cPages) Then $nNumIn = FileOpen($cFilePdf, $FO_ANSI) $cLine = StringReplace(FileRead($nNumIn), "{[(totpages)]}", String($nPage)) FileClose($nNumIn) $nNumOut = FileOpen($cFilePdf, $FO_OVERWRITE + $FO_ANSI) FileWrite($nNumOut, $cLine) FileClose($nNumOut) EndIf Else $nRetVal = 1 EndIf Return ($nRetVal) EndFunc ;==>_FileTxtToPDF Func CreatePageObjects($nNumOut, $nPage, ByRef $aReference, $cFollow, $nVsize, $nVSpacing) Local $nPageObject = $nFixedObjs + $nFontObjs + 1 + ($nPage * 3) _ArrayAdd($aReference, String($nPageObject) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nPageObject) & " 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Type /Page") FileWriteLine($nNumOut, "/Parent 3 0 R") FileWriteLine($nNumOut, "/Resources 5 0 R") FileWriteLine($nNumOut, "/Contents " & String($nPageObject + 1) & " 0 R") FileWriteLine($nNumOut, "/Rotate 0") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "endobj") $nPageObject += 1 Local $nStart = FileGetPos($nNumOut) _ArrayAdd($aReference, String($nPageObject) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nPageObject) & " 0 obj") FileWriteLine($nNumOut, "<<") FileWriteLine($nNumOut, "/Length " & String($nPageObject + 1) & " 0 R") FileWriteLine($nNumOut, ">>") FileWriteLine($nNumOut, "stream") ;FileWriteLine($nNumOut, "BT") If $nPage > 0 and Not StringIsSpace($cFollow) Then Local $cHeader = $cFollow & String($nPage) FileWriteLine($nNumOut, "BT") FileWriteLine($nNumOut, $cBlack & " rg") FileWriteLine($nNumOut, "/STANDARD 5 Tf") FileWriteLine($nNumOut, "1 0 0 1 5 " & String($nVsize - 5) & " Tm") FileWriteLine($nNumOut, "(" & $cHeader & ") Tj") FileWriteLine($nNumOut, "ET") EndIf Return $nStart EndFunc ;==>CreatePageObjects Func ClosePageObj($nNumOut, ByRef $aReference, $nStart, $cPage, $cPages, $nPage, $lEasyRead, $nLine, $nMaxLines, $nVsize, $nVMargin, $nVSpacing, $nHsize) Local $nPageLengthObject = $nFixedObjs + $nFontObjs + 3 + (($nPage - 1) * 3) Local $nCount = 0 If $lEasyRead Then For $nCount = $nLine + 1 To $nMaxLines If Mod($nCount, 2) = 1 Then FileWriteLine($nNumOut, "0.8 1 1 rg") FileWriteLine($nNumOut, "0 " & ($nVsize - $nVMargin - ($nVSpacing * $nCount)) - ($nVSpacing / 4) & " " & $nHsize & " " & $nVSpacing & " re") FileWriteLine($nNumOut, "F") FileWriteLine($nNumOut, $cBlack & " rg") EndIf Next EndIf FileWriteLine($nNumOut, "0 0 0 rg") If Not StringIsSpace($cPage) Then Local $cFooter = $cPage & String($nPage) If Not StringIsSpace($cPages) Then $cFooter &= $cPages & "{[(totpages)]}" EndIf FileWriteLine($nNumOut, "BT") FileWriteLine($nNumOut, $cBlack & " rg") FileWriteLine($nNumOut, "/STANDARD 5 Tf") FileWriteLine($nNumOut, "1 0 0 1 5 5 Tm") FileWriteLine($nNumOut, "(" & $cFooter & ") Tj") FileWriteLine($nNumOut, "ET") EndIf ;FileWriteLine($nNumOut, "ET") FileWriteLine($nNumOut, "endstream") FileWriteLine($nNumOut, "endobj") Local $nLength = FileGetPos($nNumOut) - $nStart _ArrayAdd($aReference, String($nPageLengthObject) & "|" & FileGetPos($nNumOut) + $nGap) FileWriteLine($nNumOut, String($nPageLengthObject) & " 0 obj") FileWriteLine($nNumOut, String($nLength)) FileWriteLine($nNumOut, "endobj") Return EndFunc ;==>ClosePageObj Func AnalizeLine(ByRef $cLine, ByRef $lBold, ByRef $lItalic, ByRef $lNewPage, ByRef $lRed, ByRef $lGreen, ByRef $lbYellow, ByRef $lbGreen, ByRef $lNormal) If SearchReplaceLine($cLine, "bold") Then $lBold = True EndIf If SearchReplaceLine($cLine, "italic") Then $lItalic = True EndIf If SearchReplaceLine($cLine, "normal") Then $lNormal = True EndIf If SearchReplaceLine($cLine, "newpage") Then $lNewPage = True EndIf If SearchReplaceLine($cLine, "red") Then $lRed = True EndIf If SearchReplaceLine($cLine, "green") Then $lGreen = True EndIf If SearchReplaceLine($cLine, "byellow") Then $lbYellow = True EndIf If SearchReplaceLine($cLine, "bgreen") Then $lbGreen = True EndIf Return EndFunc ;==>AnalizeLine Func SearchReplaceLine(ByRef $cLine, $cTag) Local $cStartTag = "{[(" Local $cEndTag = ")]}" Local $lRetVal = False If StringInStr($cLine, $cStartTag & $cTag & $cEndTag) > 0 Then $lRetVal = True $cLine = StringReplace($cLine, $cStartTag & $cTag & $cEndTag, "") EndIf Return $lRetVal EndFunc ;==>SearchReplaceLine Func Utf8toAnsi($cString) Local $nCount = 0 Local $aSubst[0][3] For $nCount = 161 to 191 _ArrayAdd ( $aSubst, "194|" & $nCount & "|" & $nCount ) Next For $nCount = 192 to 255 _ArrayAdd ( $aSubst, "195|" & ($nCount - 64) & "|" & $nCount ) Next ;_ArrayDisplay($aSubst) For $nCount = 0 To UBound($aSubst, 1) - 1 $cString = StringReplace($cString, Chr($aSubst[$nCount][0]) & Chr($aSubst[$nCount][1]), Chr($aSubst[$nCount][2])) Next Return ($cString) EndFunc ;==>XmlToString
-
Thank you so much! What a dumb i am! I was ever convinced the the CUI option was incompatible with any GUI control, so i thought it was not a valid option (in my case) because my applications run either GUI-interactively (when invoked without positional parameters) and non-interactively (invoked with positiona parameters). Aside from the "syncronous" property, what are exactly the effects of a "CUI" compilation? Thanks again
-
Hi, there. Searched on the forum but wasn't able to find anything about it. Is there any way to force compiled autoit script (exe) to run syncronously? To be more specific: look at this minimal script "MyWait.au3": ------------------------- #include <MsgBoxConstants.au3> Sleep(10000) MsgBox($MB_SYSTEMMODAL, "End", "10 seconds gone!") ------------------------- When i compile to the file "MyWait.exe", and then i run it (under command prompt) like this: c:>MyWait the prompt is immediately restored and after 10 seconds the msgbox appears (it runs asyncronously). Instead, if i run it like this: c:>start /wait "MyWait.exe" The prompt is not restored until the script is entirely processed Is there any way, maybe some autoit directive or so, to force the script to be syncronous by himself, without using the "start /wait" launching mode? Any help appreciated