Update For all you Mozilla Firefox users: your plug in directories must be changed to this otherwise you get an error they come from your Internet explorer
If it's not set your default browser. Only use this if you're Mozilla Firefox is set as your default browser.Rem Type=Plugin
Rem Name=Auto Wikipedia Knowledge
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005 modified by Ismael Ledesma A.K.A moreis62
Rem Host=All
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
lblPlugin(0).Caption = "Just say: please study about the universe or please study about science, you can replace the word Universe or Science with any other word or noun, all information on the word is studied from the website Wikipedia"
lblPlugin(0).Move 120, 10, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub
Rem PLUGIN: PRE-PROCESS
Set objFirefox = CreateObject("MozillaFirefox.Application")
Set HalXBrain = CreateObject("UltraHalAsst.Brain")
Set FileSys = CreateObject("Scripting.FileSystemObject")
If XDir = "" Then XDir = "C:\Program Files\Zabaware\Ultra Hal Assistant 6\"
MyFile = "C:\Program Files\Zabaware\Ultra Hal Assistant 6\AutoText.brn"
If File_Exists = "" Then File_Exists = False
If FileSys.FileExists(MyFile) = True Then File_Exists = True
If File_Exists = False Then
HalXBrain.AppendFile XDir & "AutoText.brn", "Start of Knowledge strings"
End If
MyInput = HalXBrain.AlphaNumericalOnly(InputString)
If WikiToLookup = "" Then WikiToLookup = HalBrain.SearchPattern(MyInput, "*PLEASE STUDY ABOUT THE *", 2)
If WikiToLookup = "" Then WikiToLookup = HalBrain.SearchPattern(MyInput, "*PLEASE STUDY ABOUT *", 2)
If WikiToLookup = "" Then WikiToLookup = HalBrain.SearchPattern(MyInput, "*DO YOU KNOW ANYTHING ABOUT THE *", 2)
If WikiToLookup = "" Then WikiToLookup = HalBrain.SearchPattern(MyInput, "*DO YOU KNOW ANYTHING ABOUT *", 2)
If WikiToLookup <> "" Then
SourcePage = "
http://en.wikipedia.org/wiki/" & WikiToLookup
objFirefox.Navigate("
http://en.wikipedia.org/wiki/" & WikiToLookup)
Do Until objFirefox.ReadyState=4 : Loop
myText = objFirefox.Document.Body.innerText
If XDir = "" Then XDir = "C:\Program Files\Zabaware\Ultra Hal Assistant 6\"
HalXBrain.AppendFile XDir & "AutoText.brn", Trim(myText)
UltraHal = " I have looked up the study of " & WikiToLookup & ", Thanks. "
End If
'--------------------------------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Program Files\Zabaware\Ultra Hal Assistant 6\AutoText.brn", ReadVariable())
strText = objTextFile.ReadAll
objTextFile.Close
'--------------------------------------------
If InStr(1, strText, " ", vbTextCompare) > 0 Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Program Files\Zabaware\Ultra Hal Assistant 6\AutoText.brn", ReadVariable())
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\AutoText.brn", WriteVariable())
objFile.Write strNewContents
objFile.Close
End If
'--------------------------------------------
TextCount = StrCount()
If ClipXDir = "" Then ClipXDir = "C:\Program Files\Zabaware\Ultra Hal Assistant 6\"
For i = 1 To TextCount
If i > 0 Then ClipResX = HalXBrain.ChooseSentenceFromFile(ClipXDir & "AutoText.brn")
ClipResX = HalXBrain.AlphaNumericalOnly(ClipResX)
ClipResX = UCase(ClipResX)
ClipResX = Trim(ClipResX)
MyInputString = HalXBrain.AlphaNumericalOnly(InputString)
MyInputString = UCase(MyInputString)
MyInputString = Trim(MyInputString)
If InStr(1, ClipResX, MyInputString, vbTextCompare) > 0 And Len(ClipResX) > 50 Then
UltraHal = ClipResX
ElseIf Len(ClipResX) < 50 Then
UltraHal = UltraHal
End If
Next
'--------------------------------------------
Rem PLUGIN: FUNCTIONS
Function StrCount()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Program Files\Zabaware\Ultra Hal Assistant 6\AutoText.brn", ReadVariable())
strText = objTextFile.ReadAll
objTextFile.Close
Do While InStr(1, strText, " ")
strText = Replace(strText, " ", " ")
Exit Do
Loop
aWords = split(strText, ". ")
StrCount = Ubound(aWords) + 1
End Function
Function ReadVariable()
Const ForReading = 1
ReadVariable = ForReading
End Function
Function WriteVariable()
Const ForWriting = 2
WriteVariable = ForWriting
End Function