Solved

C# puts some word to search

Posted on 2010-11-28
4
398 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 500 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

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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