Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Internet Explorer VB6

Posted on 2006-05-02
8
Medium Priority
?
342 Views
Last Modified: 2008-03-04
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...
0
Comment
Question by:ogog
  • 4
  • 3
8 Comments
 
LVL 17

Expert Comment

by:Cem Türk
ID: 16591805
0
 
LVL 6

Expert Comment

by:junglerover77
ID: 16592112
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
 
LVL 1

Author Comment

by:ogog
ID: 16593590
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 6

Accepted Solution

by:
junglerover77 earned 520 total points
ID: 16595699
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
 
LVL 1

Author Comment

by:ogog
ID: 16621590
:( 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
 
LVL 6

Expert Comment

by:junglerover77
ID: 16621613
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
 
LVL 1

Author Comment

by:ogog
ID: 16621632
now i can't submit. I'm using:

IE.Document.Forms(0).submit

as i always do...

Sorry, last time i bother you!!!!
0
 
LVL 6

Expert Comment

by:junglerover77
ID: 16623078
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

Featured Post

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!

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
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…
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.

580 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