Jump to content

singbass

Active Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by singbass

  1. If you are able to write your log files to a sub-folder named 'Today', then you could schedule something like this to run daily right after midnight and it will backup your log files to a daily sub-folder. ;============================================================= ; create new folder and delete sub-folders > 6 days old ;============================================================= #include<Date.au3> $yesterdayfolder = StringReplace(_DateAdd('d', -1, _NowCalcDate()), "/", "") If Not FileExists(@ScriptDir & "\" & $yesterdayfolder) Then ;create folder with yesterday's date if it doesn't exist DirCreate(@ScriptDir & "\" & $yesterdayfolder) For $x = -10 To -6 Step 1 ; use for loop in case this doesn't run for a few days. It will still delete old folders. $DeleteFolder = StringReplace(_DateAdd('d', $x, _NowCalcDate()), "/", "") DirRemove(@ScriptDir & "\" & $DeleteFolder, 1) ;removes folder and all sub-folders and files Next FileMove(@ScriptDir & "\Today\*.Log",@ScriptDir & "\" & $yesterdayfolder) ;moves all .log files in the today folder to the folder with yesterday's date EndIf This will just move the files from the 'Today' sub-folder into a different sub-folder with yesterday's date as the folder name and automatically delete folders that are older than x number of days (in this case, 6 days).
  2. I have an issue with disk space on a server so I wrote a simple little script to check specific directories and save the sizes to an Excel spreadsheet. For this script, I am still using version 3.3.8.1. Everything works fine, I just have a question. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 #ce ---------------------------------------------------------------------------- #include<date.au3> #include<excel.au3> #include<array.au3> $file = FileOpen(@ScriptDir & "\CMScriptDirList.txt", 0) If @error Then Exit ;--folder view still OK $oexcel = _ExcelBookOpen(@ScriptDir & "\CMScriptDirSizesCopy.xlsx") If @error Then Exit ;--folder view now parent folder $excelArray = _ExcelReadSheetToArray($oexcel) $lastrow = $excelArray[0][0] $lastcol = $excelArray[0][1] _ExcelWriteCell($oexcel, _NowCalc(), 1, $lastcol + 1) While 1 $line = FileReadLine($file) If @error Then ExitLoop $size = DirGetSize(StringStripWS($line, 3)) / 1024 / 1024 $iIndex = _ArraySearch($excelArray, $line, 0, 0, 0, 0, 1, 1) If @error Then ContinueLoop _ExcelWriteCell($oexcel, $size, $iIndex, $lastcol + 1) WEnd FileClose($file) _ExcelWriteFormula($oexcel, "=SUM(R2C" & $lastcol + 1 & ":R38C" & $lastcol + 1 & ")", 39, $lastcol + 1) _ExcelWriteFormula($oexcel, "=R39C" & $lastcol + 1 & "/1024", 40, $lastcol + 1) $oexcel.ActiveSheet.columns($lastcol).copy ;used to copy the format of the original last column of the spreadsheet $oexcel.ActiveSheet.columns($lastcol + 1).PasteSpecial(-4122, Default, Default, Default) ;this just pastes the format of the original last column to the new last column $oexcel.ActiveSheet.Range("A1").Select ;select cell A1 just to unselect the entire column from previous command $oexcel.columns.AutoFit ;auto sizes the column width _ExcelBookClose($oexcel, 1) ;save file when closing The script is compiled and sitting is a sub-directory on the server in question. The text file and the spreadsheet that are used are both in this same folder as well. When I navigate to the folder and run the script by double-clicking on the executable, the process runs but the folder view where I ran the script will go back up one level so when the script completes, I am in the parent folder from where I started. I have added message boxes throughout the script and have determined that the folder view goes back up one level at some point after the @error check for the file open and before the @error check for the ExcelBookOpen (where the comments are). I just wanted to know if someone can tell me why and if there is a way to prevent it. (Note: still using v3.3.8.1 on this machine but slowly converting scripts to v3.3.14.2).
  3. How do you access the VM? I use DameWare and there are cursor settings to actually show the cursor on the remote.
  4. We have been working on running scripts on a VM as well. The scripts interact with a Meditech (Hospital Information System) client and scrape and input data. When the RDP session ends, the script stops working. I've found that using DameWare Remote Control software seems to work for us. Disconnecting a DameWare session leaves the user account logged in. Maybe you could give that a try.
  5. That was too simple. I feel like an idiot. I was already using the GUISetAccelerators so I knew the hotkeys but I didn't know how to display them. Thanks.
  6. On a daily basis, I use a proprietary HIS (Hospital Information System) knonw as Meditech. On some of their screens, they have buttons like this; When you hit the F8 key, the buttons will change and the hotkey gets identified as shown below; I would like to mimic this action with some GUI's that I have developed using AutoIT, but I can't figure out how to get the underline character to show up on the letter I want to be the hotkey. Actually, if I could just figure out how to make the first character of the button label be underlined, that would suffice for now. Can anyone point me in the right direction?
  7. On the weekends I listen to Car Talk on public radio. Often times they have math puzzlers and often times I just write simple scripts to solve them for my own enjoyment (how sick is that ). Here is something I did many years ago. #cs ---------------------------------------------------------------------------- This may have been a problem from Car Talk many years ago Dogs cost $5 each Cats cost $2 each Mice are 10 for $1 How many of each will you need to get 100 animals for $100 #ce ---------------------------------------------------------------------------- $Dogs = 0 $Cats = 0 $Mice = 0 For $Dogs = 1 To 20 ;any more than 20 dogs and you would go over $100 If (($Dogs * 5) + ($Cats * 2) + ($Mice * .1)) > 100 Or ($Dogs + $Cats + $Mice) > 100 Then ContinueLoop EndIf For $Cats = 1 To 50 ;any more than 50 cats and you would go over $100 If (($Dogs * 5) + ($Cats * 2) + ($Mice * .1)) > 100 Or ($Dogs + $Cats + $Mice) > 100 Then $Cats = 0 ExitLoop EndIf For $Mice = 10 To 100 Step 10 ;must buy in lots of 10 and you can't have more than 100 animals If (($Dogs * 5) + ($Cats * 2) + ($Mice * .1)) > 100 Or ($Dogs + $Cats + $Mice) > 100 Then $Mice = 0 ExitLoop ElseIf (($Dogs * 5) + ($Cats * 2) + ($Mice * .1)) = 100 And ($Dogs + $Cats + $Mice = 100) Then MsgBox(0, "Total", $Dogs & @TAB & "Dogs" & @TAB & "$" & $Dogs * 5 & @CRLF & $Cats & @TAB & "Cats" & @TAB & "$" & $Cats * 2 & @CRLF & $Mice & @TAB & "Mice" & @TAB & "$" & $Mice * .1 & @CRLF & "-----" & @TAB & "-----" & @TAB & "-----" & @CRLF & ($Dogs + $Cats + $Mice) & @TAB & "Total" & @TAB & "$" & (($Dogs * 5) + ($Cats * 2) + ($Mice * .1))) EndIf Next Next Next
  8. I am planning on moving and resizing before clicking. I just thought if I could "hook the windows move and size events" it might be easier (and less intrusive). If they couldn't move the window then I wouldn't have a problem. I just couldn't find anything in the forums that showed me how to do it although I didn't search for 'hook' or 'event'. I still didn't get Q1 answered so I am playing now to see if mouseclick can take place off the screen. I am going to guess no, but then I have been wrong in the past (just ask my wife) . Edit:....Confirmed
  9. I have a script that opens a proprietary application and pulls up a patient monitor. This monitor has a refresh button that needs to be pushed every 2 minutes. Unfortunately there is no keyboard command to get to the button and no controls are exposed when using the Window Info tool. It has to be a mouseclick. What I have done so far is just move to a position and click and it works great. However, if the window gets moved, the click is now in the wrong place. Q1. I can determine the position and size of the window, then determine the location within that window based on where it is, but will the mouseclick work if the refresh button has been moved off the screen (i.e. can you click beyond your screen resolution)? Q2. Right now I am going to code it to move the window back to the original location and resize it to the original size before I do the mouse click and that should take care of my problem. I just wondered if there was a way to freeze a window so it couldn't be moved? The nurses still need to interact with other things on the window, I just don't want them to be able to move it or resize it.
  10. As I figured, it appears it's a Win 2008 issue. Finally found the fix in another forum, deep within the thread. Had tried everything mentioned up to that point with no luck. Finally found the anwer. http://social.technet.microsoft.com/Forums/windowsserver/en-US/d47d116e-10b9-44f0-9a30-7406c86c2fbe/scheduled-task-wont-run-bat-file Thanks.
  11. That was next on my list. When you mentioned interaction with the desktop, I knew there wouldn't be a desktop if the user wasn't logged in, I just didn't know if it was a requirement in order to use parameters.
  12. Assume $var is your string, then I would just use the StringMid and StringInStr commands as follows; StringMid($var,StringInStr($var,":")+2) This is assuming the " are part of the string. If you use the StringMid function without a character count, it will just return the rest of the string starting at your startpos (in this case, 2 characters after the first colon).
  13. I think you need to move these inside your while loop after your Sleep(5000) command. $posxa = random(411,500) $posya = random(72,85)
  14. Not sure about the desktop. If you mean is the 'Hidden' box checked in the General tab, the answer is no. However, I do want this to be able to run if the user is not logged in. When passing scripts, does the user account have to be logged in to the box for it to work? I have many scripts that access file shares running from a box where the user account is not logged on but the user account does have rights to the shares. As for the UNC path, everything is on the same box. I just always use UNC path so it can run from other locations if necessary.
  15. I have searched the forums and tried a few things but still haven't found a solution. I also have our local Network Support guys looking into this. I dont think it is an AutoIT issue but there is a wealth of knowledge out here in the forum and maybe someone has run across this in the past. I have a very simple script; #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #RequireAdmin If IsAdmin() Then MsgBox(0, "", "Admin rights detected") $param1 = $cmdline[1] $param2 = $cmdline[2] MsgBox(0,"","Parameter 1 = " & $param1 & @crlf & "Parameter 2 = " & $param2) I tried to set up a scheduled task and pass the parameters as arguments but it just hangs in a running state. I don't even get the first Message Box that says 'Admin rights detected'. I then set up a .bat file as shown below; \\ilxap-cmscript\e$\Scripts\In_Development\cold2_x64.exe "SJS" "123" I can run the .bat file and get each MsgBox returned. I then tried to set up a scheduled task calling the .bat file and still get nothing. That's why I think this is not and AutoIT problem. The server is running Windows Server 2008 R2 Enterprise, SP1, 64 bit. I have tried compiling as both x86 and x64 and neither works. I am doing everything remotely. I RDP to the server using the service account that everything runs as. I then set up the scheduled tasks as that same user. That's where I also go to run the .bat file manually. Can anyone shed some light on this? Is there something different I need to be doing for Win 2008 Server?
  16. Found it and it works great! Thanks.
  17. I'm not finding it in my install. I've got the latest version but I don't find it in the include folder. I can't find it online either. Where should I be looking?
  18. There is an app that writes to a file. When the file is complete, I need to move the file to another location. I have no control over the application that is writing the file. What I have done is to check the file size, sleep for 30 second and then check the file size again. If they were equal, I would assume the file was done writing. Most of the time that works fairly well. Unfortunately, on the first of the month, the other application could have the file open and writing to it for 4 or 5 hours while the job runs. There may be times when nothing gets written to the file for 5 or 10 minutes. What I need is a way to check the file to see if it is open by another process. I have scoured the help files and the forum but haven't found anything that looks to be my solution. Is there something in AutoIT that will return some value to let me know if the file is really in use? I have experimented with differrent files and AutoIT will let me do a FileOpen and read from a file that I already have open with another application.
  19. I have two issues. I have multiple spreadsheets, each with one worksheet. I want to copy all of these into one spreadsheet with multiple worksheets. I have been able to copy the contents from one worksheet to a new worksheet in a different spreadsheet by using the commands; $aArray = _ExcelReadSheetToArray($iExcel) ;Using Default Parameters _ExcelWriteSheetFromArray($oExcel, $aArray) However, this does not preserve the formatting (lots of cells with different colored backgrounds as well as italics and bold). Is there a way to copy a worksheet from one spreadsheet to another and keep the formatting? In the forums I see _ExcelCopy() and thought that might work but I don't see that in my help file. Currently running V 3.3.4.0 dated January 15th, 2010. Didn't know if an update might get me what I need, but right now I am being blocked by the firewall and Websense.
  20. I too have a hard time following just what you are saying. For copying files, you can assign a varaiable to the filecopy command and then use the return value to determin if the copy was successful or not. $filename1 = "source.txt" $filename2 = "destination.txt" $return = filecopy($filename1,$filename2,9) ;create destination folder and overwrite file if it exists. ; filecopy success returns 1. filecopy failure returns 0 if $return = 0 Then ;failed filewriteline("LogRecord.txt","File " & $filename1 & " not copied.") Else ;success filewriteline("LogRecord.txt","File " & $filename1 & " successfully copied as " & $filename2 & ".") EndIf The above example is OK for a few files, but not the best way if you are doing a lot of files. Instead, I would open the LogRecord.txt file for writing, then write to it each time, then close it at the end.
  21. I've never used 'Default' before but I will from now on. This worked perfectly!
  22. When creating an Inputbox and not defining the location, the box will default to the middle of the screen. However, if I want to put a timeout on the Inputbox, then I have to fill in the preceding values for default value, password, width, height, left, and top before I can enter the timeout value. Is there a way to get the inputbox to center on the screen like it does when no values are entered, without going through the trouble of determining the screen resolution then doing the math to position the box accordingly? $readfile = InputBox("File", "Enter file name to be read.") If $readfile = "" Then Exit $readfile = InputBox("File", "Enter file name to be read.","","",0,0,0,0,10) If $readfile = "" Then Exit First example will default the inputbox in the center of the screen. Second example puts it in upper left corner. I have tried using -1, "", and even leaving the fields blank but so far, no luck.
  23. I use the following for most all of my simple ftp processes. The downside is that there is no way to trap any error codes so I can't monitor for success or failure. $ftpfile = "ftpfile.ftp" ;name of file that will be used for ftp responses $ftpfilename = FileOpen($ftpfile, 2) ;open the ftp file with write access, overwriting previous versions FileWriteLine($ftpfilename, "open 100.200.300.400") FileWriteLine($ftpfilename, "username") FileWriteLine($ftpfilename, "password") FileWriteLine($ftpfilename, "prompt") FileWriteLine($ftpfilename, "mget \\servername\sharename\filename*.* /foldername/*.*") FileWriteLine($ftpfilename, "bye") FileClose($ftpfilename) ;close the ftp response file RunWait(@ComSpec & " /c " & 'ftp -s:"' & $ftpfile & "", "", @SW_MINIMIZE) ;executes the ftp command using the contents of $ftpfile as responses to the prompts. FileDelete($ftpfile) ;delete the ftp response file since it is no longer needed
  24. Thanks, I don't think I have ever used ControlSend() before. I'll give it a try.
  25. I have a PC that will eventually run a screen saver after x number of minutes of inactivity. I need to wake this PC up so I can run an app via an AutoIT script. I have experimented with WOL but the PC isn't really asleep, it's just in screensaver mode so sending the command doesn't do anything to stop the screensaver. I have tried mousemove but that doesn't work either. The script needs to move the mouse and do some mouse clicks in certain spots. When the PC is active (ie the desktop is showing) the script will start the app and execute the necessary commands. In screensaver mode, it doesn't work. I assume it has to do with the WinWaitActive command never finding the window due to the screensaver. Is there any way to wake the PC up?
×
×
  • Create New...