SatyaGanesh

How to send ; from autoit ?

12 posts in this topic

Hello All

 

I wanted to generate a HTML table report from data given in text file (a.txt). This i am doing by :

1. Reading data from "a.txt"

1. Writing HTML code from "FileWriteLine" command into "xxx.txt" (taking a.txt data as reference i will be building html code.

2. Renaming the "xxx.txt" to "xxx.html" using "FileCopy" command.

 

Problem is HTML code contains many special characters which cannot be used in autoit like    ;    and  " Can you please let me know how to send these characters in file write line command ?

 

the desired output i.e "xxx.txt" is attached. Please help me!

THANKS

 

latest - Copy.txt

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Use HTML encoding as described here.

Means: Instead of ";" write "&#59;" to your file.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Could you post an example of initial "a.txt" file ?

Share this post


Link to post
Share on other sites

Thank You all .. currently i am following the solution given by JohnOne  

Hi Mikell please check the attached example "a.txt" file.

 

Thank you very much ... :)

Results.txt

Share this post


Link to post
Share on other sites

Well, not 100% sure if this id what you want, but it's for the concept  :)
[be careful when mixing single and double quotes]

#include <File.au3>
#include <Array.au3>

Local $aArray, $n = 0

$sFilePath = @scriptdir & "\Results.txt"
$sFileResult = @scriptdir & "\Results.html"

_FileReadToArray($sFilePath, $aArray, $FRTA_NOCOUNT, @TAB)
;_ArrayDisplay($aArray)

Local $html = "<html><head><meta content='text/html charset=ISO-8859-1'http-equiv='content-type'><title>AUTO-LOGGER Result History</title></head><img src=C:\Autologger\arh.png></big></td></tr></tbody></table><br style='font-family: Calibri'><big style='font-family: Calibri font-weight: bold'> </big>"
$html &= '<br style="font-family: Calibri;"><table style="text-align: left; font-family: Calibri; width: 1285px; height: 40px;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Order</td><td style="background-color: rgb(204, 204, 204); font-weight: bold; width: 550px; text-align: center;">    Test Case</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;">Result</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Seq-ID</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;">Binary</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;">Location</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;">Setup</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Hour</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Day</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Month</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Year</td></tr>'

For $i = 1 to UBound($aArray)-1
    $n += 1
    $html &= '<tr>'
    $html &= '<td style="text-align: center;">' & $n & '</td>'
    For $j = 0 to UBound($aArray, 2)-1
       $html &= '<td style="text-align: center;">' & $aArray[$i][$j] & '</td>'
    Next
    $html &= '</tr>'
Next
$html &= '</tbody></table><br style="font-family: Arial;"></body></html>'

Filewrite($sFileResult, $html)
ShellExecute($sFileResult)

 

Share this post


Link to post
Share on other sites

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Just tripple your quotes

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thank You Mikell

I am also following similar type of script: 

The good thing is html also accepts ' instead of "

Now my question is how to get this html data in pdf as well as xls format ? can you help me in that ?

SCITE:

#include <File.au3>
#include <Array.au3>

Local $lines = _FileCountLines(@ScriptDir & "\Results.txt")
            FileWriteLine("C:\Autologger\Result-Historyhtm.txt", "<html><head><meta content='text/html charset=ISO-8859-1'http-equiv='content-type'><title>AUTO-LOGGER Result History</title></head><img src=C:\Autologger\arh.png></big></td></tr></tbody></table><br style='font-family: Calibri'><big style='font-family: Calibri font-weight: bold'> </big><br style='font-family: Calibri'><table style='text-align: left; font-family: Calibri; width: 1285px; height: 40px;' border='1' cellpadding='2' cellspacing='2'><tbody><tr><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Order</td><td style='background-color: rgb(204, 204, 204); font-weight: bold; width: 550px; text-align: center;'>    Test Case</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;'>Result</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Seq-ID</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;'>Binary</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;'>Location</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;'>Setup</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Hour</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Day</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Month</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Year</td></tr>")
            For $a = 2 To $lines Step 1
                $resultline = StringSplit(FileReadLine(@ScriptDir & "\Results.txt", $a), "    ")
                $resultline[0] = "<tr><td style='width: 99px; text-align: center;'>" & $a - 1 & "</td>"
                $resultline[1] = "<td style='text-align: left; width: 536px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & $resultline[1] & "</td>"
                $resultline[2] = "<td style='text-align: center; width: 128px;'>" & $resultline[2] & "</td>"
                $resultline[3] = "<td style='text-align: center; width: 128px;'>" & $resultline[3] & "</td>"
                $resultline[4] = "<td style='text-align: center; width: 250px;'>" & $resultline[4] & "</td>"
                $resultline[5] = "<td style='text-align: center; width: 450px;'><a href=file:///" & StringReplace($resultline[5], " ", "%20") & " ><i>" & $resultline[5] & "</i></a></td>"
                $resultline[6] = "<td style='text-align: center; width: 128px;'>" & $resultline[6] & "</td>"
                $resultline[7] = "<td style='text-align: center; width: 99px;'>" & $resultline[7] & "</td>"
                $resultline[8] = "<td style='text-align: center; width: 99px;'>" & $resultline[8] & "</td>"
                $resultline[9] = "<td style='text-align: center; width: 99px;'>" & $resultline[9] & "</td>"
                $resultline[10] = "<td style='text-align: center; width: 99px;'>" & $resultline[10] & "</td></tr>"
                $resultline1 = _ArrayToString($resultline, "")
                FileWriteLine(@ScriptDir & "\Result-Historyhtm.txt", $resultline1)
            Next
            FileWriteLine(@ScriptDir & "\Result-Historyhtm.txt", "</tbody></table><br style='font-family: Arial;'></body></html>")
            FileCopy(@ScriptDir & "\Result-Historyhtm.txt", @ScriptDir & "\AUTO-LOGGER_Result-History.html", 1)
ShellExecute(@ScriptDir & "\AUTO-LOGGER_Result-History.html", 1)
FileDelete(@ScriptDir & "\Result-Historyhtm.txt")

 

Edited by JLogan3o13
adding code

Share this post


Link to post
Share on other sites

@SatyaGanesh in the future, please enclose your code in a block (<> symbol on the toolbar) to make it easier to read. I have done so for you in the post above ;)

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

To export it to Excel please use the Excel UDF that comes with AutoIt. You can then export it from Excel to PDF using function _Excel_Export.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

  • Similar Content

    • algiuxas
      By algiuxas
      Hello everybody!
      I get these weird errors in SciTE console:
      [0801/210405:ERROR:tcp_socket_win.cc(335)] bind() returned an error: Only one usage of each socket address (protocol/network address/port) is normally permitted. (0x2740) [0801/210405:ERROR:devtools_http_handler.cc(229)] Cannot start http server for devtools. Stop devtools. [0801/210405:ERROR:browser_gpu_channel_host_factory.cc(119)] Failed to launch GPU process. [0801/210405:ERROR:browser_gpu_channel_host_factory.cc(119)] Failed to launch GPU process. My script:
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> #NoTrayIcon $title = "Hello" $txt = "..." ; TODO: Make 4 of them ;~ #Region ### START Koda GUI section ### Form= ;~ $1_GUI = GUICreate($title, 370, 120, -1, -1) ;~ GUISetBkColor(0xFFFFFF) ;~ $1_B1 = GUICtrlCreateButton("B1", 136, 80, 107, 25) ;~ GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") ;~ $1_B2 = GUICtrlCreateButton("B2", 248, 80, 107, 25) ;~ GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") ;~ GUICtrlCreateLabel($txt, 16, 24, 338, 52) ;~ GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") ;~ GUICtrlSetColor(-1, 0x000000) ;~ GUISetState(@SW_SHOW) ;~ #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form= $2_GUI = GUICreate($title, 370, 0?"Hi :)":120, -1, -1) GUISetBkColor(0xFFFFFF) $2_B1 = GUICtrlCreateButton("B1", 136, 80, 107, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $2_B2 = GUICtrlCreateButton(0?":D":"B2", 248, 80, 107, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel($txt, 16, 24, 338, 52) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $u32dll = DllOpen("user32.dll") ;~ Opt("GUIOnEventMode", 1) ;~ GUICtrlSetOnEvent(-3, "_Exit") ; TODO: Fix, doesn't work with 2 GUI at the same time ;~ GUICtrlSetOnEvent($B11, "_Exit") ;~ GUICtrlSetOnEvent($B21, "_Exit") ;~ GUICtrlSetOnEvent($B12, "_Exit") ;~ GUICtrlSetOnEvent($B22, "_Exit") ;~ $pos1 = WinGetPos($GUI1) ;~ $pos2 = WinGetPos($GUI1) While 1 ;~ $pos1 = WinGetPos($GUI1) ;~ $pos2 = WinGetPos($GUI1) ;~ $x = $pos1[0] - 370 ;~ $y = $pos1[1] ;~ WinMove($GUI2, "", $x, $y, $pos1[2], $pos1[3], 1) ; Press middle mouse button to close (it's gonna be a non malicious prank for my friend) If _IsPressed(4, $u32dll) Then Exit $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() ;~ Case $1_B1 ;~ _Exit() ;~ Case $1_B2 ;~ _Exit() Case $2_B1 _Exit() Case $2_B2 _Exit() EndSwitch WEnd Func _Exit() ; TODO: ... ;~ GUIDelete($1_GUI) GUIDelete($2_GUI) Exit EndFunc ;==>_Exit How to get rid of these errors?
    • Nareshm
      By Nareshm
      I create message box but i dont know how to add button action when i click it.

      Help for : Add script for Button : Left, Right, Right Finger
      example when i press Left finger button do Case $idNotepad
                      $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                              ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                              ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")
      How to add like above ?
                    
                                                                sorry for my bad english
       
    • Altor
      By Altor
      Hi all:
      In Scite it is possible to expand and collapse  all  the #Region at time  with a shortcut ..?
      Now I use the + key to expand and collapse but I can only use this suggestion for a one # Region
      If I collapse all the regions one by one  in order to have the code more understandable when I re-open the script all the regions are expanded and I need to collapse all again one by one.
      Thank.s to all
      Altor
    • corgano
      By corgano
      Edit: A solution was found! Thanks Jos and others who helped me find this:
      You can have AutoIt run a different "Main" autoit script when you hit F5 instead of the current one, per folder, by doing the following:
      Run SciTE (might need administrator, depending on how autoit was installed) Options -> global properties (alt o g) Uncomment properties.directory.enable=1 (line 270 in my case) create a file SciTEDirectory.properties in the project's main folder Alternatively, if you don't have admin or don't want to edit the global.properties for whatever reason, you can just skip step 1,2,3 and name it SciTE.properties Put in the file you created command.go.$(au3)="$(SciteDefaultHome)\..\AutoIt3.exe" "$(SciteDefaultHome)\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "NAME OF SCRIPT HERE.au3" /UserParams $(1) $(2) $(3) $(4) Save the file. Now anything you run in that folder or subfolder will run the main script when you hit F5 Using SciTEDirectory.properties effects that folder and subfolders, where as SciTE.properties only effects that folder. Apart from that they work the same

      Original question:
      I have a main script, and a bunch of includes / udf's. Almost every single time I edit my includes I hit F5 to run the script, but it runs the include instead. I'm tired of switching back to the main script's tab in SciTE to run it, just to switch back to the include. Is there some kind of #flag or option to set a "main au3 file" so when I hit F5, it will see that and run the main file instead?
    • AndyS19
      By AndyS19
      I have a au3.properties file that adds a search command to the right click context menu.  This command does a FINDSTR on all .au3 files in the "Program Files" directory.  However, on 32 bit Windows 7 and 8.1 OS's, 32 bit executables are now run from a "Program Files (x86)" directory.
      I have a construct that builds a path variable that holds the locations to search.  In this variable, I have both "Program Files" and "Program Files (x86)", as well as a directory that holds my library file.
      The constructor looks like this:
      findcmd="C:\Windows\System32\Findstr.exe" myLib="C:\Andy\AutoIT-src\myLib" where1="C:\Program Files\autoit3\include\*.au3" "C:\Program Files (x86)\autoit3\include\*.au3" $(myLib)\*.au3 Then in the command definition, I use it like this:
      # "Find Definitions" # Look in the C:\Program Files (x86)\AutoIt3\Include directory for any .au3 file # that has a definition for the currently selected word (or the word the # cursor is on) # command.name.42.$(au3)= command.42.$(au3)=$(findcmd) /N /R /I /C:"^global [0-9a-f].* $(CurrentWord) =" $(where1) command.subsystem.42.$(au3)=0 command.save.before.42.$(au3)=2 The problem is that on 32 bit systems without the "Program Files (x86)" directory, I get this error:
          FINDSTR: Cannot open C:\Program Files (x86)\autoit3\include\*.au3
      I think that what I need is an 'if then else' something like this:
       
      if exists "C:\Program Files (x86)" then where1=""C:\Program Files (x86)" $(myLib)\*.au3 else where1=""C:\Program Files" $(myLib)\*.au3 endif How can I conditionally define the search path?