Flash Posted November 2, 2015 Share Posted November 2, 2015 (edited) Hello,a while ago I made myself an application to periodically check a website for changes. Changes are then stored into a file on my computer for me to check them later. Actions are logged into a textfile. I started coding under Win 8.1 and from the start had a weird error that I could not track down. In my GUI I have a tab for the log file to be displayed and that sometimes did not work after some time until I restarted the program. For me this issue wasn't big enough to do the fixing. Then I changed to Win10. Not only after some time the log was not displayed but also sometimes immidiately after startup. Also the file that is created for a change on the website (each change another file) was sometimes not. So whenever the log wasn't displayed anymore, also creating of the other files would not work anymore. Trying to find a solution I found out, that FileOpen would simply not work anymore. It returns the error code -1 and thats it, I have no idea why. The files are not opened in any oher program. Nvm, I found a "solution": Adding #requireAdmin to the script fixed all my problems, but created a new one (couldn't auto start on system boot).Also I tried:Closing Malwarebytes Anti-Malware -> no effect (no other anti virus installed)Giving the executable of my app all rights within the folder (the version without admin rights) -> no effectUsing different folder locations (also Desktop) -> no effectUsing different autoit versions -> no effect Some other info:UAC is turned offWin 10 Pro 64bitLatest stable autoit 3.3.12 Anyone having any ideas what could cause theis kind of problem for FileOpen not to work anymore? Thanks Edited November 2, 2015 by Flash Link to comment Share on other sites More sharing options...
JohnOne Posted November 2, 2015 Share Posted November 2, 2015 Impossible to answer without your exact and full code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Flash Posted November 5, 2015 Author Share Posted November 5, 2015 (edited) Hey, sorry for my late answer.I cannot post all the code, cause I'm using some parts from someone else who doesn't want it to be published. However, these are the parts that are relevant:Creating info file:Func _createInfoFile($URL, $name, $name1, $name2, $language, $debug = 0) Local $file = $name & ".data" Local $fileString = "[Name] = " & $name & @CRLF & _ "[Name1] = " & $name1 & @CRLF & _ "[Name2] = " & $name2 & @CRLF & _ "[Language] = " & $language & @CRLF & _ "[URL] = " & $URL Local $hFile = FileOpen($file, 2 + 8) ;overwrite + create dir structure If $debug = 1 Then MsgBox(0, "Logdatei", $hFile & @CRLF & @error & @CRLF & @extended) FileWrite($hFile, $fileString) FileClose($hFile) EndFuncLog:expandcollapse popupGlobal $logFileName = "log\{year}_{month}_{day}.log" Func _Log($data, $tabs = 0, $returns = 0) If $tabs < 0 Then $tabs = 0 Local $tabString = " - ", $_msg For $i = 1 To $tabs $tabString &= " " Next If $data = "" Then $_msg = "" Else Local $_date = @YEAR & "-" & @MON & "-" & @MDAY Local $_time = @HOUR & ":" & @MIN & ":" & @SEC If $data = " " Then $tabString = "" $_msg = $_date & " " & $_time & $tabString & $data EndIf $hFileOpen = FileOpen(@ScriptDir & "\" & _getLogFileName(), 1) FileWriteLine($hFileOpen, $_msg) FileClose($hFileOpen) If $hGUI <> "" And GUICtrlRead($hTab) = $tabLog Then _updateLog() EndFunc ;==>_Log Func _updateLog($logFile = _getLogFileName(), $debug = 0) Local $file = FileRead($logFile) If $debug = 1 Then MsgBox(0, "Logdatei", $file & @CRLF & @error & @CRLF & @extended) Local $setData = GUICtrlSetData($hLog, $file) ;If $debug = 1 Then MsgBox(0, "Set Data", $setData & @CRLF & @error & @CRLF & @extended) ;_GUICtrlEdit_SetText($hLog, $logText) Local $textLength = _GUICtrlEdit_GetTextLen($hLog) ;If $debug = 1 Then MsgBox(0, "Textlänge", $textLength & @CRLF & @error & @CRLF & @extended) Local $selection = _GUICtrlEdit_SetSel($hLog, $textLength, $textLength) ;If $debug = 1 Then MsgBox(0, "Set Selection", $selection & @CRLF & @error & @CRLF & @extended) Local $scroll = _GUICtrlEdit_Scroll($hLog, $SB_SCROLLCARET) ;If $debug = 1 Then MsgBox(0, "Scrollen ans Ende", $scroll & @CRLF & @error & @CRLF & @extended) EndFunc ;==>_updateLog Func _getLogFileName() Local $logFile = StringReplace($logFileName, "{year}", @YEAR) $logFile = StringReplace($logFile, "{month}", @MON) $logFile = StringReplace($logFile, "{day}", @MDAY) Return $logFile EndFunc ;==>_getLogFileNameThese are the only parts where the files are accessed to. The info files are opened manually by me afterwards for now. The main process runs every 15 minutes logging all activities using _Log() and creates an info file in case of finding new data for every new data found. Edited November 5, 2015 by Flash 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