styles3000 Posted December 24, 2009 Share Posted December 24, 2009 I'm trying to write this script without having to shellexecute and without such repitiion. I tried this way...... $Title = _GetTitle("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0001.txt") but I got an error. expandcollapse popupOpt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",1) $sTotalFiles = _GetFileCount("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\") sleep(4000) For $i = 1 To $sTotalFiles shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0001.txt") sleep(4000) $Title = _GetTitle() sleep(4000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0002.txt") sleep(4000) $Title = _GetTitle() sleep(3000) sleep(4000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0003.txt") sleep(4000) $Title = _GetTitle() sleep(3000) sleep(4000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0004.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0005.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0006.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0007.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0008.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0009.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0010.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0011.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0012.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0013.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0014.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0015.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0016.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0017.txt") sleep(4000) $Title = _GetTitle() sleep(3000) shellexecute("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0018.txt") sleep(4000) $Title = _GetTitle() Func _GetTitle() Sleep(250) Opt("WinTitleMatchMode", 2) $text = WinGetText("Notepad") $posStart = StringInStr($text,'<title>') $posEnd = StringInStr($text,'</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'ERROR','This File doesnt Contain a Title') $result = '' ; This File doesnt Contain a Title Else $result = StringMid($text,$posStart+7,$posEnd-($posStart+7)) EndIf $result= StringLower($result) Return $result EndFunc Func _SendTitle($Title) Sleep(250) ControlSend("Notepad",'','', String($Title)) ControlSend('[Class:Notepad]', '', 'Edit1', $Title) Sleep(250) EndFunc Func _GetFileCount($Directory) Local $sTotalFiles = 0 $search = FileFindFirstFile($Directory&"*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($Directory&$file) If StringInStr($attrib,"D") < 1 Then $sTotalFiles = $sTotalFiles+1 EndIf WEnd FileClose($search) Return $sTotalFiles EndFunc Link to comment Share on other sites More sharing options...
whim Posted December 24, 2009 Share Posted December 24, 2009 Not tried (to lazy to generate .txt files, sorry ...) expandcollapse popup#Include <File.au3> Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",1) Global $mypath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" Global $output = $mypath & "results.txt" Global $number, $ret $number = _GetTitles($mypath) $ret = MsgBox(0, "Results", "Searched " & $number & " files" & @CRLF & "Click OK to open in Notepad") If $ret = 1 Then ShellExecute($output, "", "", "open") Func _GetTitles($Directory) Local $temp, $STotalFiles = 0 $search = FileFindFirstFile($Directory & "*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($Directory & $file) If StringInStr($attrib, "D") < 1 Then $sTotalFiles = $sTotalFiles + 1 ; read $file into array $temp; it will automatically be dimensioned, ; and temp[0] has the number of lines _FileReadToArray($Directory & $file, $temp) ; loop through array to find all titles For $i = 1 To $temp[0] $posStart = StringInStr($temp[$i], '<title>') $posEnd = StringInStr($temp[$i], '</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'ERROR','This File doesnt Contain a Title') $result = '' ; This File doesnt Contain a Title Else $result = StringLower( StringMid($temp[$i],$posStart+7,$posEnd-($posStart+7)) ) FileWriteLine($output, $result) EndIf Next EndIf WEnd FileClose($search) Return $sTotalFiles EndFunc hope that helps, whim PS don't know why this @#$! forum editor always screws with code indentation - copied straight from SciTE Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 Thank you,thank you,thank you. Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 Not tried (to lazy to generate .txt files, sorry ...) expandcollapse popup#Include <File.au3> Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",1) Global $mypath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" Global $output = $mypath & "results.txt" Global $number, $ret $number = _GetTitles($mypath) $ret = MsgBox(0, "Results", "Searched " & $number & " files" & @CRLF & "Click OK to open in Notepad") If $ret = 1 Then ShellExecute($output, "", "", "open") Func _GetTitles($Directory) Local $temp, $STotalFiles = 0 $search = FileFindFirstFile($Directory & "*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($Directory & $file) If StringInStr($attrib, "D") < 1 Then $sTotalFiles = $sTotalFiles + 1 ; read $file into array $temp; it will automatically be dimensioned, ; and temp[0] has the number of lines _FileReadToArray($Directory & $file, $temp) ; loop through array to find all titles For $i = 1 To $temp[0] $posStart = StringInStr($temp[$i], '<title>') $posEnd = StringInStr($temp[$i], '</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'ERROR','This File doesnt Contain a Title') $result = '' ; This File doesnt Contain a Title Else $result = StringLower( StringMid($temp[$i],$posStart+7,$posEnd-($posStart+7)) ) FileWriteLine($output, $result) EndIf Next EndIf WEnd FileClose($search) Return $sTotalFiles EndFunc hope that helps, whim PS don't know why this @#$! forum editor always screws with code indentation - copied straight from SciTE Its says, Error, no titile found. I'll try it again, I'll also check the paths to make sure they'll right. Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 Its says, Error, no titile found. I'll try it again, I'll also check the paths to make sure they'll right.Is there a function that extracts and holds the strings until I'm ready to send them? Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 Its says, Error, no titile found. I'll try it again, I'll also check the paths to make sure they'll right.What are the problems that arise when forum editor screws with code indentation - copied straight from SciTE? Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 What are the problems that arise when forum editor screws with code indentation - copied straight from SciTE? I'm having problems merging this script below with the prior one..... #include <file.au3> Func _CreateTaggedKeywords() Dim $aRecords $PthFile = 'D:\Rename.txt' ;Full path and filename to read $outputFileName = 'D:\New Text Document (2).txt' If Not _FileReadToArray($PthFile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $file = FileOpen($outputFileName, 2) For $x = 1 to $aRecords[0] FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF) Next FileClose($file) EndFunc Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 I'm having problems merging this script below with the prior one..... #include <file.au3> Func _CreateTaggedKeywords() Dim $aRecords $PthFile = 'D:\Rename.txt' ;Full path and filename to read $outputFileName = 'D:\New Text Document (2).txt' If Not _FileReadToArray($PthFile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $file = FileOpen($outputFileName, 2) For $x = 1 to $aRecords[0] FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF) Next FileClose($file) EndFunc When I try to merge these scripts, I get nothing but errors...... Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2009 Developers Share Posted December 24, 2009 When I try to merge these scripts, I get nothing but errors......... waiting impatiently on the next post here .... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 24, 2009 Share Posted December 24, 2009 Your code is a total mess and needs to be written from scratch. What exactly are you trying to return? If it's only the titles into a single file then it's straight-forward coding. Answer my question and you should get some reasonable answers. BTW: You still haven't replied to Jos about the errors. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 ... waiting impatiently on the next post here .... My bad Jos, I'm baking christmas cookies. LOL. I'm trying to merge this script ..... expandcollapse popup#Include <File.au3> Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",1) Global $mypath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" Global $output = $mypath & "results.txt" Global $number, $ret $number = _GetTitles($mypath) $ret = MsgBox(0, "Results", "Searched " & $number & " files" & @CRLF & "Click OK to open in Notepad") If $ret = 1 Then ShellExecute($output, "", "", "open") Func _GetTitles($Directory) Local $temp, $STotalFiles = 0 $search = FileFindFirstFile($Directory & "*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($Directory & $file) If StringInStr($attrib, "D") < 1 Then $sTotalFiles = $sTotalFiles + 1 ; read $file into array $temp; it will automatically be dimensioned, ; and temp[0] has the number of lines _FileReadToArray($Directory & $file, $temp) ; loop through array to find all titles For $i = 1 To $temp[0] $posStart = StringInStr($temp[$i], '<title>') $posEnd = StringInStr($temp[$i], '</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'ERROR','This File doesnt Contain a Title') $result = '' ; This File doesnt Contain a Title Else $result = StringLower( StringMid($temp[$i],$posStart+7,$posEnd-($posStart+7)) ) FileWriteLine($output, $result) EndIf Next EndIf WEnd FileClose($search) Return $sTotalFiles EndFunc with this script...... #include <file.au3> Func _CreateTaggedKeywords() Dim $aRecords $PthFile = 'D:\Rename.txt' ;Full path and filename to read $outputFileName = 'D:\New Text Document (2).txt' If Not _FileReadToArray($PthFile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $file = FileOpen($outputFileName, 2) For $x = 1 to $aRecords[0] FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF) Next FileClose($file) EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2009 Developers Share Posted December 24, 2009 I'm trying to merge this script ........ and your issue/problem is ?Listen: I will stay nice here because of the Christmas spirit but to be honest this is a totally ridiculous thread thus far.You are part of these forums long enough to understand how it works here....I'm baking christmas cookies. LOL. Hope you know better what you are doing there. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 Your code is a total mess and needs to be written from scratch. What exactly are you trying to return? If it's only the titles into a single file then it's straight-forward coding. Answer my question and you should get some reasonable answers.BTW: You still haven't replied to Jos about the errors.I know its mess codemaster GEOSoft. Thats why I'm coming to you guys, yall know what your doing. In your last post, you pretty much summed it up.Extract All Titles From 0001.txt-0020.txtPlace All Titles Extracted From Txt files Into.....index.htmPlace All Titles Extracted Into....index1.htmPlace All Titles Extracted Into....index2.htmPlace All Titles Extracted Into....index3.htm etc.I've been sitting at my computer for 2 days trying to figure this out..... Link to comment Share on other sites More sharing options...
styles3000 Posted December 24, 2009 Author Share Posted December 24, 2009 ... and your issue/problem is ?Listen: I will stay nice here because of the Christmas spirit but to be honest this is a totally ridiculous thread thus far.You are part of these forums long enough to understand how it works here.Hope you know better what you are doing there. My bad codemaster Jos, I didn't mean to upset you sir. Just trying to pull a project together that I've been working on. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 25, 2009 Share Posted December 25, 2009 Like Jos said, it's Christmas so... Well, according to your description, index1.htm through index[n].htm are exact duplicates of each other so lets take this one step at a time. The first step is to forget everything you've already posted. Now I have to make an assumption that the 00[n].txt files already exist on your system or you have already handled getting them. I'm also assuming that these are simply html files saved as text. Start by trying this and see where we are at. Keep in mind that it's not tested because I don't have the files and I also don't have a sample file to work from. #include<file.au3> $sText = "" $sPath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" $aFiles = _FileListToArray($sPath, "*", 1) If NOT @Error Then For $i = 1 To Ubound($aFiles) -1 $sHold = FileRead($sPath & $aFiles[$i]) $aTitle = StringRegExp($sHold, "(?i)<title>(.+)</title>", 1) If NOT @Error Then $sText &= $aTitle[0] & @CRLF EndIf Next EndIf If $sText Then $sFile = @TempDir & "\titles.txt" $hFile = FileOpen($sFile, 2) FileWrite($hFile, StringStripWS($sText, 2)) FileClose($hFile) ShellExecute($sFile) EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
styles3000 Posted December 25, 2009 Author Share Posted December 25, 2009 (edited) Like Jos said, it's Christmas so... Well, according to your description, index1.htm through index[n].htm are exact duplicates of each other so lets take this one step at a time. The first step is to forget everything you've already posted. Now I have to make an assumption that the 00[n].txt files already exist on your system or you have already handled getting them. I'm also assuming that these are simply html files saved as text. Start by trying this and see where we are at. Keep in mind that it's not tested because I don't have the files and I also don't have a sample file to work from. #include<file.au3> $sText = "" $sPath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" $aFiles = _FileListToArray($sPath, "*", 1) If NOT @Error Then For $i = 1 To Ubound($aFiles) -1 $sHold = FileRead($sPath & $aFiles[$i]) $aTitle = StringRegExp($sHold, "(?i)<title>(.+)</title>", 1) If NOT @Error Then $sText &= $aTitle[0] & @CRLF EndIf Next EndIf If $sText Then $sFile = @TempDir & "\titles.txt" $hFile = FileOpen($sFile, 2) FileWrite($hFile, StringStripWS($sText, 2)) FileClose($hFile) ShellExecute($sFile) EndIf Codemaster GEOSoft, Please allow me to send you the the files, their aren't many sir. My mentor is with his family for the holidays and I can't get intouch with him like I usually do via yahoo messenger. I would like to gain insight on how you construct the script so I can learn by your example. To answer your question....yes, index1.htm through index[n].htm are exact duplicates of each other. And yes....00[n].txt files already exist on my system and I have already handled getting them. The path to the text files is D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\ The path to the index files is D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\ Edited December 25, 2009 by styles3000 Link to comment Share on other sites More sharing options...
GEOSoft Posted December 25, 2009 Share Posted December 25, 2009 Send away. I'll just set up my own path structure. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
styles3000 Posted December 25, 2009 Author Share Posted December 25, 2009 Codemaster GEOSoft, Please allow me to send you the the files, their aren't many sir. My mentor is with his family for the holidays and I can't get intouch with him like I usually do via yahoo messenger. I would like to gain insight on how you construct the script so I can learn by your example. To answer your question....yes, index1.htm through index[n].htm are exact duplicates of each other. And yes....00[n].txt files already exist on my system and I have already handled getting them. The path to the text files is D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\ The path to the index files is D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\ Codemaster GEOSoft, I just ran it, your amazing!!!The script worked beautifully sir. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 25, 2009 Share Posted December 25, 2009 So amazing I missed the part where you wanted lower case Change $sText &= $aTitle[0] & @CRLF To $sText &= StringLower($aTitle[0]) & @CRLF George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
styles3000 Posted December 25, 2009 Author Share Posted December 25, 2009 So amazing I missed the part where you wanted lower case Change $sText &= $aTitle[0] & @CRLF To $sText &= StringLower($aTitle[0]) & @CRLF Will do sir. Don't down yourself sir. If we don't mess up from time to time, how will we ever learn codemaster sir? BTW....I tried to send you a zip file of the files but AutoIT would'nt let me,sir. 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