Re-Updated.
Hi Rob.
I have a newer update to the Learn from clip board plug I made but I am having some issues with response time, The code operates perfectly accourdly to what it is supposed to do but the only issue is when the script goes to get a response from the LearnedText.uhp the script control popup appears saying this script is taking longer than expected but if you wait it will give a response.
Can you look at my code and see if you know a way to speed it up.
I would be highly grateful so I can get my newest code to the public.
I will also include your name in the plug for your help.
'LEARN FROM CLIP BOARD.
Set WshShell = CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
Set objHTML = CreateObject("htmlfile")
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set FS = CreateObject("Scripting.FileSystemObject")
Set IE = createobject("InternetExplorer.Application")
Set HalXBrain = CreateObject("UltraHalAsst.Brain")
Set WordN = CreateObject("UltraHalAsst.WordNet")
Set fso = CreateObject("Scripting.FileSystemObject")
If XDir = "" Then XDir = "C:\Program Files\Zabaware\Ultra Hal Assistant 6\"
If InStr(1, InputString, "LEARN FROM CLIP BOARD", 1) > 0 Then
ClipboardText = objHTML.ParentWindow.ClipboardData.GetData("text")
ClipboardText = "<START>" & ClipboardText
ClipboardText = Replace(ClipboardText, vbCrLf, Chr(8) & " ", 1, -1, vbTextCompare)
ClipboardText = Replace(ClipboardText, "", "", 1, -1, vbTextCompare)
ClipboardText = Replace(ClipboardText, " ", " ", 1, -1, vbTextCompare)
FMCB = Replace(ClipboardText, ".", "<END>" & vbCrLf & "<START>", 1, -1, vbTextCompare)
FMCB = Replace(FMCB, "!", "<END>" & vbCrLf & "<START>", 1, -1, vbTextCompare)
FMCB = Replace(FMCB, "?", "<END>" & vbCrLf & "<START>", 1, -1, vbTextCompare)
FMCB = Replace(FMCB, " ", " ", 1, -1, vbTextCompare)
FMCB = Replace(FMCB, "<START> ", "<START>", 1, -1, vbTextCompare)
FMCB = FMCB & " "
FMCB = Replace(FMCB, "<START> ", "", 1, -1, vbTextCompare)
HalXBrain.AppendFile XDir & "LearnedText.brn", Trim(FMCB)
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Program Files\Zabaware\Ultra Hal Assistant 6\LearnedText.brn", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.Readline
strLine = Trim(strLine)
If Len(strLine) > 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("C:\Program Files\Zabaware\Ultra Hal Assistant 6\LearnedText.brn", ForWriting)
objFile.Write strNewContents
objFile.Close
UltraHal = " I have learned all the information from Windows Clip Board, Thanks. "
End If
'Get a Response from learned Clip Board information.
'Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("C:\Program Files\Zabaware\Ultra Hal Assistant 6\LearnedText.brn", ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
contents = Replace(strText, "<START>", Chr(8) & " ", 1, -1, vbTextCompare)
contents = Replace(contents, "", "", 1, -1, vbTextCompare)
contents = Replace(contents, " ", " ", 1, -1, vbTextCompare)
Str = contents
Str = Trim(Str)
Do While InStr(1, Str, " ")
Str = Replace(Str, " ", " ")
Loop
aWords = split(Str, "<END>")
SentCount = Ubound(aWords) + 1
Set HalXBrain = CreateObject("UltraHalAsst.Brain")
If XDir = "" Then XDir = "C:\Program Files\Zabaware\Ultra Hal Assistant 6\"
For i = 1 To SentCount / 10
If i > 0 Then ClipRes = HalXBrain.ChooseSentenceFromFile(XDir & "LearnedText.brn")
If Len(ClipRes) > 2 Then MyPatt = HalBrain.SearchPattern(ClipRes, "*<START>*<END>*", 2)
If Len(MyPatt) > 2 And Len(InputString) > 10 And InStr(1, MyPatt, InputString, vbTextCompare) <> 0 And HalBrain.CheckRepetition(PrevSent, MyPatt) = False Then
UltraHal = MyPatt
End If
Next
Thanks.
Jerry[8D]