Jump to content

Hadez

Active Members
  • Posts

    60
  • Joined

  • Last visited

Everything posted by Hadez

  1. Hi, Ive managed to write a script that uses Command_Line_SFV_Checker_v0.1 to check the sfv of files being uploaded to my server by FTP. It searches a folder for an sfv, and then runs recursively until the sfv check passes. It will then email me on file upload completion. Sometimes the folders that are being uploaded contain files with an .sfv directly in them, and sometimes they contain subfolders, which each contain files with an .sfv. The script works great when the files are in the main folder, but im having some issues when there are subfolders. For Example: A folder called 'PhotoshopDesigns' is uploaded and contains the subfolders 'cd1' and cd2'. Inside the folder cd1, there is a set of files with an .sfv, and inside cd2 there are a set of files with an .sfv. like: PhotoshopDesigns/Cd1/cd1files.sfv PhotoshopDesigns/Cd2/cd2files.sfv So when a folder is uploaded to my server by FTP, my script will need to search inside of that folder and If it finds there is an .sfv, then run the sfv check, but if there are subfolders by the names of cd1, cd2, cd3 , then check each of the subfolders and run an sfv check inside each. Only once the sfv checks for each of these subfolders have all passed, then run a script that emails me ( I will write the email script later). My code so far is: #include <Constants.au3> $sfvcheck = "Enfis_SFV.exe -c=G:\PhotoshopFiles\PhotoshopDesigns\particleremovaltests.sfv" While 1 do Sleep (100) $DOS = Run(@ComSpec & ' /c ' & $sfvcheck, "", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $Message = StdoutRead($DOS) $Missing = StringInStr($Message, " Missing") Until $Missing = 0 MsgBox(0, "Stdout Read:", $Message) Exit Wend Any help will be much appreciated Thanks for taking the time.
  2. Not very clear what you mean, but if you want the value of the input box changed after submitting (just guessing due to your title of the thread) Then you can try destroying the input box after submitting the value and recreate the inputbox. that way you get an empty input box after everytime you submit.
  3. Im trying to read a shoutbox in real time on a website. It will read each line and then if it sees a string within that line, it will respond. I used: $sUrl = "http://site.com" $oIE = _IECreate($sUrl) $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 1) $oShoutbox = _IEGetObjByName($oForm, 'shoutbox_form') $sText = _IEBodyReadText($oShoutbox) filewrite(@scriptdir & "\write.txt", $sText) $shoutstring = fileread(@scriptdir & "\write.txt") _Main() Func _Main() Local $aArray1 = _StringBetween($shoutstring, ">>>>>>", "<<<<<<") ;_ArrayDisplay($aArray1, 'Default Search') ;$aArray1[0] = StringReplace($aArray1[0], @CRLF & @CRLF, @CRLF) $aArray1[0] = StringStripWS($aArray1[0], 3) filewrite(@scriptdir & "\filewrite.txt",$aArray1[0]) EndFunc ;==>_Main This gets the correct section for the shoutbox, but i dont know how to only write new lines to the text file. Since i need it to be able to respond when it reads a line, i need it to only read new lines, 1 by 1. Any idea how i go about this? Thanks for any help.
  4. So far no luck on disabling _IECreateEmbedded () scroll bar. I was thinking of a way around it may be to make the GUISetBkColor (0x000000) so its black, then add a black picture over the scroll bar so it makes them unusable. If that works, then i could probably also create a transparent label to put over the actual _IECreateEmbedded () so that the IE becomes unclickable. This may round the user not being able to navigate away from the section of the page i want to view. Any pointers on doing this? Can it be done? Thanks for any help.
  5. $Breaktime = GUICtrlCreateObj($B_oIE3, -45, -140, 540, 510) Thanks. that was a great help, although i see that if i press tab on the webpage, it moves off from what i want it to show. That aswell as the gui having scroll bars that i cant get rid of. Will look out for ways to get rid of them. Thanks again.
  6. I have created a gui that embeds a website. The problem is that i dont want to display all of the website. i only want to show the shoutbox which is just a small part of the page. Is there any way to do this? like a crop or only showing a form? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 620, 480) $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 530, 100, 30) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 530, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 530, 100, 30) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 530, 100, 30) GUISetState() ;Show GUI _IENavigate ($oIE, "http://www.google.com") ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate ($oIE, "http://www.google.com") Case $msg = $GUI_Button_Back _IEAction ($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction ($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction ($oIE, "stop") EndSelect WEnd GUIDelete() Exit
  7. #include <File.au3> #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hFileHTM, $sFileHTM = @ScriptDir & "\Form.htm" Global $oHTTP, $oReceived, $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ;Post request $oHTTP.Open("POST", "http://website.com/takelogin.php" , False) ;Add User-Agent header $oHTTP.SetRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR ") ;Add Referrer header$oHTTP.SetRequestHeader("Referrer", "http://www.REFERRERURL.com") $oHTTP.SetRequestHeader("Referrer", "http://website.com/login.php") ;Add Content-Type $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.SetRequestHeader("Connection", "keep-alive") ;$oHTTP.Send() $oHTTP.Send("username=xxxxxx" & "&password=xxxxxx" & "&index.php?logged=true") ;now open next page $oHTTP.Open("POST", "http://website.com/upload.php" , False) ;Add User-Agent header $oHTTP.SetRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR ") ;Add Referrer header$oHTTP.SetRequestHeader("Referrer", "http://www.REFERRERURL.com") $oHTTP.SetRequestHeader("Referrer", "http://website.com/upload.php") ;Add Content-Type $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.SetRequestHeader("Connection", "keep-alive") $oHTTP.Send("subject=title.of.the.file" & "&message=this+is+a+description") $oReceived = $oHTTP.ResponseText If $oReceived Then MsgBox(64 + 262144, "Done!", "Will open returned page in your default browser now." & @CRLF & _ "It should show sent data.") $hFileHTM = FileOpen($sFileHTM, 2) FileWrite($hFileHTM, $oReceived) FileClose($hFileHTM) ShellExecuteWait($sFileHTM) EndIf This successfully redirected to another page and posted to that page. I was unable to go further and figure out how to upload a file so went with curl instead. Hope it helps you.
  8. #include <IE.au3> $sName = "username" $sPassword = "password" $sUrl = "http://www.wizards.com/dnd/launch.aspx?x=dnd/dnd/cblaunch" $oIE = _IECreate($sUrl) Sleep(3000) $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oName = _IEGetObjByName($oForm, "ctl00$ctl00$ctl00$ctl00$SiteContent$DnDContent$ctl00$UserName") $oPassword = _IEGetObjByName($oForm, "ctl00$ctl00$ctl00$ctl00$SiteContent$DnDContent$ctl00$UserPassword") $oSubmit = _IEGetObjByName($oForm, 'ctl00$ctl00$ctl00$ctl00$SiteContent$DnDContent$ctl00$LoginButton') _IEFormElementSetValue($oName, $sName) _IEFormElementSetValue($oPassword, $sPassword) _IEAction ($oSubmit, "click") The page didnt load for me so cant confirm this works, but it may put you on the right track hopefully.
  9. Thanks for the info on headers. That seemed to be the problem. I decided to use $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") instead of WinHttp.au3. I have now successfully redirected to another page. i have a question though. It seems some of the fields on that page have different content types to others. If im sending data to 1 page, do i use the pages Content-Type: multipart/form-data and then set a content type for each field that requires it or just use the pages content-type? E.G. The pages content type is: Content-Type: multipart/form-data there are some fields on that page that i need to send data to like: Content-Disposition: form-data; name="file"; filename="C:\Testfolder\test.txt" Content-Type: application/octet-stream 2 fields have this content type but the others dont. Is this important or can i use the pages Content-Type? $oHTTP.SetRequestHeader("Content-Type", "multipart/form-data") $oHTTP.Send()
  10. The name:username etc are the field names. i used debugbar to get every fieldname. The first page is way off? That first page was a login page and the response showed that i logged in ok. I filled it in according to _WinHttpSimpleFormFill. Oh, and i already wrote a fully working script to do what i want using IE, but wanted to use POST instead as it is alot more convenient than having to open IE. Im pretty sure i what what im coding, just struggling with how to do it. I'll now look into HTTP headers. See if that is where my issue is. Thanks
  11. no1 knows the problem? ive tried so many variations to the examples to try to get a redirect. when i do successfully get a redirect, its to the wrong page lol. I just need to know if its the format thats wrong so i can cancel the issue down to incorrectly using the parameters. Thanks to anyone who can shed some light on the problem.
  12. now i defo need help. i checked with the site im using POST with and can confirm its my code thats the problem. i can login, but cant redirect to a page on that site and post data there, im using the code below. If you could point out where i going wrong, i would appreciate it as ive been stuck here for ages. #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hOpen = _WinHttpOpen() Global $hConnect, $sRead, $hConnect2, $sRead2 Global $hFileHTM, $sFileHTM = @ScriptDir & "\Form.htm" ; Get connection handle $hConnect = _WinHttpConnect($hOpen, "website.com") $sRead = _WinHttpSimpleFormFill($hConnect, "takelogin.php", "takelogin.php", "name:username", "xxxxxxx", "name:password", "xxxxxxx") $hConnect2 = _WinHttpConnect($hOpen, "website.com") $sRead2 = _WinHttpSimpleFormFill($hConnect2, "index.php", "shoutbox_form", "name:shoutbox_message", "test", "name:shout_submit", "Shout") _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hConnect2) If $sRead2 Then MsgBox(64 + 262144, "Done!", "Will open returned page in your default browser now." & @CRLF & _ "It should show sent data.") $hFileHTM = FileOpen($sFileHTM, 2) FileWrite($hFileHTM, $sRead2) FileClose($hFileHTM) ShellExecuteWait($sFileHTM) EndIf _WinHttpCloseHandle($hOpen)
  13. as good as the examples are, i still cant work out how to redirect to another page after logging in. It must be that im not trying hard enough then Either that, or there is something wrong with the site im trying to POST to
  14. I relooked at WinHttp.au3. there are good examples, but the problem is that i cant find anywhere that says what the parameters are. E.G $sRead = _WinHttpSimpleFormFill($hConnect, "html/html_forms.asp", "name:input0", "name:user", "OMG!!!") i see that but dont know what the parameters are. i have no idea what is supposed to go between each comma, so cant figure out how to modify the examples to do what i want. thats why i asked for help here.
  15. ive had a look at WinHttp.au3 but didnt understand it. When you said i should just go to that page, ive tried adding $oHTTP.Open("POST", "http://POSTWebsite.com/forum.php" , False) at the end of the script but $oReceived = $oHTTP.ResponseText shows that that page doesnt load. Ive read through every forum post in every forum thread but wasnt able to scrape the info from it. Any help with this? Thanks
  16. Im wondering if anyone can help me with a http post problem. Iam able to log into a site easily enough but i need to be able to get to another page on the site after that, but im unsure how. currently im using the code below to login but i need to get to the http://POSTWebsite.com/forum.php page after login so that i can post a new thread. anyone got any ideas how to do this? $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "http://POSTWebsite.com/login.php" , False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)") $oHTTP.SetRequestHeader("Referrer", "http://www.google.com") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.SetRequestHeader("Connection", "keep-alive") $oHTTP.Send("username=xxxxxxx" & "&password=xxxxxxx") $oReceived = $oHTTP.ResponseText Thanks for any help
  17. $aSRE = StringRegExp($sStr,"(?i)Process Error/Cause/([a-z]{2}\d{4}).*(?:\v|$)+", 3) This line worked perfectly. Thanks alot GEOSoft
  18. $nOffset = 1 $sStr = FileRead("C:\Documents and Settings\ST\Desktop\Log.txt") $aSRE = StringRegExp($sStr,'Process Error/Cause/(.+)(?:\v|$)+', 1, $nOffset) ;StringRegExp("test", If NOT @Error Then For $i = 0 To Ubound($aSRE) -1 msgbox(0, "Process Error/Cause/" & $i, "Process Error/Cause/" & $aSRE[$i]) Next EndIf so far that finds the string im looking for but also has all the end characters to the readline that i dont want. is there any way to trim the string so that only 6 characters are after 'Process Error/Cause/' ? E.g The line on the text reads 'gggggggggg Process Error/Cause/sd0215 ooooooooooooooooo' stringregexp gets it to 'sd0215 ooooooooooooooooo' i only want the sd0215 (sd0215 is a variable) any ideas how to trim it?
  19. not always. there can be absolutely anything before or after it. and GEOSoft, i think im being a numpty but i cudnt get ur code to work. tried to mess around with it but still cudnt get it to work
  20. I think that would work if i knew what was before and after the string but unfortunately i dont. the line on the text file could be: iiiiiiiiiiiiiiiffffff Process Error/Cause/as2455 aaaaaaaassasadasdasdfsasf or hhhhhhhhhjjjjjjfuf Process Error/Cause/ds1234 dasdasdfaeffvasd or aadf Process Error/Cause/hj4415 dsdsdasdasd etc i put the ' in the first post to show what the string was. '' are not a part of the string. thanks for taking the time ot reply though
  21. Iam able to search for a string within a text file, but the problem arrises when there is an unknown variable attached to the string im searching for. E.G. I fileread Log.txt. I need to search for the string 'Process Error/Cause/xxyyyy' ( where x are unknown letters and y are unknown numbers. 'Process Error/Cause/' is always present before the unknown characters) This string could be contained anywhere within the txt file so i cant specify a line number to search. Once the string is found, the string is written in a msgbox How would i go about searching for this string? Thanks for any help you can give.
  22. Thanks for your help. Think its all done now Awesome #include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> while 1 _deleteOld() wend Func _deleteOld() $FREE = DriveSpaceFree("C:\") if $FREE > 10240.00 then MsgBox(0,"TEST", "You have " & $FREE & " free space",1) sleep(360000) Return Endif if $FREE < 10240.00 Then $dir = "D:\Files\" $search = FileFindFirstFile($dir & "*.*") ; get all files from the directory If $search = -1 Then ; return an error if the search fails MsgBox(0, "Error", "No files found in the search") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($dir & $file, 1) ; Pulls the file creation time into an array, use 0 for a string $tformatted = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5] ; Formatted to work with _DateDiff $iDateCalc = _DateDiff( 'D', $tformatted,_NowCalc()) ;throws the difference of the time in Days into the variable if $iDateCalc > 4 Then filedelete($dir & $file) ;If the value, returned in days, is greater than 4 (5 or higher) delete the file Sleep(100) WEnd FileClose($search) Endif EndFunc ;==> _deleteOld()
  23. Im working on a script that will auto delete files when the hdd space on the drive gets below 10gb.Once if sees that the free hdd space falls below 10gb, The script will check the folder i want it to delete files from, check the creation date of each file and if the file is over 5 days old, then delete it. Im having some problems with the checking of files. Can anyone give some guidance? ive sort of got the search function for the files i want to delete, and ive got the date i want to delete the fiels that were created early than but am strugglin to join the two. Any help would be appreciated. So in summary: Drive space will be watched If Free Drive space goes below 10gb, the folder D:\Files\ is searched All files in D:\Files\ that are older than 5 days old are deleted Process is looped. #include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> Global $iMemo Local $FREE, $search, $hGUI, $tFile, $aFile, $sFile ; Create GUI ;$hGUI = GUICreate("Time",400,400) ;$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 396, $WS_VSCROLL) $hGUI = GUICreate("Drive Space", 469, 639, (@DesktopWidth - 469) / 2, (@DesktopHeight - 639) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $iMemo = GUICtrlCreateEdit("", 2, 2, 465, 635, $WS_VSCROLL) GUICtrlSetFont($iMemo,9, 400, 0, "Courier New") GUISetState() While 1 FREEDRIVESPACE() WEnd Func FREEDRIVESPACE() $FREE = DriveSpaceFree("C:\") ;Shows the filenames of all files in the current directory. if $FREE < 10480.00 then $search = FileFindFirstFile("D:\Files\" & "*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Sleep(10000) Return EndIf While 1 $file = FileFindNextFile($search) $t = FileGetTime("D:\File\" & $file, 1) if not @error then $yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2] ; getting errors on this once list completes endif ;If @error Then ExitLoop if $file = "" then Return MemoWrite("File: .: " & $file) MemoWrite("CREATION DATE .: " & $yyyymd) sleep(10) WEnd Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Close the search handle FileClose($search) elseif $FREE > 10480.00 then MsgBox(0,"TEST", "You have " & $FREE & " free space", 0) sleep(1000) Return Endif EndFunc Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite ;######### Finds Date Roughly five days before Todays date ################ $Dayminus5 = @MDAY - 5 if $Dayminus5 = 0 then $Dayminus5 = -1 if $Dayminus5 < 0 Then $NewDay = 31 - SQRT(($Dayminus5)*($Dayminus5)) if $NewDay = 0 then $NewDay = 31 Endif $NewMonth = @MON - 1 if $NewMonth = 0 then $NewMonth = 12 $NewYear = @YEAR - 1 Endif $NewYear = @YEAR Endif If $Dayminus5 > 0 Then $NewDay = $Dayminus5 $NewMonth = @MON $NewYear = @YEAR Endif MsgBox(0, "New Date", $NewYear & "/" & $NewMonth & "/" & $NewDay)
  24. Thank you all for your help. I managed to solve it with your help, although my method was a little noob like It is kind of based on: Local $avArray[4] $avArray[0] = ".jpg" $avArray[1] = ".png" $avArray[2] = ".gif" $avArray[3] = ".bmp" ;ect... $line = FileReadLine($filename) For $i = 0 to UBound($avArray) - 1 If StringInStr($line,$avArray[$i]) > 0 Then FileDelete($filename) Return ;Go back to While 1 EndIf Next ;rest of processing But i cudnt quite work that out, so used a basic version of it: While 1 Search() WEnd Func Search() $chkNewFileLocation = FileFindFirstFile($chkPath & "\*.txt") If $chkNewFileLocation = -1 Then Sleep(10000) Return EndIf While 1 $chkNewfile = FileFindNextFile($chkNewFileLocation) $chkNewFilePath = $chkPath & $chkNewFile $filetypecheck = Fileread($chkNewFilePath) $oofiletype = StringRight($filetypecheck, 4) If $oofiletype = ".png" Then Filedelete($chkNewFilePath) Return elseif $oofiletype = ".gif" Then Filedelete($chkNewFilePath) Return elseif $oofiletype = ".jpeg" Then Filedelete($chkNewFilePath) Return Endif msgbox(0,"Success","This works ok so continue procesing") ; rest of processing follows Sleep(10000) WEnd EndFunc seems like the StringRight solved the problem. Thanks for also explaining Return. The biggest problem for me was to get back to while 1, which return solved. Thanks for all your help
  25. I wasnt trying to be vague. I was trying to be as clear as i cud but obviously didnt succeed. I appreciate your input on recursion, but my method runs perfectly fine the way i did it, and like i said before, if anything goes wrong, then i will try your method out, but until then, whats the point of trying to fix something that isnt broke. This is a script that runs line by line, and as such, it currently performs its task good. Your comparison with that of a car is a little off, since a car is alot more complex and every detail can make a difference. With this script, if it works, then i dont find it necessary to mess around with it as it is a personal script and not for professional use. For my next script, however, i will follow your guide to recursion. In case it is me not being clear with my problem, then i shall try to be alot more clearer My script runs like this: My script watches a folder for new txt files. (E.G. C:\Watchfolder) These text files are named after a file elsewhere on the system that needs to be processed later. (E.G. apples.txt) This filename changes depending on the name of the file that needs to be processed. Inside these text files there is 1 line. This line contains the location of a file that i would need to process later (E.G. C:\Photos\Apples.rar) If it finds a txt file, then it reads the file location and continues to process the file. The processing is long so i didnt find the need to include it above. But for this case, lets say the process is to just move the file. So, C:\Photos\Apples.rar is then moved to another folder. (E.G. C:\fileafterprocess) Once that is done, apples.txt is then deleted and the script loops from the beginning to process the next txt file. If no txt file is there, then it sleeps for 10 seconds and then rechecks. The problem i currently have is that it will process (move) whatever file that is written inside the txt file. If it says C:\Photos\Apples.rar inside the txt file, then i would like it process it, but if it says C:\Photos\Apples.jpeg, C:\Photos\Apples.png or C:\Photos\Apples.gif, then i would like it to not process the file and to delete Apples.txt from C:\Watchfolder, before looping to the beginning of the script to check C:\Watchfolder for any other txt files. I hope this is explained clearer now.
×
×
  • Create New...