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
334 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
hearing...
0
 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

772 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

15 Experts available now in Live!

Get 1:1 Help Now