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
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 52

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 52

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

738 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