Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

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

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
yinmu
Asked:
yinmu
1 Solution
 
Ryan ChongCommented:
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
 
Ryan ChongCommented:
oops, try this instead:

R = ShellExecute(0, "open", "http://ets.freetranslation.com/" & mypara, 0, 0, 1)
0
 
aelatikCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Richie_SimonettiCommented:
hearing...
0
 
EDDYKTCommented:
Did I read something before because of security reason, You can not set the textbox value from outside?

May be I'm wrong
0
 
Richie_SimonettiCommented:
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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now