NoobieAutoitUser
Active Members-
Posts
57 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
NoobieAutoitUser's Achievements
Wayfarer (2/7)
0
Reputation
-
@subz. Thanks a lot , with a few tweaks it works perfectly. Also I should be able to use this elsewhere, so many doors have opened. Though, strangely, I was getting error message on the line '$aMaintenance[4] = [3, "vacum", "reindex", "analyze"]'. Now I can move on in my script, thanks again $aMaintenance[4] = [3, "vacum", "reindex", "analyze"] <-- Error 'possibly used before declaration.' Local $aMaintenance[4] = [3, "vacum", "reindex", "analyze"] <-- works, I have no idea why.
-
I would like to do the exact same code - except changing the line 'Local $param19 = $a1' to 'Local $param19 = $a2, for the 2nd run, and for the 3rd run to 'Local $param19 = $a3'. I'm getting stumped on how to use the changing variables. $a1 = "vacum" $a2 = "reindex" $a3 = "analyze" Local $param19 = $a1 ; 1st run loop Local $param19 = $a2 , 2nd run loop Local $param19 = $a3 , 3rd run exit loop
-
Hi everybody. Trying to learn some Autoit and move form an old batch file that did back ups, and had served me well. I'm trying to use 'SQlite' to do some file maintenance on files in back up location (then back them up). 'Vacuum' , 'reindex' and 'analyze', are the three things I'm trying to 'run' on each of the SQlite files the script finds. I have the script written, and it works great. Except I cannot figure out how to loop it? I'm not even sure that is the right word to use. I'm stuck and would appreciate any help or ideas to get past this hurdle. Thanks for looking and offering any input. #include <File.au3> #include <Array.au3> $FileList = _FileListToArray(@AppDataDir & "\Moonchild Productions\Pale Moon\Profiles\od3oy6iu.default", "*.sqlite") If @error = 1 Then MsgBox(0, "", "0 Files found.") Exit EndIf if isarray($FileList) then ConsoleWrite('Number of files returned = ' & $FileList[0] & @LF) ; ConsoleWrite($FileList & @LF) _ArrayDisplay($FileList, "$FileList") ; Debug $a1 = "vacum" $a2 = "reindex" $a3 = "analyze" For $i = 1 To $FileList[0] Local $param01 = "D:\[[Command]\sqlite3.exe" Local $param05 = " " Local $param10 = $FileList[$i] Local $param15 = " " Local $param19 = $a1 ; Run SQLite Local $sRun = $param01&$param05&$param10&$param15&$param19 ConsoleWrite(' $sRun >'&$sRun&'<'&@CRLF) ; ..this way you can see what is gonna execute ; RunWait($sRun, "", @SW_MAXIMIZE) Next Number of files returned = 7 $sRun >D:\[[Command]\sqlite3.exe content-prefs.sqlite vacum< $sRun >D:\[[Command]\sqlite3.exe cookies.sqlite vacum< $sRun >D:\[[Command]\sqlite3.exe formhistory.sqlite vacum< $sRun >D:\[[Command]\sqlite3.exe permissions.sqlite vacum< $sRun >D:\[[Command]\sqlite3.exe places.sqlite vacum< $sRun >D:\[[Command]\sqlite3.exe storage.sqlite vacum< $sRun >D:\[[Command]\sqlite3.exe webappsstore.sqlite vacum<
-
Hi folks, I am moving away from Windows 'batch' to Autoit. A lot more power with Autoit, and flexibility. Also a lot more to learn I wrote a script that automatically backups something. It makes a back up every time I launch the script. It then deletes all backups except three. That is the problem. Everything works great till the deletion part. If there are files to delete, it works great. If there are not files to delete I get this error 'Array variable has incorrect number of subscripts or subscript dimension range exceeded'. I'm fairly sure that is has something to do with the 'Ubound' part. From what I read, do I need to resize the array? Or how do I move past the error. I am new to this, and not sure how do error checking. Thanks for any input. #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Dim $szDrive, $szDir, $szFName, $szExt $openfile = 'D:\Z-Users\Last-Time\AppData\Roaming\Something\Saves' $foldertoworkin = 'G:\Temp_D1\' $filename = _PathSplit($openfile, $szDrive, $szDir, $szFName, $szExt) _ArrayDisplay ($filename,"") $Filenamevalue = _ArrayToString($filename,'',3,3) ; MsgBox(0, "Test", $szFName) FileChangeDir($openfile) Local $param01 = "C:\Program Files\7-Zip\7z.exe" Local $param02 = " a -mx1 -r " Local $param03 = $foldertoworkin ; Local $param04 = $szFName Local $param04 = 'Something--' Local $param05 = ".zip" ;Create zip Local $sRun = $param01&$param02&$param03&$param04 &"-"& @MON &"-"& @MDAY &"-"& @YEAR &"_"& @HOUR &"-"& @MIN &"-"& @SEC&$param05 ConsoleWrite(' $sRun >'&$sRun&'<'&@CRLF) ; ..this way you can see what is gonna execute RunWait($sRun, "", @SW_HIDE) ;############################################################################################## Local $sFilePath = $foldertoworkin Local $aFilePath = _FileListToArrayRec($sFilePath, "*", 1,0,0,2) Local $aFileTime[1][2] ;============================================================================= _ArrayColInsert($aFilePath, 1) ; insert a second column For $i = 1 To $aFilePath[0][0] ; now it's [0][0] - row index 0, column index 0 $aFilePath[$i][1] = FileGetTime($aFilePath[$i][0], 1, 1) ; in column 1 (remember 0-indexed - if you start counting by one it's your second) Next ;============================================================================= _ArrayDelete($aFilePath, 0) ; delete number of indexes - there is no filepath inside _ArraySort ($aFilePath,1, 0, 0, 1) ;sort by date _ArrayDisplay($aFilePath) ;============================================================================= For $m = 3 To UBound($aFilePath, 1) ; '3 to ubound' takes the first '3' off the top of the list returned form array (make sure what you want is on the top) ;ConsoleWrite("FileDelete: " & $aFilePath[$m][0] & @CRLF) ; instead of real deletion only saying what will be deleted - just for my security ;if _FileInUse($myfile[$n], 0) And MsgBox(0,"",@error) then continueloop; ADDED ;if $aFilePath[$m][0] And MsgBox(0,"",@error) then continueloop; ADDED FileDelete($aFilePath[$m][0]) ;if FileDelete($aFilePath[$m][0]) And @error = 1 then continueloop; ADDED Next ;############################################################################## ProcessSetPriority("Something.exe", 3)
-
NoobieAutoitUser reacted to a post in a topic: (Solved) How to delete files 'read' in to an array ?
-
Thanks to all of you that helped. I start to see writing the script the easy, its the debugging that is a PITA (pain in the azz). @ Simpel - Thanks for cleaning up my script and the pointers. What is a 1D array? As opposed to a 2D array? @ Danp2 - It was the top two (by creation date). Thanks for your post, as I was going nuts trying to figure how to make that work I changed to it to sort by 'creation date'. I will start to use the 'console write' more, as it really helps to see what it will do before it does it. Again thanks. #include <Array.au3> #include <File.au3> Local $sFilePath = "K:\zxzx" Local $aFilePath = _FileListToArrayRec($sFilePath, "*", 1,0,0,2) Local $aFileTime[1][2] ;============================================================================= _ArrayColInsert($aFilePath, 1) ; insert a second column For $i = 1 To $aFilePath[0][0] ; now it's [0][0] - row index 0, column index 0 $aFilePath[$i][1] = FileGetTime($aFilePath[$i][0], 1, 1) ; in column 1 (remember 0-indexed - if you start counting by one it's your second) Next ;============================================================================= _ArrayDelete($aFilePath, 0) ; delete number of indexes - there is no filepath inside _ArraySort ($aFilePath,1, 0, 0, 1) ;sort by date _ArrayDisplay($aFilePath) ;============================================================================= For $m = 2 To UBound($aFilePath, 1) ; you only want to delete the newest and second newest file (remember row index 0 and 1) ; ConsoleWrite("FileDelete: " & $aFilePath[$m][0] & @CRLF) ; instead of real deletion only saying what will be deleted - just for my security ; ConsoleWrite("FileDelete: " & $aFilePath[$m][0] & @CRLF) ; instead of real deletion only saying what will be deleted - just for my security FileDelete($aFilePath[$m][0]) Next
-
I understand how to sort by date now In the scrip their are two arrays, first is '$aFilePath' and second is '$aFileTime'. '$aFileTime' give me the correct things to delete, but the the script uses '$aFilePath' to delete the files. I try switching the arrays and I get a subscript error, or it does nothing. What can I do to use '$aFilePath' as the array the delete files? Thanks for all the input, I slowly learn my way around The below example deletes nothing. #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $sFilePath = "K:\zxzx" Local $aFilePath = _FileListToArrayRec($sFilePath, "*", 1,0,0,2) Local $aFileTime[1][2] ;============================================================================= For $i = 1 To $aFilePath[0] _ArrayAdd($aFileTime, $aFilePath[$i] & "|" & FileGetTime($aFilePath[$i], 0, 1)) Next ;============================================================================= ; _ArraySort ($aFileTime,1, 0, 0, 1) ;sort by date _ArraySort ($aFilePath,1, 0, 0, 1) ;sort by date ; _ArrayDisplay($aFileTime) _ArrayDisplay($aFilePath) ;============================================================================= For $m = 1 To $aFilePath[0]-2 FileDelete($aFilePath[$m]) Next ;=============================================================================
-
@ careca & @ Danp2 Thank you both for taking the time to assist. Unfortunately their are errors. Its '$aFilePath'. No matter what I do with this, it always returns an error. Not always the same error, but '$aFilePath' it is always something to do with this. After a few hours, I came here to for help lol Both arrays use '$i' as a variable? Might that that be the trouble ? Error "M:\xvcbvctyuiyt76.au3" (8) : ==> Subscript used on non-accessible variable.: For $i = 1 To $aFilePath[0] For $i = 1 To $aFilePath^ ERROR #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $sFilePath = "K:\zxzx" Local $aFilePath = _FileListToArrayRec($sFilePath, "*", 1,0,0,2) Local $aFileTime[1][2] ;============================================================================= For $i = 1 To $aFilePath[0] _ArrayAdd($aFileTime, $aFilePath[$i] & "|" & FileGetTime($aFilePath[$i], 0, 1)) Next ;============================================================================= _ArraySort ($aFileTime,1,1,"",1) ;sort by date ; _ArrayDelete($aFileTime, "1-2") _ArrayDisplay($aFileTime) ;============================================================================= For $i = 2 To UBound ($aFileTime, 1) FileDelete($aFileTime[$i][0]) Next ;=============================================================================
-
@careca This code looks real nice Unfortunately its deletes all (which you said it would). I would like to only delete the values that display in '_ArrayDisplay($aFileTime)'. This is where I get stuck, how do I use the values in '_ArrayDisplay($aFileTime)' to delete files? Thanks a lot for your help. #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $sFilePath = "K:\zxzx" Local $aFilePath = _FileListToArrayRec($sFilePath, "*", 1,0,0,2) Local $aFileTime[1][2] ;============================================================================= For $i = 1 To $aFilePath[0] _ArrayAdd($aFileTime, $aFilePath[$i] & "|" & FileGetTime($aFilePath[$i], 0, 1)) Next ;============================================================================= _ArraySort ($aFileTime,1,1,"",1) ;sort by date _ArrayDelete($aFileTime, "1-2") _ArrayDisplay($aFileTime) ;============================================================================= For $i = 1 To $aFilePath[0] FileDelete($aFilePath[$i]) Next ;============================================================================= @Danp2 Yes, my goal is to only delete the top two in the array display (the newest files). Then using what is left in the array (after deleting). This is for a auto delete 'batch'. I have used other scripts before, but if something goes wrong, and after a period of time, all your files get deleted. After this works, then it always keeps at least two files for backup. I hope this makes sense
-
Hi everybody. I'm trying to delete files I have read into an array. Everything works, other than the deleting. I have scoured the forums, and tried all kinds of thing. Most errors I get are 'Array variable has incorrect number of subscripts error'. I am not sure what I am doing with arrays, and am quite proud I got the delete lines to work Any pointers how to use the info form the array to delete these files found ? #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $sFilePath = "K:\zxzx" Local $aFilePath = _FileListToArrayRec($sFilePath, "*", 1,0,0,2) ; If @error Then Exit ; _ArrayDisplay($aFilePath) Local $aFileTime[1][2] For $i = 1 To $aFilePath[0] _ArrayAdd($aFileTime, $aFilePath[$i] & "|" & FileGetTime($aFilePath[$i], 0, 1)) Next _ArraySort ($aFileTime,1,1,"",1) ;sort by date ; Deletes first two results (newest is ontop) _ArrayDelete($aFileTime, "1-2") _ArrayDisplay($aFileTime)
-
Hi, thanks for looking at my post. I have a script that does 'auto answering' for Pidgin (chat client, using XMPP). I use OTR (off the record - encrypts conversations) with Pidgin. Their is a pause when someones connects to you (some times it takes seconds, other minutes), as the OTR kicks in. I made a script that works with it and is so far is flawless. I am using an 'ini' to read from to get the info that is needed for each user (~10 users). I understand how to read the different sections on the ini. How do I tell the script what section to use based on who logged in? Example = !Mycell logs in and uses Buddy1 in the ini. Example = Webpage logs in and uses Buddy2 in the ini. How do I tell the script what part to use? I have one main script. Do I need to make a script for each ini? Thanks for any help. I feel so close to being done with this, and this part has me stumped. [Buddy1] Wname=!My-Cell-Q1 ClipWrite=!My-Cell-Q1ClipWrite.txt TextToRead=!My-Cell-Q1-Read-Text.txt Ran=Yes [Buddy2] Wname=Webpage ClipWrite=Webpage.txt TextToRead=Webpage-Read-Text.txt ; Maine script #include <File.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> ; sleep(5000000000000000000000000) $sIniFile = 'ini-begin.ini' ; S- Read the INI file for the values. Local $sReadIni0 = IniRead($sIniFile, "Buddy1", "Wname", "Default Value") Local $sReadIni1 = IniRead($sIniFile, "Buddy1", "ClipWrite", "Default Value") Local $sReadIni2 = IniRead($sIniFile, "Buddy1", "TextToRead", "Default Value") ; S-Delete File for 'clip write' , so file is blank on first use. ; FileDelete - Do not use quotes, with viariables. Use quotes with full name. FileDelete($sReadIni1) ; sleep(500000000000000000000000) ; E-Delete File for 'clip write' , so file is blank on first use. ; S- Read the INI file for the values. ; Display the value returned by IniRead. (Works) ; MsgBox($MB_SYSTEMMODAL, "", "The value of 'Buddy1' in the section labelled '$sReadIni0 ' is: " & $sReadIni0) ; MsgBox($MB_SYSTEMMODAL, "", "The value of 'Buddy1' in the section labelled 'ClpWrite' is: " & $sReadIni1) ; sleep(5000000000000) ; MsgBox($MB_SYSTEMMODAL, "", "The value of 'Buddy1' in the section labelled 'TextToRead' is: " & $sReadIni2) ; Write the values to an INI file (Works). ; IniWrite($sIniFile, "Buddy1", "Ran", "Yes") ; E- Read the INI file for the values. ; S - Wait for message window to appear. ; The 10 is in seconds (not milliseconds) ; WinWait($sReadIni0 , "", 10) If WinExists($sReadIni0 ) Then ;MsgBox(0, "", "Window exists") Else ;MsgBox(0, "", "Window does not exist") Exit EndIf ; E - Wait for message window to appear. $counter = 0 While $counter <= 5 Sleep(10) ;MsgBox(0, "Value of $counter is:", $counter) winactivate($sReadIni0) Send("^l") winactivate($sReadIni0) Sleep(1500) Send("!c") winactivate($sReadIni0) Sleep(1500) Send("{RIGHT}") winactivate($sReadIni0) Sleep(1500) Send("{RIGHT}") winactivate($sReadIni0) Sleep(1500) send("{ENTER}") winactivate($sReadIni0) Sleep(1500) Send("{F6}") winactivate($sReadIni0) Sleep(1500) Send("^a") winactivate($sReadIni0) Sleep(1500) Send("^c") winactivate($sReadIni0) Sleep(1500) Send("^l") winactivate($sReadIni0) Sleep(1500) ; S - Write Clipboard to a file ; the & '@CRLF' adds a line break afer paste form clipboard filewrite($sReadIni1,clipget() & @CRLF) ; E - Send keys to pidgin to copy text and send to ClipWrite. ; S - Look for matching text in file.) Sleep(1500) $textToFind = ("successfully refreshed") $AllText = FileRead($sReadIni1) If StringInStr($AllText ,$textToFind) <> 0 then ;it's there ;MsgBox($MB_OK, "Crap", "Yes") exitloop else ;it isn't there ;MsgBox($MB_OK, "Crap", "No") Sleep(100) endif ; E - Look for matching text in file. $counter = $counter + 1 WEnd For $i = 1 to _FileCountLines($sReadIni2) $line = FileReadLine($sReadIni2, $i) ;Send($line & @CRLF) Send($line) Send("{ENTER}") Sleep(5000) Next ; FileClose($file) ; end read form text fiel and send to pidgin
-
[Solved] Winwait (strange behavior?)
NoobieAutoitUser replied to NoobieAutoitUser's topic in AutoIt General Help and Support
Hi. I have been messing with this for a few days now. My head feels like scrambled eggs The 'code' finally works I think it was a combination of a few things, and that the window name has an exclamation point in it. Notice I used ' instead of " around !My-Cell. Now it waits for 5 seconds, if window does not appear, it exits the script. Thanks to all for help, and for having patience. $hWnd = WinWait('!My-Cell', "", 5) sleep(5000) If WinExists($hWnd) Then MsgBox(0, "", "Window exists") Else MsgBox(0, "", "Window does not exist") Exit EndIf -
[Solved] Winwait (strange behavior?)
NoobieAutoitUser replied to NoobieAutoitUser's topic in AutoIt General Help and Support
Finally I understand now. I thought it paused until the window existed, and timed out the script. I was pulling my hair out Thanks so much. How do I make a script wait for a window and exit if not ? Winwait does not work like I thought it did, so how to do this ? I'm thinking a loop (x seconds). If 'winexsits' ?