Solved

copy text from hello.txt to a text-box in an URL and auto click on a button on the URL

Posted on 2003-12-01
6
335 Views
Last Modified: 2010-05-01
Dear sir and mdm,

I am currently doing a school prj involved visual basic 6.0 which I get stuck in midway and I had tried for the past few wks searching for books and website for ideas or solution. Hope u all can help me.

I have this hello.txt file in which there is some English sentences. I want to copy these sentence to an URL www.freetranslation.com where there is a textbox on the URL for people to key in English text and click on the translation button in the URL.

I have managed to open the website using

Private Sub text_translation_Click()

Dim R As Long

R = ShellExecute(0, "open", "www.freetranslation.com", 0, 0, 1)

End Sub

Problem
(1) I could not do a copy and paste function from hello.txt to the textbox in the URL

(2) I could not perform auto click function on the translation button in the URL after text is entered.

I have only visual basic 6.0 and visual C++ but the build-on is on visual basic platform and no java

Thanks a lot…

0
Comment
Question by:yinmu
6 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9856191
You can try open the targeted post page with the parameters required.

Example:

mytext = "Hello World"
mypara = "?language=English/Spanish&srctext=" & mytext & "&sequence=core&mode=html&template=results_en-us.htm"

then

Dim R As Long

R = ShellExecute(0, "open", "www.freetranslation.com" & mypara, 0, 0, 1)
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9856201
oops, try this instead:

R = ShellExecute(0, "open", "http://ets.freetranslation.com/" & mypara, 0, 0, 1)
0
 
LVL 14

Accepted Solution

by:
aelatik earned 125 total points
ID: 9856695
You can do this by browsing to the website > filling info and clicking buttons :


Private Sub Form_Load()

'Open the file containing the sentences and store it in a variable called MySentences
    Dim MySentences As String
    Dim MyLine As Variant
        MySentences = ""
    Open "c:\yourtextfile.txt" For Input As #1
        While Not EOF(1)
            Line Input #1, MyLine
                MySentences = MySentences & MyLine & vbCrLf
        Wend
    Close #1

'Create an internet explorer session
    Dim IE As Object
    Dim DOC, ITEM As Variant
    Set IE = CreateObject("internetexplorer.application")
'navigate to the website
        IE.navigate "http://www.freetranslation.com"
'Show the browser or hide it by settings it to false
        IE.Visible = True
    While IE.busy: DoEvents: Wend
'Wait till the page loads
        Set DOC = IE.Document
            Do Until DOC.readyState = "complete": DoEvents: Loop
'Wait till the document is complete
            For Each ITEM In DOC.All.tags("textarea")
'srctext = Name of the textarea in HTML
                If ITEM.Name = "srctext" Then ITEM.Value = MySentences
            Next
            For Each ITEM In DOC.All.tags("input")
'Humantranslation = Name of the button in HTML
                If ITEM.Name = "HumanTranslation" Then ITEM.Click
            Next
    Set IE = Nothing
End Sub
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9857558
hearing...
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9857737
Did I read something before because of security reason, You can not set the textbox value from outside?

May be I'm wrong
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9857918
Optionally, you could see this, it is an autologin to Hotmail but the approach is exactly the same:
http://www.angelfire.com/realm/vb-shared/IEDOM_Tip06.htm
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now