自定义搜索程序

  时常要开着几个网页,有的是英文翻译的,有的是官方api的。网页如果关了要再用又要重新开,不关又很乱。于是写了个搜索框,程序很简单。我觉得挺好玩的。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;


namespace UnityScriptAPIform
{

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



        private void Form1_Load(object sender, EventArgs e)
        {

            this.notifyIcon1.Visible = true;//在通知区显示Form的Icon

            this.ShowInTaskbar = true;//使Form不在任务栏上显示

            this.TopMost = true;
            FormBorderStyle = FormBorderStyle.None;
            this.Location = new Point(1080, 0);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            
            if (e.KeyCode == Keys.Enter)
            {
                string url = "https://docs.unity3d.com/ScriptReference/30_search.html?q="+ textBox1.Text.ToString();
                Process.Start("D:/QQBrowser/QQBrowser.exe", url);
                //create a new form
                
                textBox1.Clear();

            }
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(13) || e.KeyChar == Convert.ToChar(27))
            {
                e.Handled = true;
            }
        }

        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode == Keys.Enter)
            {
                string url = "http://fanyi.baidu.com/?aldtype=16047#en/zh/" + textBox2.Text.ToString();
                Process.Start("D:/QQBrowser/QQBrowser.exe", url);
                textBox2.Clear();
            }
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(13) || e.KeyChar == Convert.ToChar(27))
            {
                e.Handled = true;
            }
        }

        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            if(e.Button == MouseButtons.Right)
            {
                Exit.Show();
            }

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

  

  再向注册表添加个开机自启动,就是一个很完整的小程序了(●'◡'●)

转载于:https://www.cnblogs.com/-Yrqm/p/8084700.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值