Internet Explorer VB6

hi everyone, i'm trying to auto send myself a file from internet explorer object from vB.

however, even so i can login in my account, i can't write the filename i wish to send.

i access the recipients email (mine) and it works, however, filename1 does not.


Here's my code:
      
          Set IE = CreateObject("InternetExplorer.Application")
            
            ...

            Do Until IE.readystate = 4
                  DoEvents
            Loop
   
            IE.document.All.Item("recipient").Value = "WORKS FINE"
            IE.document.All.Item("filename1").Value = "this one does not..."
            
            IE.document.Forms(0).submit
            

            ---------------------------------
            
            
      And here is html code of that fraction of page:
            
            <td align="right">To:&nbsp;</td>
                  <td><input type="text" name="recipient" style="width:140px;" /><input type="button" onClick="newWindow('previous.php','window2');" value="previous" /></td>
            </tr>
            <tr>
                  <td align="right">File:&nbsp;</td>
                  <td><input type="file" name="filename1" /></td>
            </tr>
            <tr>
                  <td align="right" valign=top>Note:&nbsp;</td>
                  <td><textarea rows=2 cols=15 name=note></textarea></td>
            </tr>
            <tr>
                  <td>&nbsp;</td>
                  <td><input type="submit" value="send" />

            
            
            it even submits, just that the file goes on blank...
            i think it hase something to do with it being of type file...
LVL 1
ogogAsked:
Who is Participating?
 
junglerover77Commented:
After I tried to achieve this goal for 2 hours, I have to say that I was wrong. The API "PostMessage" can post a key stroke to any Input Controls in Normal windows applications, but not Internet Explorer. That's because the Input Controls, which exist in a HTML page in an IE window, don't have hWNDs.

The windows structure of Internet Explorer is:
IEFrame -> Shell DocObject View -> Internet Explorer_server
But because the window "Internet Explorer_server" is just an OLE container, it has no child windows. So......

You can use the following code to post a key to a textbox in another form without activate it:
Call PostMessage(Form2.Text1.hWnd, WM_CHAR, Asc("a"), 1)
But it's not compatible for IE.

So, the only way to achieve your goal might be activate the IE window, focus on the control, then Sendkeys ...... I know that's not good, but I do have no better idea. Sorry for that.

Jungle
0
 
Cem TürkSenior Software EngineerCommented:
0
 
junglerover77Commented:
To assign a value to a File Control in an HTML page is extremely forbidden for security purpose.

Just imagine, if you are allowed to do that, web sites would also be able to get any files on your computer silently by the same way.

The only way should be, get the hwnd of the IE Window, then post some key stroke messages to it.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
ogogAuthor Commented:
junglerover77 can you show me how, i can increase points.

well, security causes trouble when you can't do the secure things you want to do YOURSELF! It's like buying a door that's so secure, that when you forget your keys inside, a truck has to break a wall.

This would ease my job... i've sent keystrokes before but to entire windows to automake corel draw actions. can you show me how to send them speciffically to ie windoW?
0
 
ogogAuthor Commented:
:( well... if that is the way, junglerover sure deserves the points scince he've showed so much effort.

Anyway could you just tell me how to login on this site: "http://jumk.de/notepad/"

 IE.document.All.Item("user").Value = "my name" -> this one is not working...
 IE.document.All.Item("log").Value = "my pass"

I'm tired of trying this... Can't get it to work...
0
 
junglerover77Commented:
If you wanna access a control via the "All" collection, you must set its "id" property, not "name".

So, you can only do it this way:
    IE.Document.GetElementsByName("user")(0).Value = "my name"
    IE.Document.GetElementsByName("log")(0).Value = "my pass"
0
 
ogogAuthor Commented:
now i can't submit. I'm using:

IE.Document.Forms(0).submit

as i always do...

Sorry, last time i bother you!!!!
0
 
junglerover77Commented:
I just tested your code and it works well, and I don't know why it doesn't work on your computer.

Alternatively, you can try the following statement:
IE.Document.GetElementsByTagName("input")(2).Click
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.