Jump to content

chewy

Active Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by chewy

  1. this does the trick thanks! it does run the processor a little high but not a deal breaker.
  2. I took out the sleep commands and the gui doesnt lock up now. However I would still like the script to pause for a certain number of seconds between ping polls.
  3. hmmm...same result
  4. i did put that in but it had no effect on being able to close the window. im on a win 7 pro machine if that makes a difference
  5. I know this should probably be basic programming but I am having an issue with this. I am trying to create a simple app that pings a server to tell if it is up or not. if it is up it puts a checkbox image and if is not reachable it is given an x image. My code seems to work fine but I cant get the window to close when I click the close "x". It seems like it is too busy to close it or something. Sorry for the probably noob question. #include <INet.au3> #include <GUIConstantsEx.au3> GUICreate("Hello World", 300, 300) $buttonServer1 = GuiCtrlCreatePic("C:\Users\Administrator\Desktop\ping server test\Exclamation.bmp",110,0, 0,0) GUISetState() $i = 0 While 1 $var = Ping("www.google.com") If $var Then; also possible: If @error = 0 Then ... GUICtrlSetImage($buttonServer1, "C:\Users\Administrator\Desktop\ping server test\CheckMark.bmp") GUISetState() $i = $i + 1 Sleep(10000) ;two seconds Else GUICtrlSetImage($ButtonServer1, "C:\Users\Administrator\Desktop\ping server test\Failed.bmp") GUISetState() $i = $i + 1 Sleep(10000) ;two seconds EndIf WEnd
  6. I think I got it. I guess I should have read a little deeper
  7. I have searched and found $cmdline and a few other topics that seems to be what I am looking for but I couldn't seem to understand it. I would like to pass a parameter to a compiled autoit exe file. What I actually want to do is create an exe then pass a string of text to the exe at runtime. I need that text I pass to be dynamic. I want to be able to give network messages like the mail server is getting rebooted at 3:00PM or something like that. So I want to pass the message in as a parameter then be able to use it in the script. hope this makes sense.
  8. thanks for the help guys, I was overthinking this. I reworked it and got it to work. Here is the code in case anyone is interested. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: Matt Majewski Date: 5.20.09 Script Function: Edits the host file to append zenwsimport IP this will add the specified IP address regardless of whether zenwsimport is already in the HOSTS File This script will either add the IP in or edit the existing. It will NOT leave the ZEN IP in the file if one exists already for some reason it adds an extra line break at the beginning of the HOSTS file when it saves. Feel free to figure out why and fix if you want! #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <file.au3> #include <Array.au3> ;DEFINES ;EDIT THIS IP TO THE IP ADDRESS OF YOUR ZEN SERVER YOU WANT MACHINES TO IMPORT TO $ZENIP = "172.20.96.2" ;HOSTS file path $sFile = @SystemDir & "\Drivers\etc\hosts" ;used to define the index in the array when zenwsimport was found Dim $zenfind ;the array used to import the HOSTS file to Dim $aRecords ;Open the HOSTS file for reading into the array If Not _FileReadToArray(@SystemDir & "\Drivers\etc\hosts",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf ;searches the imported array to find the word "zenwsimport" ;then set the arrayindex it found it into $zenfind $zenfind = _ArraySearch ($aRecords, "zenwsimport", 0 , 0, 0, True) ;IF it found zenwsimport IF ($zenfind <> -1) Then ;change the array to include the new zen ip Number ;it changes the specific array index based on the earlier search $aRecords[$zenfind] = $ZENIP & " zenwsimport" ;open the host file for editing ;the 2 parameter will erase the contents of the file $hFile = FileOpen($sFile, 2); 2 = erase ;write the array to the open File _FileWriteFromArray($hfile, $aRecords, 1) ;close the HOSTS file that was opened FileClose($hFile) ; did not find zenwsimport Else ;open the host file for editing ;the 1 parameter will append to the end of the file $hFile = FileOpen($sFile, 1); 1 = append ;write the new zen ip to the end of the file FileWriteLine($hFile, $ZENIP & " zenwsimport") ;close the HOSTS file that was opened Fileclose($hFile) ;END IF found ZENWSImport of not EndIf
  9. here is what I have #include <file.au3> #include <Array.au3> Dim $zenfind Dim $aRecords If Not _FileReadToArray(@SystemDir & "\Drivers\etc\hosts",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf ;_ArrayDisplay($aRecords, "b") For $x = 0 to $aRecords[0] Msgbox(0,'Record:' & $x, $aRecords[$x]) ;;;;;xxxxx;;;;;msgbox (0, "test", $aRecords[0]) $zenfind = _ArraySearch ($aRecords[$x], "zenwsimport", 0, 0) msgbox (0,"zenfind", $zenfind) if $zenfind <> -1 then $aRecords[$x] = "172.20.96.2 zenwsimport" msgbox (0,"after 96.2 check",$aRecords[$x]) EndIf Next Im getting -1 everytime for the $zenfind from the array search even though I know it is in the host file
  10. i got the array to read in, but I dont know how to find and delete out a line within the array and save the results to the original file
  11. I know there has been question asked about editing the host file before. I have been able to successfully open the host file and add in a new entry with no problem. I am also able to do a find and replace in the host file with no problem. What I want to accomplish is to be able to open a host file and search for a string of text and replace the entire line. For example: in my host file if I may or may not have a line like the following 10.0.0.1 zenwsimport However the ip address could be different, so what I would like to have happen is check for the word "zenwsimport" (that will be constant, if the line is there at all) and if it is found, edit the entire line to say: 10.0.0.2 zenwsimport Also if zenwsimport is not found I would add in the line above. So basically I know I need to read everything into an array, but that is where I am stuck. I get confused trying to delete out the array line I want removed and the new line added in. Any direction and help would be appreciated!
  12. I just wanted to thank the creator and everyone who makes AutoIT such an easy and intuitive product! It never ceases to amaze me!!!!
  13. another question about this. Now I also need to erase the last character in the file. This is what I use to delete the first 2 characters and it work perfect now I need to delete out the last character in the file. Any ideas?
  14. Thanks! works perfect now! thanks for the help!
  15. Func _RemoveLeadingCharsFromFile($sInFile, $sOutFile, $iRemoveChars) Local $sAll, $hFile $sAll = FileRead($sInFile, FileGetSize($sInFile)) $hFile = Fileopen($sOutFile, 2) FileWrite($hFile, stringmid($sAll, $iRemoveChars + 1,filegetsize($sInFile))) FileClose($hFile) EndFunc remember i am new at this
  16. boy I spoke too soon, if I write it to a different filename than the original it is fine, but if the output file is the same as the input file the output file is blank
  17. you were missing the count parameter in the stringmid, works good now! thanks for the help!
  18. i tried phillips response and get the following error
  19. the file is about 100K or so
  20. my answer is giving me problem because it is using wordpad instead of notepad on a 98 machine. any more suggestions on this, I cant seem to implement the giving suggestions
  21. got it Run('C:\Windows\Notepad.exe "C:\Documents and Settings\Administrator\Desktop\canastotaMiddle.txt" ') WinWaitActive("CanastotaMiddle.txt - Notepad") Send("{DELETE}") Send("{DELETE}") Send("!f") Send("s") WinClose("CanastotaMiddle.txt - Notepad", "") i was trying too hard
  22. winwaitactive was what i needed
  23. i tried this Run('C:\Windows\Notepad.exe "C:\canastotahigh.txt" ') WinActivate("CanastotaHigh.txt - Notepad") Send("{DELETE}") the problem is the window will not keep the focus
  24. I am looking to open a specific text file and need to delete the first 2 characters in the file and then save the file. I am very new to this any help would be appreciated. Thanks
×
×
  • Create New...