unclesam Posted February 4, 2010 Share Posted February 4, 2010 Hi, i have a problem with func. "FileReadLine" in AutoIt Version 3.3.4.0 I will open an inuse logfile with "$RC = FileOpen($LOG, 0)" the RetunCode is -1. AutoIt can not open the inuse logfile. AutoIt Version 3.3.2.0 or less runs with the same syntax without problems. Is that a bug or a feature? Can anyone help? Link to comment Share on other sites More sharing options...
Xenobiologist Posted February 4, 2010 Share Posted February 4, 2010 I had the same problem at first. After I don't know really what fixed it. But now it works. Maybe reinstall, reboot, I cannot say. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 4, 2010 Moderators Share Posted February 4, 2010 unclesam,open an inuse logfileCould it be a problem with trying for multiple opens on the same file? I know a lot of work went into the File* functions during the 3.3.3.* Beta phase, although obviusly I am not privy to the details:Please test the ever-loving fuck out of the file functions: FileOpen(), FileClose(), FileRead(), FileReadLine(), FileWrite(), FileWriteLine(), FileGetPos(), FileSetPos() and FileFlush(). A lot of change has gone into thosePerhaps using _FileReadToArray might be a solution for you as it does not rely on you keeping a handle open over a long period. It also gets you the contents nicely arranged in an array so that your code might not have to change too much to manage the new format. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
unclesam Posted February 4, 2010 Author Share Posted February 4, 2010 Hi, thanks for the quick responds. i check it on an other PC - same problem with 3.3.4.0 Less 3.3.2.0 runs without problem The func. "_FileReadToArray" has the same problem it doesn't work when the file is inuse. If the file not inuse runs the scipt fine. The file what I want to open is inuse by an other application not from the script! Link to comment Share on other sites More sharing options...
Administrators Jon Posted February 4, 2010 Administrators Share Posted February 4, 2010 Try the beta. Opened of in-use files changed in 3.3.4.0 and I think we undid it in the beta. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
unclesam Posted March 8, 2010 Author Share Posted March 8, 2010 the new version 3.3.6.0 has the same problem. is the file inuse by an other application, AutoIt can not open (read)the inuse file. AutoIT Versions 3.3.2.0 or less runs without problem. Is this bug/featue fixt in the next autoit version? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2010 Moderators Share Posted March 8, 2010 unclesam,Are you sure? I have just tried to open a file already open in Notepad and Autoit 3.3.6.0 opened it without problem. I tested with both FileOpen and FileRead. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 8, 2010 Share Posted March 8, 2010 Me too, new version seems to work well! Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
unclesam Posted March 8, 2010 Author Share Posted March 8, 2010 hi Melba23m, i'm sure - it not work with 3.3.6.0 & 3.3.4.0 the script will read the last line from an inuse robocopy log $LOG_LAST_LINE = FileReadLine($ROBO_LOG, -1) Link to comment Share on other sites More sharing options...
MHz Posted March 8, 2010 Share Posted March 8, 2010 unclesam, Are you sure? I have just tried to open a file already open in Notepad and Autoit 3.3.6.0 opened it without problem. I tested with both FileOpen and FileRead. M23 You can do that in 3.3.4.0 as well. Notepad does not lock the file. Notepad has issues with an already opened file though. Try this with 3.3.6.0 (I do not have it at present) $h_write = FileOpen('test.txt', 1) ;~ FileClose($h_write) ;~ Run('notepad "' & @WorkingDir & '\test.txt"') $h_read = FileOpen('test.txt', 0) If $h_read = -1 Then FileClose($h_write) MsgBox(0, @AutoItVersion, 'Failed to open handle for read') EndIf FileDelete('test.txt') Uncomment the lines and works OK in 3.3.4.0 but fails as is current form. Link to comment Share on other sites More sharing options...
unclesam Posted March 8, 2010 Author Share Posted March 8, 2010 Hi MHZ, the file what I want to open is inuse by an other application (robocopy.exe) not start from the script!. And this not work, in the last two autoit versions. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2010 Moderators Share Posted March 8, 2010 (edited) MHz, Notepad does not lock the fileThanks for that info - you learn something every day! Now I have tried with other apps, I agree that v3.3.6.0 does NOT open or read already open files. This was already fixed once in v3.3.5.3 Beta: AutoIt v3.3.5.3 (Beta) Released - Fixed: Regression in FileOpen() where it wasn't allowed to open files in read mode if they were already open in write mode I will open a ticket. M23 Edit: Ticket raised #1515 Edited March 8, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Marci Posted March 22, 2010 Share Posted March 22, 2010 Hi I have similar problem like Unclesam, but the other way. I have a logfile ("debug.log") to watch. I read lines over and over again with FileRead, because the program watches the newly appended rows. But if I open the file with FileOpen("debug.log", 0), the other program can't access it, therefore no new lines are added. This poblem didn't appear in the previous versions of AutoIt. Is somebody can help me how to open the file for reading, that is not locked to the other programs to writing? Link to comment Share on other sites More sharing options...
fusion254 Posted March 22, 2010 Share Posted March 22, 2010 (edited) indeed , i got the same problem with the 3.3.4.0 and 3.3.6.0 too Edited March 22, 2010 by fusion254 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 22, 2010 Moderators Share Posted March 22, 2010 Marci and fusion254, The ticket I raised has been accepted but I do not think any of the Devs have the time at present to work on AutoIt. I am afraid you will just have to wait until the next Beta release. However, given that AutoIt used to behave as you wish, I hope it will not be difficult to fix - just keep your fingers crossed! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted March 30, 2010 Share Posted March 30, 2010 (edited) After spending one day of searching in my new compiled script, I ran over this post. (btw: I read also the HISTORY; but to me it was not obvious that fileread affects me :-) )OK, now I understood the cause (newer is not always better for all....)BUT, isn't there a way like calling a strange API/DLL structure to get the same result in 3.3.6.0?If someone could post a suggestion (or post number) to show how to open a file with Autoit in "shared" mode, I will bow down before him/her.(ok, some other will tell me: 'wait for the fix', or 'use 3.3.2.0', but for some strange other reasons I can't)Thanks in advance.//edit: Oh, I forgot: I'm facing a problem like Marci. //edit2: I think I got a solution for me: _WinAPI_CreateFile($sFile, 2, 2,6)OK I need a little rearrange the readfile function but that's ok, so I'm fine with what I found.very scary: I also tried some sort of Mutex......uuuhahaha to get by. So you see I'm almost open to any suggestion. Edited March 30, 2010 by Tankbuster Link to comment Share on other sites More sharing options...
KaFu Posted March 30, 2010 Share Posted March 30, 2010 Give _WinAPI_CreateFile() and corresponding functions a try... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Tankbuster Posted March 30, 2010 Share Posted March 30, 2010 @KaFu: Thx, found it already (maybe even in one of your older posts, thx) @Marci: Just guessing, that you read a constantly written file (by some other process?) and your Autoit shoudl read it without blocking the other process, correct? Maybe this will help you: expandcollapse popup#include <Array.au3> #include <WinAPI.au3> Global $sFile, $hFile, $sText, $nBytes, $tBuffer,$sTextCur,$lastPosition Dim $aRecods[1] $sFile = @ScriptDir & '\TEST.LOG' $lastPosition=0 $lastsize=0 while 1 readfile() sleep(1000) wend _WinAPI_CloseHandle($hFile) func ReadFile() $hFile = _WinAPI_CreateFile($sFile, 2, 2,6) $size = _WinAPI_GetFileSizeEx($hFile) $Deltasize=$size-$lastsize if $Deltasize<=0 Then consolewrite("Nothing new to read --- "&@CRLF) $sTextCur="" Else ConsoleWrite("Size:"&$size&@CRLF) $tBuffer = DllStructCreate("byte[" & $size & "]") _WinAPI_SetFilePointer($hFile, $lastPosition) _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $Deltasize, $nBytes) $sTextCur = BinaryToString(DllStructGetData($tBuffer, 1)) $aRecords=StringSplit($sTextCur,@CR) ConsoleWrite('' & $sTextCur) $lastPosition=$size $lastsize=$size EndIf EndFunc It reads a file in the end you will have something like FileReadLine or _File2Array. But this is just a guess, maybe it helps you or inspires you for something that works for you. Here is a batch that will write a simple file for the Autoit Script here: @echo off set LOGFILE=TEST.LOG cls del %LOGFILE% :START echo %date% - %time% >> %LOGFILE% echo %date% - %time% if exist STOP.CTL goto STOP goto START :STOP del STOP.CTL goto end :END Link to comment Share on other sites More sharing options...
TripleDES Posted April 29, 2010 Share Posted April 29, 2010 The issue is resolved. Unfortunately, we'll have to wait until 3.3.7.0. Fixed by revision [5753] in version: 3.3.7.0 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 29, 2010 Moderators Share Posted April 29, 2010 TripleDES,It is actually fixed in 3.3.6.1: 16th April, 2010 - v3.3.6.1AutoIt:Fixed #1515: FileOpen() still opening in exclusive mode in some situations. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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