Sign in to follow this  
Followers 0
IchBistTod

ICI Intelligent Computer Interface

8 posts in this topic

#1 ·  Posted (edited)

 Ok Well I took two ideas and put them together to create a very basic framework. However after i took a break and got back to coding my enthusiasm had worn off a bit, as I do have depression... it does ruin A lot of my projects.....

Anyways, the idea is to combine an AI Bot that talks with an AI bot that can assist. For example, you can have a chat with it, then ask it to look up the word "Verlorn", or to translate "verlorn to english" or to solve "5*10", and other tasks such as backup the registry, run a file, download a program, you get the idea pretty much anything.

I hope to turn this  into a community project where everyone works on it and submits their edits and improvements to make something better. Perhaps then when i see it progression I will get my encouragement back, and in addition to that, with others helping this will get done much faster. 

Code(Right now it learns your name, and tells the time)

#include <GUIConstantsEx.au3>
#include <IE.au3>
HotKeySet("{enter}", "_enter")
#Region Global Constants
Global Const $ini = @ScriptDir&"\ici.ini" ;decalre the location of the settings file as a constant(meaning it cant be changed)
Global Const  $brain = @ScriptDir&"\ici.brain" ;decalre the location of the brain file as a constant(meaning it cant be changed)
Global Const $title = "ICI - Intelligent Computer Interface" ;decalre the title of the window as a constant(meaning it cant be changed)
#EndRegion

#Region Defaults
if not FileExists($ini) Then ;if the settings file doesnt exist
    IniWrite($ini, "window", "x", (@DesktopWidth/2)-(500/2)) ;default x pos on screen
    IniWrite($ini, "window", "y", (@DesktopHeight/2)-(550/2)) ;default y pos on screen
EndIf
#EndRegion

#Region Window Settings
Global $width = 500
Global $height = 550
Global $x = IniRead($ini, "window", "x", (@DesktopWidth/2)-(500/2)) ;Get the last used x pos of the window from the settings file
Global $y = IniRead($ini, "window", "y", (@DesktopHeight/2)-(550/2)) ;Get the last used y pos of the window from the settings file
#EndRegion

#Region Brain Settings

Global $user_name = IniRead($brain, "userinfo", "name", "?") ;Get the name of the user
#EndRegion

#Region Gui Creation
Global $gui = GUICreate($title, $width, $height, $x, $y, bitor(0x00020000, 0x00800000, 0x00010000, 0x00040000)) ;create the main window and make it resizable
Global $OIE = _IECreateEmbedded() ;create an IE object so we can use HTLM to format the text/images
Global $GUIACTIVEX = GUICtrlCreateObj($OIE, 10, 10, $width-20, ($height/1.2)-20) ;add object to window
GUICtrlSetResizing(-1, 102) ;set the control to resize docking all borders
_IENavigate($OIE, "about:blank")
Global $input = GUICtrlCreateEdit("", 10, ($height/1.2)+5, $width-20, $height-($height/1.2)-30)
GUICtrlSetResizing(-1,  $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) ;set the control to resize docking all borders
GUISetState(@SW_SHOW, $gui) ;show the gui
if $user_name = "?" then ;if the user's name is not known, ask for it
    $name = 0
_IEBodyWriteHTML($OIE, '<font color="#FF0000">ICI-1.0</font>&nbsp;Says:<br/>&nbsp;&nbsp;Hello, My name is ICI-1.0 and my Job is to assist you with every day computer tasks. What name should I address you by?')
Else ;else greet them
    $name = 1
_IEBodyWriteHTML($OIE, '<font color="#FF0000">ICI-1.0</font>&nbsp;Says:<br/>&nbsp;&nbsp;Welcome back '&$user_name&'.')

EndIf

#EndRegion


while 1
    $guimsg = GUIGetMsg($gui)
    Switch $guimsg
        case -3

            $positionsize = WinGetPos($gui)
            IniWrite($ini, "window", "x", $positionsize[0]) ;write x position of window to settings file on exit
            IniWrite($ini, "window", "y", $positionsize[1]) ;write y position of window to settings file on exit
            IniWrite($ini, "window", "width", $positionsize[2]) ;write width of window to settings file on exit
            IniWrite($ini, "window", "height", $positionsize[3]) ;write hight of window to settings file on exit


            Exit
    EndSwitch
    sleep(20)
WEnd


func _enter()
    $ACTIVEWINDOW = WinGetHandle("")
    if $ACTIVEWINDOW <> $gui Then
        HotKeySet("{enter}")
        Send("{enter}")
        HotKeySet("{enter}", "_enter")
        Return
    Else
        $html = _IEBodyReadHTML($OIE)
        $intext = GUICtrlRead($input)
        $html &= "<br/><font color=0000FF >You</font>&nbsp;Say:<br/>&nbsp;&nbsp;"&$intext
        _IEBodyWriteHTML($OIE, $html)
        GUICtrlSetData($input, "")
        _AI($intext)
    EndIf


EndFunc

func _AI($intext)
    if $name=0 Then
        IniWrite($brain, "userinfo", "name", $intext)
        $html = _IEBodyReadHTML($OIE)
        $html &= '<br/><font color="#FF0000">ICI-1.0</font> Says:<br/>&nbsp;&nbsp;Hello '&$intext&' it is nice to meet you!'
        _IEBodyWriteHTML($OIE, $html)
        $name=1
    EndIf

    if StringRegExp($intext, "(?i)what(.*?)time(.*?)?") Then
        $html = _IEBodyReadHTML($OIE)
        $html &= '<br/><font color="#FF0000">ICI-1.0</font> Says:<br/>&nbsp;&nbsp;It Is Currently '&@HOUR&":"&@MIN&":"&@SEC&"."
        _IEBodyWriteHTML($OIE, $html)

    EndIf
EndFunc
Edited by IchBistTod

[center][/center][center]=][u][/u][/center][center][/center]

Share this post


Link to post
Share on other sites



Hi IchBistTod,

Damn good idea to implement something like this in AutoIT :D . A suggestion if I may for the program is to allow the user to configure their own Q&A. Example: User Types "Make Question" ICI Responds "Enter Keywords" UserTypes Keywords ICI Responds "Enter Answer" User Answers, Q&A saved in INI file.

Cya.


Frequent sufferer of ID10T Syndrome and CRAFT (Can't Remember A "BLEEP" Thing)

Share this post


Link to post
Share on other sites

 Ok Well I took two ideas and put them together to create a very basic framework. However after i took a break and got back to coding my enthusiasm had worn off a bit, as I do have depression... it does ruin A lot of my projects.....

Anyways, the idea is to combine an AI Bot that talks with an AI bot that can assist. For example, you can have a chat with it, then ask it to look up the word "Verlorn", or to translate "verlorn to english" or to solve "5*10", and other tasks such as backup the registry, run a file, download a program, you get the idea pretty much anything.

I hope to turn this  into a community project where everyone works on it and submits their edits and improvements to make something better. Perhaps then when i see it progression I will get my encouragement back, and in addition to that, with others helping this will get done much faster. 

Code(Right now it learns your name, and tells the time)

#include <GUIConstantsEx.au3>
#include <IE.au3>
HotKeySet("{enter}", "_enter")
#Region Global Constants
Global Const $ini = @ScriptDir&"\ici.ini" ;decalre the location of the settings file as a constant(meaning it cant be changed)
Global Const  $brain = @ScriptDir&"\ici.brain" ;decalre the location of the brain file as a constant(meaning it cant be changed)
Global Const $title = "ICI - Intelligent Computer Interface" ;decalre the title of the window as a constant(meaning it cant be changed)
#EndRegion

#Region Defaults
if not FileExists($ini) Then ;if the settings file doesnt exist
    IniWrite($ini, "window", "x", (@DesktopWidth/2)-(500/2)) ;default x pos on screen
    IniWrite($ini, "window", "y", (@DesktopHeight/2)-(550/2)) ;default y pos on screen
EndIf
#EndRegion

#Region Window Settings
Global $width = 500
Global $height = 550
Global $x = IniRead($ini, "window", "x", (@DesktopWidth/2)-(500/2)) ;Get the last used x pos of the window from the settings file
Global $y = IniRead($ini, "window", "y", (@DesktopHeight/2)-(550/2)) ;Get the last used y pos of the window from the settings file
#EndRegion

#Region Brain Settings

Global $user_name = IniRead($brain, "userinfo", "name", "?") ;Get the name of the user
#EndRegion

#Region Gui Creation
Global $gui = GUICreate($title, $width, $height, $x, $y, bitor(0x00020000, 0x00800000, 0x00010000, 0x00040000)) ;create the main window and make it resizable
Global $OIE = _IECreateEmbedded() ;create an IE object so we can use HTLM to format the text/images
Global $GUIACTIVEX = GUICtrlCreateObj($OIE, 10, 10, $width-20, ($height/1.2)-20) ;add object to window
GUICtrlSetResizing(-1, 102) ;set the control to resize docking all borders
_IENavigate($OIE, "about:blank")
Global $input = GUICtrlCreateEdit("", 10, ($height/1.2)+5, $width-20, $height-($height/1.2)-30)
GUICtrlSetResizing(-1,  $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) ;set the control to resize docking all borders
GUISetState(@SW_SHOW, $gui) ;show the gui
if $user_name = "?" then ;if the user's name is not known, ask for it
    $name = 0
_IEBodyWriteHTML($OIE, '<font color="#FF0000">ICI-1.0</font>&nbsp;Says:<br/>&nbsp;&nbsp;Hello, My name is ICI-1.0 and my Job is to assist you with every day computer tasks. What name should I address you by?')
Else ;else greet them
    $name = 1
_IEBodyWriteHTML($OIE, '<font color="#FF0000">ICI-1.0</font>&nbsp;Says:<br/>&nbsp;&nbsp;Welcome back '&$user_name&'.')

EndIf

#EndRegion


while 1
    $guimsg = GUIGetMsg($gui)
    Switch $guimsg
        case -3

            $positionsize = WinGetPos($gui)
            IniWrite($ini, "window", "x", $positionsize[0]) ;write x position of window to settings file on exit
            IniWrite($ini, "window", "y", $positionsize[1]) ;write y position of window to settings file on exit
            IniWrite($ini, "window", "width", $positionsize[2]) ;write width of window to settings file on exit
            IniWrite($ini, "window", "height", $positionsize[3]) ;write hight of window to settings file on exit


            Exit
    EndSwitch
    sleep(20)
WEnd


func _enter()
    $ACTIVEWINDOW = WinGetHandle("")
    if $ACTIVEWINDOW <> $gui Then
        HotKeySet("{enter}")
        Send("{enter}")
        HotKeySet("{enter}", "_enter")
        Return
    Else
        $html = _IEBodyReadHTML($OIE)
        $intext = GUICtrlRead($input)
        $html &= "<br/><font color=0000FF >You</font>&nbsp;Say:<br/>&nbsp;&nbsp;"&$intext
        _IEBodyWriteHTML($OIE, $html)
        GUICtrlSetData($input, "")
        _AI($intext)
    EndIf


EndFunc

func _AI($intext)
    if $name=0 Then
        IniWrite($brain, "userinfo", "name", $intext)
        $html = _IEBodyReadHTML($OIE)
        $html &= '<br/><font color="#FF0000">ICI-1.0</font> Says:<br/>&nbsp;&nbsp;Hello '&$intext&' it is nice to meet you!'
        _IEBodyWriteHTML($OIE, $html)
        $name=1
    EndIf

    if StringRegExp($intext, "(?i)what(.*?)time(.*?)?") Then
        $html = _IEBodyReadHTML($OIE)
        $html &= '<br/><font color="#FF0000">ICI-1.0</font> Says:<br/>&nbsp;&nbsp;It Is Currently '&@HOUR&":"&@MIN&":"&@SEC&"."
        _IEBodyWriteHTML($OIE, $html)

    EndIf
EndFunc

I suggest using an sqlite *.db file instead of the *.ini. Consider size and execution time as the file gets larger.

Share this post


Link to post
Share on other sites

check out this python script i found a while back. check the code out, wonder if something like that can be done in autoit.

check it out.. Questor Python...

reminded me of it when i saw your script so figured id throw it in here.


;Frank. 

Share this post


Link to post
Share on other sites

Nice.


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

if i could add, i made some additions/improvements.

i made it so it would be easier to add answers to questions.

i wrote comments, so you could probably get it from that.

EDIT: added a compute command. type "compute" and the math equation after and it spits it out.

EDIT2: Change color, made it so its easy to change those colors. Look at the $AIColor1..2

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <SendMessage.au3>

HotKeySet("{enter}", "_enter")

#Region Global Constants
Global Const $ini = @ScriptDir&"\ici.ini" ;decalre the location of the settings file as a constant(meaning it cant be changed)
Global Const $brain = @ScriptDir&"\ici.brain" ;decalre the location of the brain file as a constant(meaning it cant be changed)
Global Const $title = "ICI - Intelligent Computer Interface" ;decalre the title of the window as a constant(meaning it cant be changed)
#EndRegion

#Region Defaults
if not FileExists($ini) Then ;if the settings file doesnt exist
    IniWrite($ini, "window", "x", (@DesktopWidth/2)-(500/2)) ;default x pos on screen
    IniWrite($ini, "window", "y", (@DesktopHeight/2)-(550/2)) ;default y pos on screen
EndIf
#EndRegion

#Region Window Settings
Global $width = 500
Global $height = 550
Global $x = IniRead($ini, "window", "x", (@DesktopWidth/2)-(500/2)) ;Get the last used x pos of the window from the settings file
Global $y = IniRead($ini, "window", "y", (@DesktopHeight/2)-(550/2)) ;Get the last used y pos of the window from the settings file
Global $AIFont = "Courier New"
Global $AIColor1 = "#0E5CA7"
Global $AIColor2 = "#4883BB"
#EndRegion

#Region Brain Settings
Global $user_name = IniRead($brain, "userinfo", "name", "?") ;Get the name of the user
Global $hello[5] = ["Hello!", "Hi!", "Good Day!", "What's up?"]
#EndRegion

#Region Gui Creation
Global $gui = GUICreate($title, $width, $height, $x, $y, bitor(0x00020000, 0x00800000, 0x00010000, 0x00040000)) ;create the main window and make it resizable
Global $OIE = _IECreateEmbedded() ;create an IE object so we can use HTLM to format the text/images
Global $GUIACTIVEX = GUICtrlCreateObj($OIE, 0, 0, $width-0, ($height/1.2)-0) ;add object to window
        GUICtrlSetResizing(-1, 102) ;set the control to resize docking all borders

_IENavigate($OIE, "about:blank")
Global $input = GUICtrlCreateEdit("", 0, ($height/1.2)+0, $width-0, $height-($height/1.2)-20)
GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetFont(-1, 8.5, 400, 0, $AIFont)
GUICtrlSetResizing(-1,  $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) ;set the control to resize docking all borders
GUISetState(@SW_SHOW, $gui) ;show the gui

If $user_name = "?" Then ;if the user's name is not known, ask for it
    $name = 0

    _IEBodyWriteHTML($OIE, '<table border="0" width="100%"><tr><td bgcolor='&$AIColor1&'><font color="#FFFFFF" face="'&$AIFont&'" size="2">ICI-1.0</font></td></tr>' & _
        '<tr><td bgcolor='&$AIColor2&'><font color="#FFFFFF" face="'&$AIFont&'" size="2">Hello, My name is ICI-1.0 ' & _
        'and my Job is to assist you with every day computer tasks. What name should I address you by?' & _
        '</font></td></tr></table>')
Else ;else greet them
    $name = 1
    _IEBodyWriteHTML($OIE, '<table border="0" width="100%"><tr><td bgcolor='&$AIColor1&'><font color="#FFFFFF" face="'&$AIFont&'" size="2">ICI-1.0</font></td></tr>' & _
        '<tr><td bgcolor='&$AIColor2&'><font color="#FFFFFF" face="'&$AIFont&'" size="2">Welcome back '&$user_name& _
        '</font></td></tr></table>')
EndIf
#EndRegion
;

while 1
    $guimsg = GUIGetMsg($gui)
    Switch $guimsg
        case -3

            $positionsize = WinGetPos($gui)
            IniWrite($ini, "window", "x", $positionsize[0]) ;write x position of window to settings file on exit
            IniWrite($ini, "window", "y", $positionsize[1]) ;write y position of window to settings file on exit
            IniWrite($ini, "window", "width", $positionsize[2]) ;write width of window to settings file on exit
            IniWrite($ini, "window", "height", $positionsize[3]) ;write hight of window to settings file on exit


            Exit
    EndSwitch
    sleep(20)
WEnd
;
func _enter()
    $ACTIVEWINDOW = WinGetHandle("")
    if $ACTIVEWINDOW <> $gui Then
        HotKeySet("{enter}")
        Send("{enter}")
        HotKeySet("{enter}", "_enter")
        Return
    Else
        $html = _IEBodyReadHTML($OIE)
        $intext = GUICtrlRead($input)
        If $intext ="" Then Return 0
        $html &= '<table border="0" width="100%"><tr><td bgcolor='&$AIColor1&'><font color="#FFFFFF" face="'&$AIFont&'" size="2"><p align="right">'&$user_name&'</font></td></tr>' & _
        '<tr><td bgcolor='&$AIColor2&'><font color="#FFFFFF" face="'&$AIFont&'" size="2"><p align="right">' & $intext & _
        '</font></td></tr></table>'
        _IEBodyWriteHTML($OIE, $html)
        GUICtrlSetData($input, "")
        _AI($intext)
    EndIf
EndFunc
;
func _AI($intext)
    if $name=0 Then
        IniWrite($brain, "userinfo", "name", $intext)
        _SetHTML('Hello '&$intext&' it is nice to meet you!')
        $name=1
    EndIf
    
    if StringRegExp($intext, _SSR("compute")) Then;if time is asked
        $equa = StringReplace(StringReplace($intext, "compute", ""), " ", "")
        _SetHTML($equa & " = <font color='#0000ff'>" & Execute($equa) & "</font>")
        Return 1
    EndIf
    
    if StringRegExp($intext, _SSR("hello")) Then;if time is asked
        _SetHTML($hello[Random(1,4,1)])
        Return 1
    EndIf
    
    if StringRegExp($intext, _SSR("exit")) Then;if time is asked
        _SetHTML('Exiting...')
        Sleep(1000)
        Exit
    EndIf
    
    ;What section.
    if StringRegExp($intext, _SSR("what")) Then;if the sentence has 'what' in it, then...
        if StringRegExp($intext, _SSR("time")) Then;if time is asked
            _SetHTML('It is currently '&@HOUR&":"&@MIN&":"&@SEC&".")
        ElseIf StringRegExp($intext, _SSR("my name")) Then;if you ask for your name...
            _SetHTML('Your name is '&$user_name&".")
        ElseIf StringRegExp($intext, _SSR("your name")) Then;if you ask for it's name...
            _SetHTML('My name is '&$title&".")
            
        ;continue with what questions, with this pattern... 
        Else
            _SetHTML('Sorry, at this time I do not have an answer.')
        EndIf
        
        Return 1
    Else
        _SetHTML('Not sure what that means.')
        Return 1
    EndIf   
EndFunc
;
Func _SSR($string)
    ;for this funtion, $string is the string of words seperated by a space
    ;for the bot to find.
    ;instead of '(?i)what(.*?)time(.*?)' all you need is 'what time'
    ;
    ;this makes it a lot cleaner and easier to write.
    Local $ssr = "(?i)"
    $ss = StringSplit($string, " ")
    For $r = 1 To $ss[0]
        $ssr &= $ss[$r] & "(.*?)"
    Next
    Return $ssr
EndFunc
;
Func _SetHTML($source)
    $html = _IEBodyReadHTML($OIE)
    $html &= '<table border="0" width="100%"><tr><td bgcolor='&$AIColor1&'><font color="#FFFFFF" face="'&$AIFont&'" size="2">ICI-1.0</font></td></tr>' & _
    '<tr><td bgcolor='&$AIColor2&'><font color="#FFFFFF" face="'&$AIFont&'" size="2">' & $source & _
    '</font></td></tr></table>'
    _IEBodyWriteHTML($OIE, $html)
EndFunc
Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites

@Billthecreator: COOL.


;Frank. 

Share this post


Link to post
Share on other sites

I've been working on something almost exactly like this. I'm glad to see someone else working on this. However, I'm not quite sure I'm ready to release my version yet as it is messy at the moment.


My work in AutoIt (Not many yet):

Parse Large Text Files To 2D Array Quickly [With Chunk Size]

 

My artificial intelligence project coded entirely in AutoIt. Meet Alice Assistant: http://facebook.com/ProjectAliceAI

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0