?
Solved

c#- SendKeys.Send("{tab}") to Internet explorer

Posted on 2011-03-16
5
Medium Priority
?
2,796 Views
Last Modified: 2012-05-11
HI,

I have created a simple winform application to launch the browser on a click of the button. The code is as follows:

        private void button1_Click(object sender, EventArgs e)
        {
           Process IEProc = new Process();
           IEProc.StartInfo.FileName = "iexplore.exe";
           IEProc.StartInfo.Arguments = "http://google.com";
           IEProc.Start();
           //IEProc.StandardInput.Write("Hello World");
           
           SendKeys.Send("{tab}");
        }

The purpose of putting the line "SendKeys.Send("{tab}");" is to navigate to the new field on google.com. However, the tabbing is happening on winform application. Can someone please let me know how the tab can be used on google.com.

Appreciate your help.


0
Comment
Question by:deoyagya
[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
5 Comments
 
LVL 10

Expert Comment

by:John Claes
ID: 35145921
When opening the iexplore you should just wait for a few moments before sending the TAB.
Why?

the iexplore is still opening when the TAB is send, and your winform is still in front. ;-)

waiting :
using System.Threading;


Thread.Sleep(10 * 1000); // 10 Seconds delay


regards

poor beggar
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35145928
try this

      IEProc.Start();
                  IEProc.WaitForInputIdle();

                  SendKeys.Send("{tab}");
0
 
LVL 4

Accepted Solution

by:
parnasso earned 1200 total points
ID: 35146016
In order to implement the SendKeys function, you need to finde the internet explorer window that receives the user input and send an WM_KEY... message to it. I'm not sure if your approach is going to give you more problems than you think.

I would suggest to add a reference to the internet explorer interface through COM (automation). If you are not familiar with automation, take a look at this project:

Internet explorer automation
0
 
LVL 12

Assisted Solution

by:FarWest
FarWest earned 800 total points
ID: 35146512
you can get the process window handle, and the setfoucs to that window, before sending keys
check this, http://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainwindowhandle.aspx


and pay attention to this note in the page
"If you have just started a process and want to use its main window handle, consider using the WaitForInputIdle method to allow the process to finish starting, ensuring that the main window handle has been created. Otherwise, an exception will be thrown."


good luck
0
 

Author Closing Comment

by:deoyagya
ID: 35275429
Thanks for the assistance.
0

Featured Post

Independent Software Vendors: 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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

801 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