?
Solved

C# puts some word to search

Posted on 2010-11-28
4
Medium Priority
?
403 Views
Last Modified: 2012-05-10
System.Diagnostics.Process.Start(@"E:\Program Files\Mozilla Firefox\firefox.exe", "www.msn.com www.yahoo.com www.hotmail.com");


Can i put some key word to search after fire fox open 3 search engin   such as put

"song naran" in the search box of tree website that just open
0
Comment
Question by:teera
[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
  • 3
4 Comments
 
LVL 13

Expert Comment

by:AngryBinary
ID: 34227332
Yes. You will want to look at the format of the search query strings for those sites. For instance, on www.msn.com, the URL to use would be:

"http://www.bing.com/search?q=song+naran"

For Yahoo, use:

"http://search.yahoo.com/search?p=song+naran"

Hotmail would also use the Bing search engine, so you wouldn't need to open another tab for that to begin with. All you have to do is URL encode the search terms (). The full code snippet would look something like this:






string searchString = "song naran"; //or some value retrieved from a form

System.Diagnostics.Process.Start(
    @"E:\Program Files\Mozilla Firefox\firefox.exe", 
    String.Format(
        "http://www.bing.com/search?q={0} http://search.yahoo.com/search?p={0}", 
        HttpUtiltity.UrlEncode(searchString)));

Open in new window

0
 
LVL 13

Expert Comment

by:AngryBinary
ID: 34227336
FYI, to use the HttpUtility class, you will need to add a reference to the System.Web namespace in your project.
0
 

Author Comment

by:teera
ID: 34227451
Error      1      A using namespace directive can only be applied to namespaces; 'System.String' is a type not a namespace      C:\Users\¿¿¿7\documents\visual studio 2010\Projects\firefox\firefox\Form1.cs      


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web ;
using System.String;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {


            string searchString = "song naran"; //or some value retrieved from a form

            System.Diagnostics.Process.Start(
                @"E:\Program Files\Mozilla Firefox\firefox.exe",
                String.Format(
                    "http://www.bing.com/search?q={0} http://search.yahoo.com/search?p={0}",
                    HttpUtiltity.UrlEncode(searchString)));


            
        }
    }
}

Open in new window

0
 
LVL 13

Accepted Solution

by:
AngryBinary earned 2000 total points
ID: 34227522
Well, the exception is pretty self explanatory. You can't issue a "using" directive on a class. Remove "using System.String;" from your code.
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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 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