Jump to content

Search the Community

Showing results for tags 'filewrite'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 16 results

  1. Is it possible , and how can I read and write txt files from Icloud (apple service) ? Let me try to explain my application. On my Ipad and Iphone I create txt files. On my windows computer it is possible to read and modify these files manually, by logging in on www.icloud.com. What I want to make is an auto-it script who reads the txt file and create an new txt file on www.icloud.com, so I can acces these on my ipad and/or phone. Thank you.
  2. Hi to all, I am writing a feature to an existing internal AutoIt program, based on a client's request. The requested feature would be to grab the file via a button, which reads the file's path. Below the file browsing button would be a button to upload the file into a MySQL server. Initially, my method would be to read the contents of the file provided in the filepath, then convert the contents of the file into binary data, and then store it into a column of a table as a BLOB. I am not sure whether if this is the best approach to storing text/Word/PDF files into the MySQL Server in this way, if the program used is an AutoIt program. So far, I am only able to generate Excel files, but only because there was already an existing BLOB column in an existing table. Sample code: $sTemplateName = "SearchTemplate" $sFilePath = @ScriptDir & "\temp\" & $sTemplateName & ".xls" $iFileExists = FileExists($sFilePath) ; If template file not found, create it. If (Not $iFileExists) Then generateExcelFile($sTemplateName, $sFilePath) EndIf $iFileExists = FileExists($sFilePath) If $iFileExists = 1 Then $oExcel = _ExcelBookOpen($sFilePath, 0) _ExcelWriteCell($oExcel, "Search conducted on " & _NowCalc() & " by " & $username & "", 2, 1) $counter = 0 While Not $recordSet.EOF _ExcelWriteCell($oExcel, 1 + $counter, 6 + $counter, 1) _ExcelWriteCell($oExcel, getName("User", $recordSet.Fields("UserID").value), 6 + $counter, 2) _ExcelWriteCell($oExcel, $recordSet.Fields("InternalName").value, 6 + $counter, 3) _ExcelWriteCell($oExcel, getName("Product", $recordSet.Fields("ProductID").value), 6 + $counter, 4) _ExcelWriteCell($oExcel, $recordSet.Fields("Serial").value, 6 + $counter, 5) _ExcelWriteCell($oExcel, getName("Location", $recordSet.Fields("LocationID").value), 6 + $counter, 6) _ExcelWriteCell($oExcel, $recordSet.Fields("Remarks").value, 6 + $counter, 7) _ExcelWriteCell($oExcel, getFriendlyDate($recordSet.Fields("LastModified").value, 1), 6 + $counter, 8) _ExcelWriteCell($oExcel, getFriendlyDate($recordSet.Fields("CreationDate").value, 1), 6 + $counter, 9) $recordSet.MoveNext $counter = $counter + 1 WEnd _ExcelBookSaveAs($oExcel, $exportDir & "\" & $username & "_Search_Results_" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC, "xls") _ExcelBookClose($oExcel, 1, 0) EndIf
  3. This code will read text data from txt file. However, if I use '$Newtext &= $convert' then $convert is saved as strings, not hex value. For example, if $convert = 0x300020FF and $bNewText = Test then the result is 0x333030303230464654657374. (Wrong) What I want is 0x300020FF54657374. How can I modify my script? For $i = $y-1 To Ubound($split) - 1 $convert = "0x" & $split[$i][0] $Newtext &= $convert $NewLen_hex = BinaryLen ($convert) $i=$i+1 $split[$i][1] = $split[$i][0] $split[$i][1] = StringRegExpReplace($split[$i][1], "<cf>", @CRLF) $split[$i][1] = StringRegExpReplace($split[$i][1], "<lf>", @LF) $split[$i][1] = StringRegExpReplace($split[$i][1], "<cr>", @CR) $bNewText = _WinAPI_WideCharToMultiByte($split[$i][1], $CP_SHIFT_JIS) if $i = Ubound($split) - 1 Then $bNewText &= Chr(0) EndIf $Newtext &= $bNewText $NewLen = $NewLen_hex + BinaryLen ($bNewText) Next (...) (...) $Newfile = BinaryMid($Newfile_header,1) & BinaryMid($Newtext,1) $hNewfile = FileOpen ("NEW_"&$Name, 2+16) FileWrite ($hNewfile, $Newfile) FileClose ($hNewfile) TrayTip ("Importer", "Finish!", 3) sleep (3000)
  4. Hi there I have searched and found many posts on READING CSV. What I need to do is WRITE CSV. Typically I have a Listview, I use @guinness's excellent _GUICtrlListView_CreateArray to read that LV to Array. Currently I use _FileWriteFromArray to write the output. It is fast and it is easy. The benefits of using these Array functions are their inherit flexibility. The code is portable. Plug it into LV report and you can write to file instantly. No formatting issues. To be sure, my problem is not with the Listview or Array. My problem is with the file write to CSV: it should be fast, accurate and efficient. Part of the problem is Microsoft Excel's insistence that my CSVs are not what they appear to be... I am inspired by the simplicity of SQLITE3.EXE's dot command options: .headers on .mode csv .once output.csv Problem is that I want to export the text packed in characters, such as ' " ' with fields delimited by another character, such as ' , '. Current method using _FileWriteFromArray outputs data like this 12-04-2016| 0.00| 131.00|131|Description 12-04-2016| 0.00| 132.00|132|Description 132 rece 12-04-2016| 998.00| 0.00|998|Description Receipt 12-04-2016| 0.00| 900.00|900|Description What I want to achieve is this: "12-04-2016"," 0.00"," 131.00","131","Description" "12-04-2016"," 0.00"," 132.00","132","Description 132 rece" "12-04-2016"," 998.00"," 0.00","998","Description Receipt" "12-04-2016"," 0.00"," 900.00","900","Description" I have done this. The long way. I have written the output one $aResult[$i][1] item at a time, spaced with the $text & $field markers. I have placed this in an array with additional columns just to fit in the formatting. I have also played with the idea of inserting the array into a sqlite db, then run sqlite3's dot commands on that. Is there a different method? Is there an efficient method to specify FileWriteFromArraytoCSV? Does anyone have ideas? I am sure I will know how to code this, I just need advice on the most efficient way of going about it. If I missed any threads, please enlighten me. Thanks for reading
  5. Hello, I would like to make a script like the below open the browser > copy the url in the browser's address bar > save it in a text file I have no clue on how to make this I'd appreciate for any help
  6. This doesn't work, it deletes (overwrites) file contents: $hFile = FileOpen("file.txt", 2) $content1 = FileRead($hFile) $content2 = StringReplace($content1, "old", "new") FileWrite($hFile, $content2) FileClose($hFile) Why? Instead, I have to use this workaround: $hFile = FileOpen("file.txt") $content1 = FileRead($hFile) $content2 = StringReplace($content1, "old", "new") FileClose($hFile) $hFile = FileOpen("file.txt",2) FileWrite($hFile, $content2) FileClose($hFile) That's it, opening, closing and reopening the file. Function reference says: FileWrite. "Write text/data to the end of a previously opened file." (Does it mean "append"?). Remarks: "The file must be opened in write mode or the FileWrite() command will fail." But what write mode? $FO_APPEND (1) = Write mode (append to end of file). $FO_OVERWRITE (2) = Write mode (erase previous contents).
  7. Hello, I have a simple task today, I am sure that I made a similar post a long time ago... I want trim (delete or remove or wipe) the contents of a file (text or binary) WITHOUT storing the contents of the file anywhere in the script. Here is a text file for the purpose of experimenting: (contents of text.txt) 1234567890The task is simple, remove "456" from the contents of text.txt WITHOUT storing the contents anywhere! I wanted to post some code but it seems impossible to provide any relevant code this time... Good luck with the challenge! TD
  8. Hi everybody, new here. I'm messing around with AutoIT since a few days. I'm actually doing some experiment on my computer, and want to do a simple textbox on my desk, and when I type some things like "chrome" then click OK or input Enter, it launch chrome.exe Anyway, I'm storing a historic of my inputs in a txt file. And if I push my BackSpace button, I'd like to make my code delete the last character of the txt file instead of FileWrite ($historic, 'BACKSPACE') .. Is there a special character that can delete my last char in the txt file ? I remember doing domething like that in C but it was years ago and I was beginning... Thanks for your help !
  9. Hello :), I wanna insert a backspace in a file (Sorry, I don't know what to say formally) I tried this: #include <Array.au3> Func FileBackspace($sFile, $iLine, $iCount) ; Pretty straight forward name, isn't it? $hFile = FileOpen($sFile, 2) ; Open file in over-write mode $aFile = FileReadToArray($hFile) ; File to array $aFile[$iLine] = StringTrimRight($aFile[$iLine], $iCount) ; Trim the line (NOTE: Backspace means trim starting from right) $sFile = _ArrayToString($aFile, @CRLF) ; Store new modifed file in a variable FileWrite($hFile, $hFile) ; Hmmmm... What would FileWrite do? EndFuncThis is not the best way to do this. This will be OK for small files but for files with size of 1 GB!!! I tried hard but I failed to insert backspace without storing the entire file in the RAM I want a function which does this but without storing the entire file Thanks in advance, TD
  10. Hello, I found that its quite challenging to do this: text.txt: Hello, I am a text file :). I love line No. 1 I want to change it like this: I am line No. 1 now :P Hello, I am a text file :). I love line No. 1 How can I do this in AutoIt without storing it? Thanks in advance! TD
  11. I am looking for some help with my code. I want to be able to have this script always run, and append a file each time a program is opened adding a new line. Here is my code, and help would be greatly appreciated. #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <File.au3> Local $aLines, $iCount = 0 local $hDate = @YEAR & '-' & @MON & '-' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC local $hfile=FileOpen("C:\Users\public\Desktop\new1.txt", $FO_APPEND) Local $hComputername = @ComputerName ; Computer Name Local $hUsername = @UserName ; User Name While 1 If $hfile = -1 Then SplashTextOn("Error", "Unable to open and append the log file.", 300, 50) Sleep(2000) SplashOff() EndIf _FileReadToArray("C:\Users\public\Desktop\new1.txt", $aLines) If Not @error Then ; if the file exists look for the ID starting on the last line For $i = $aLines[0] To 1 Step -1 If StringLeft($aLines[$i], 2) == "id" Then ; get the ID number $iCount = Int(StringRegExpReplace($aLines[$i], "id(\d*):.*", "$1")) ExitLoop EndIf Next ; Check we found an ID If $i = 0 Then MsgBox(0, "Error", "No line id found") Exit EndIf EndIf If WinExists("[Class:Notepad]", "") Then FileWrite($hfile, _LineID() & '|' & $hDate & '|' & $hComputername & '|' & "Notepad was opened by " & $hUsername & @CRLF) Sleep(10) FileClose($hfile) Sleep(1000) EndIf WEnd Func _LineID() $iCount += 1 Return "id" & StringFormat("%04i", $iCount) & ": " EndFunc ;==> LineID Thanks!
  12. Hello All, This is my test script i've been messing around with to get the syntax correct for my real script that I am working on. Simply, this script will: The problem that I am having is my loop that I have isn't waiting for a user to input new data into the "username" input box. How to replicate: 1. Input Project Name "TESTING-01A-Q1-2013" 2. Number of Projects Can be any number more than 1 3. Third input box is looking for a name "can be anything." 4. Click Next Project 5. When Next project button is dim click submit 6. Look in the script directory where you ran it from for "testing.txt" You will notice something similar to the following: Project TESTING-01A-Q1-2013 This is my username Project TESTING-01B-Q1-2013 This is my username TEST USER Project TESTING-01C-Q1-2013 This is my username TEST USER Project TESTING-01D-Q1-2013 This is my username TEST USER Project TESTING-01E-Q1-2013 This is my username TEST USER What needs to happen is the script will wait for the username input box to have data in it before filewrite. code is below #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Test", 615, 438, 215, 170) $RDCNextProjectButton = GUICtrlCreateButton("Next Project", 183, 241, 99, 33) GUICtrlSetState(-1, $GUI_DISABLE) $ProjectNameInputBox = GUICtrlCreateInput("", 35, 104, 193, 21) $ProjectNameLabel = GUICtrlCreateLabel("Please Input Your Project Name", 27, 80, 200, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $NumberOfProjectsLabel = GUICtrlCreateLabel("Please Input The Number Of Projects You Have Of This Kind", 19, 160, 364, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $RDCNumberOfProjectsInput = GUICtrlCreateInput("", 49, 198, 193, 21) $RDCSubmitButton = GUICtrlCreateButton("Submit", 72, 240, 99, 33) GUICtrlSetState(-1, $GUI_ENABLE) Global $ProjectNameRead = GUICtrlRead($ProjectNameInputBox) $username = GUICtrlCreateInput("", 48, 290, 193, 21) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $RDCNumberOfProjectsInput ;$RDCProjectSiteRead = GUICtrlRead ($ProjectSiteCombo) $RDCProjectNameRead = GUICtrlRead($ProjectNameInputBox) $RDCNumberOfProjectsRead = GUICtrlRead($RDCNumberOfProjectsInput) $usernameread = GUICtrlRead($username) If $RDCNumberOfProjectsRead > 1 Then GUICtrlSetState($RDCNextProjectButton, $GUI_ENABLE) GUICtrlSetState($RDCSubmitButton, $GUI_DISABLE) FileOpen("testing.txt", 1) FileWrite("testing.txt", @CRLF & @CRLF) FileWrite("testing.txt", "Project ") FileWrite("testing.txt", $RDCProjectNameRead & @CRLF) FileWrite("testing.txt", "This is my username " & $usernameread & @CRLF) FileClose("testing.txt") guictrlsetdata($username,"") ElseIf $RDCNumberOfProjectsRead = 1 Then GUICtrlSetState($RDCNextProjectButton, $GUI_DISABLE) GUICtrlSetState($RDCSubmitButton, $GUI_ENABLE) EndIf $CapacityInput = ($RDCNumberOfProjectsRead * 10) Case $RDCNextProjectButton $ProjectNameRead = GUICtrlRead($ProjectNameInputBox) $RDCNumberOfProjectsRead = GUICtrlRead($RDCNumberOfProjectsInput) $usernameread = GUICtrlRead($username) If guictrlread($username) = ("") Then MsgBox(0,"WAIT","Please Input A Name.") EndIf For $I = 1 To $RDCNumberOfProjectsRead - 1 FileOpen("testing.txt", 1) ConsoleWrite("'" & StringRegExpReplace($ProjectNameRead, "(?<=-\d{2})([A-Z])(?=-Q)", "' & Chr(Asc('$1') + $I) & '") & "'" & @LF) Local $soutput = Execute("'" & StringRegExpReplace($ProjectNameRead, "(?<=-\d{2})([A-Z])(?=-Q)", "' & Chr(Asc('$1') + $I) & '") & "'") GUICtrlSetData($ProjectNameInputBox, $soutput) FileWrite("testing.txt", @CRLF & @CRLF) FileWrite("testing.txt", "Project ") FileWrite("testing.txt", $soutput & @CRLF) FileWrite("testing.txt", "This is my username " & $usernameread & @CRLF) FileClose("testing.txt") guictrlsetdata($username,"") Next GUICtrlSetState($RDCNextProjectButton, $GUI_DISABLE) GUICtrlSetState($RDCSubmitButton, $GUI_ENABLE) Case $RDCSubmitButton MsgBox(0, "TESTING", "END OF SCRIPT") Exit EndSwitch WEnd Thanks to all for helping.
  13. So I am using this code: Local $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "Line1") FileWrite($file, "Still Line1" & @CRLF) FileWrite($file, "Line2") FileClose($file) However I would like to add a unique number to the beginning, so that the result would be something like: test.txt id 1: line id 2: line 2 id 3: line 3 etc Any ideas? Thanks in advance Grimm
  14. Hi everyone.. not quite sure how to get a list box to save its strings into a single .log or .txt file (either would work for me), and then later call each individual string.. the list box has up to 30 items in it, the user will be able to deselect certain items, or select items... i just need a way to save each string into an external file so i can later call them back as variables and display them into a disabled list box.. if anyone could help that would be extremely appreciated. reply if my objective is confusing. THANKS!
  15. Hello, pls can someone give some tips how to stop error. I have an error in script what stop work. Error code: C:Documents and SettingsTeodesktopodno.au3 (37) : ==> The requested action with this object has failed.: FileWrite($odno, $oLink.href & @CRLF) FileWrite($odno, $oLink.href ^ ERROR script part: Func _GetFriends() $a = $a+1 ConsoleWrite('$a = '&$a) _IELoadWait($oIE) FileDelete(@DesktopDir&"/test.txt") $oLinks = _IELinkGetCollection($oIE) $iNumLinks = @extended ConsoleWrite(' 2. Links Found: ' & $iNumLinks & @CRLF) For $oLink in $oLinks FileWrite($odno, $oLink.href & @CRLF) $check = _StringBetween($oLink.href, "chatWith=", "&tkn=") If not @error then FileWrite(@DesktopDir&'/friends.txt',$oLink.href&@CRLF) $check = _StringBetween($oLink.href, "st.page=","&tkn=") If not @error Then $string=_ArrayToString($check) If $a < 9 Then $result = StringLeft($string, 1) Else $result = StringLeft($string, 2) EndIf If $result > $a Then ConsoleWrite ('I found it: '&$result& ' link: ' & $oLink.href & @CRLF) _IENavigate($oIE,$oLink.href) _GetFriends() EndIf EndIf Next EndFunc ; ==> _GetFriends In 3 lines that have all needed variables.. i think something stop it on line 1. I have tried to make something like if $oLinks.href == '' then exitloop But that code also give error on "$oLinks.href" That work successful when $iNumLinks is about 40.. but in case of ~25 that always give error.. Thank you so much for any tips.
  16. Hi guys, I've been at this for a little while, so I thought I would turn to the community for what should be a simple answer to my problem. I want to write raw data to a file. Now, when I say raw data, I mean I want to write exactly the bytes I want in the file, not the hex equivalant of the characters I send. To be clearer, let me show you me code and explain what's wrong with it: $fOpen = FileOpen(@DesktopDir&"\icons.txt",18) For $d = 15 To 15 For $c = 12 To 12 For $b = 0 To 15 For $a = 0 To 15 $temp = binary(Hex($b, 1) & Hex($a, 1) & Hex($c, 1) & Hex($d, 1)) FileWrite($fOpen,$temp) Next Next Next Next FileClose($fOpen) (I can't post in the code box right now due to a poor internet connection. Sorry guys.) Well I've tried different flags or ways about converting the 4 letter hex code into binary so it will write to the file byte by byte. Nothing has worked so far. To be clear. I'm looking specifically to write raw data to a file; not the data equivalant of the text I am writing. i.e. 4E4F is the equivalant to "NO" in a hex editor. I want to write "4E4F" NOT the Hex equivalant. Thanks before hand for the help guys.
×
×
  • Create New...