Sign in to follow this  
Followers 0
DJKMan

How to send data over TCP to a site's form without IE and receive it.

2 posts in this topic

#1 ·  Posted (edited)

I do not want to use IECreate since it caused problems and it lagged the computer sometimes. It also doesn't hide immediately so it's not suitable for this project. I'm trying to send data to http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input (it's also located here: http://psp.wijou.com/ai.html ). I've been searching for a while about TCP connections and even PHP Post and it doesn't seem to work. I end up coming back to this method which is the only method that works. :/

Basically what I want it to do is when the user enters data in the input box and if it doesn't equal :Exit (or some other keywords such as :mail) it would send that input data to the site above using TCP and wait for a reply and then return the text that contains the reply from the server back to the input box (which will be a GUI that doesn't close once I figure it out.) I'm trying to make the program communicate to the server without the use of IE.

Here's the source code. It's unclean at the moment since I'm mainly trying to figure out how to get it to send and receive first. I do admit I'm a bit of a noob but I'm a fast learner and I'm enjoying AutoIt. ^_^

#include <IE.au3>
#Include <Constants.au3>
Global $Chat,$oIE
$sText = "What do you want to say?"
TrayTip("A.L.I.C.E.", "A.L.I.C.E. is waking up.", 4 , 1)
IECreate()
Func IECreate()
    $oIE = _IECreate("http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input")
    WinSetState ( "Windows Internet Explorer", "", @SW_MINIMIZE  )
    WinSetTrans("http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input","",0)
    Opt("WinTitleMatchMode", 2)
;WinSetState ( "http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input", "", @SW_HIDE );;doesn't work when enabled
    If IsObj($oIE) Then
        $oIE.visible = True
        SetError(0)
        Return $oIE
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc;==>_IECreate
While 1
    start()
WEnd

Func start()
While 1 
HotKeySet("{ESC}", "Terminate")
HotKeySet( "{F10}" , "Chat" )
WEnd
EndFunc




;;;; Begin program;;;;
start()

Func Chat()
     Do 
    Sleep(100)
    $say = inputbox("A.L.I.C.E. By DJKMan ~ http://psp.wijou.com", $sText, "", "",  400, 290, 603, 325)
    SendKeepActive("http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input")
    send($say)
    send("+{ENTER}")
    _IELoadWait($oIE)
;sleep(1000)
$sText = _IEBodyReadText($oIE)
Until $say == ":exit" 
start()
EndFunc



Func Terminate()
    winkill("http://www.pandorabots.com/pandora/talk?botid=f5d922d97e345aa1&skin=custom_input")
    TrayTip("A.L.I.C.E." , "Going to sleep. Goodbye." , 3,1)
    sleep(3000)
    Exit
EndFunc

EDIT: Edited to be smaller and only focuses on the problem.

Edited by DJKMan

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



Have you tried winhttp?

$oRet = _HTTPRequest('GET', 'http://www.website.com', '')

Func _HTTPRequest($oMethod, $oURL, $oData)
    Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    $oHTTP.Open($oMethod, $oURL, False)
    If $oMethod = "POST" Then $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    $oHTTP.Send($oData);error out requested
    Return $oHTTP.ResponseText
EndFunc

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