PjWebApps:将常用网址最顶端显示并一键打开

【网通】点击这里下载PjWebApps源代码     【电信、网通】点击这里下载PjWebApps源代码

【网通】点击这里下载PjWebApps演示程序 【电信、网通】点击这里下载PjWebApps演示程序

【下载说明】
1、单击上面这个地址,打开下载页面。
2、点普通下载--等待30秒--点“下载”按钮--保存

控制台程序,调用Windows的API实现了移动控制台窗口、调整控制台窗口的大小和将控制台窗口置顶(置于所有窗口最前端)等。


源代码:

/*
 * Created by SharpDevelop.
 * User: PJ
 * Date: 2012-9-25
 * Time: 10:23
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.IO;
using System.Collections.Generic;
using PjConsoleUtilsLib;
using System.Threading;
using System.Diagnostics;

using System.Drawing;
using System.Windows.Forms;

namespace PjWebApps
{
	class Program
	{
		static string windowTitle = "PjWebApps";
		static int windowWidth = 10;
		static int windowHeight = 25;
		
		static Dictionary<string,string> webApps = new Dictionary<string,string>();
		
		static void InputThread(){
			bool isExit = false;
			while(!isExit){
				ConsoleKeyInfo key = Console.ReadKey(true);
				switch(key.KeyChar){
					case 'B':
					case 'G':
					case 'L':
						Process.Start(FindWebAppsByKey(key));
						break;
					default:
//						isExit = true;
						break;
				}
			}
		}
		
		static string FindWebAppsByKey(ConsoleKeyInfo key){
			foreach(KeyValuePair<string, string> k in webApps){
				if(k.Key.ToLower()[0].ToString() == key.KeyChar.ToString().ToLower())
					return k.Value;
			}
			return string.Empty;
		}
		
		static void ReadWebAppsText(string fileName){
			using(StreamReader sr = new StreamReader(fileName)){
				while(!sr.EndOfStream){
					string line = sr.ReadLine();
					string[] parts = line.Split(',');
					webApps.Add(parts[0],parts[1]);
				}
			}
		}
		
		static void PrintWebApps(){
			foreach(KeyValuePair<string,string> k in webApps){
				PjConsoleUtils.PrintMenuItem(k.Key);
				Console.WriteLine();
			}
		}
		
		public static void Main(string[] args){
			Console.Title = windowTitle;
			Console.WindowWidth = windowWidth;
			Console.WindowHeight = windowHeight;
			Console.CursorVisible = false;
			
			// move the console window to the right
			int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
			int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
			IntPtr consoleHandle = PjConsoleUtils.FindWindowByCaption(IntPtr.Zero,windowTitle);
			if(consoleHandle != IntPtr.Zero){
				int x,y,width,height;
				if(PjConsoleUtils.GetWindowRect(consoleHandle,out x,out y,out width,out height)){
					PjConsoleUtils.SetWindowTopMost(consoleHandle);
					PjConsoleUtils.MoveWindow(consoleHandle,screenWidth-width,
					           (screenHeight-height)/2,width,height,true);
				}
			}
			
			webApps.Clear();
			ReadWebAppsText(Environment.CurrentDirectory + "\\WebApps.txt");
			PrintWebApps();
			
			Thread inputThread = new Thread(new ThreadStart(InputThread));
			inputThread.Start();
		}
	}
}



【更多阅读】

  1. [原]使用Excel的VBA来读取和修改bmp位图像素数据
  2. [原]Baidu:C#利用百度来搜索网页、图片、视频等等
  3. [原]《The C Programming Language》电子书下载
  4. [原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
  5. [原]PjConvertImageFormat:用FreeImage.NET写的一个35种图像格式转换程序
  6. [译]使用OpenXML更新Word文档中的表格
  7. [译]C#控制计算机的并口LPT
  8. [原]QQHelper:QQ大家来找茬 辅助工具 外挂
  9. [译]在C# .NET2.0实现单实例应用程序
  10. [译]用C#检测你的打印机是否连接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值