截图是最经常用的工具,QQ截图是我见过最好的截图工具,只是你必须打开QQ才可以使用,有时候没法上网,或者不想上QQ的时候,截图还是很麻烦。 Windows自带的那个截图工具和QQ的截图工具相差甚远。所以想找一个QQ离线时候的替代品。下了几个软件,觉得使用不够方便。最后找到了QQ截图工 具的提取版,可以实现QQ的截图功能,但是使用起来每次都带打开,而且不能使用快捷键。所以打算写个软件,重新整合一下。
要实现的功能
1:实现QQ的截图功能
2:时刻在后台运行,随时使用
3:不与QQ冲突
4:可以使用快捷键
5:开机自动启动
代码实现
1:实现QQ的截图功能,调用提取出来的程序
/// <summary>
/// 启动外部程序,通过事件监视其退出
/// </summary>
public void start_nokill()
{
// 启动外部程序
Process proc = Process.Start(appName);
IfExit = false
;
if (proc != null )
{
// 监视进程退出
proc.EnableRaisingEvents = true
;
// 指定退出事件方法
proc.Exited += new
EventHandler(proc_Exited);
}
}
/// <summary>
/// 启动外部程序退出事件
/// </summary>
void proc_Exited(object sender, EventArgs e)
{
IfExit = true
;
}
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas,"Courier New",courier,monospace; background-color: rgb(255, 255, 255); }.csharpcode pre { margin: 0em; }.csharpcode .rem { color: rgb(0, 128, 0); }.csharpcode .kwrd { color: rgb(0, 0, 255); }.csharpcode .str { color: rgb(0, 96, 128); }.csharpcode .op { color: rgb(0, 0, 192); }.csharpcode .preproc { color: rgb(204, 102, 51); }.csharpcode .asp { background-color: rgb(255, 255, 0); }.csharpcode .html { color: rgb(128, 0, 0); }.csharpcode .attr { color: rgb(255, 0, 0); }.csharpcode .alt { background-color: rgb(244, 244, 244); width: 100%; margin: 0em; }.csharpcode .lnum { color: rgb(96, 96, 96); }
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas,"Courier New",courier,monospace; background-color: rgb(255, 255, 255); }.csharpcode pre { margin: 0em; }.csharpcode .rem { color: rgb(0, 128, 0); }.csharpcode .kwrd { color: rgb(0, 0, 255); }.csharpcode .str { color: rgb(0, 96, 128); }.csharpcode .op { color: rgb(0, 0, 192); }.csharpcode .preproc { color: rgb(204, 102, 51); }.csharpcode .asp { background-color: rgb(255, 255, 0); }.csharpcode .html { color: rgb(128, 0, 0); }.csharpcode .attr { color: rgb(255, 0, 0); }.csharpcode .alt { background-color: rgb(244, 244, 244); width: 100%; margin: 0em; }.csharpcode .lnum { color: rgb(96, 96, 96); }
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas,"Courier New",courier,monospace; background-color: rgb(255, 255, 255); }.csharpcode pre { margin: 0em; }.csharpcode .rem { color: rgb(0, 128, 0); }.csharpcode .kwrd { color: rgb(0, 0, 255); }.csharpcode .str { color: rgb(0, 96, 128); }.csharpcode .op { color: rgb(0, 0, 192); }.csharpcode .preproc { color: rgb(204, 102, 51); }.csharpcode .asp { background-color: rgb(255, 255, 0); }.csharpcode .html { color: rgb(128, 0, 0); }.csharpcode .attr { color: rgb(255, 0, 0); }.csharpcode .alt { background-color: rgb(244, 244, 244); width: 100%; margin: 0em; }.csharpcode .lnum { color: rgb(96, 96, 96); }
3:不与QQ冲突,如果用户启动QQ停止使用
/// <summary>
/// 获取某进程是否存在
/// </summary>
/// <param name="PName">进程名</param>
/// <returns>是否存在</returns>
bool getPName(string PName)
{
Process[] processes = Process.GetProcesses();
foreach (Process p in processes)
{
if
(p.ProcessName == PName)
{
return true ;
}
}
return false ;
}
private void timer_Tick(object sender, EventArgs e)
{
if (getPName("QQ" ) && cbox_active.Checked)
{
cbox_active.Checked=false
;
}
else if (!getPName("QQ" ))
{
cbox_active.Checked = true
;
}
}
4:可以使用快捷键
这部分是这个软件最难得地方,使用的是全局钩子,代码我是参考网上找到的,比较复杂,代码较长,有兴趣的点击下载代码
5:开机自动启动
/// <summary>
/// 设置启动
/// </summary>
/// <returns></returns>
public bool setBoot()
{
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE/Microsoft/Windows
/CurrentVersion/Run"
);
try
{
run.SetValue("QQ截图"
, appPath);
if
(testBoot())
{
return true ;
}
else
{
return false ;
}
}
catch
(Exception)
{
return false ;
}
}
/// <summary>
/// 取消启动
/// </summary>
/// <returns></returns>
public bool cancelBoot()
{
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE/Microsoft/Wi ndows
/CurrentVersion/Run"
);
try
{
run.DeleteValue("QQ截图"
);
if
(!testBoot())
{
return true ;
}
else
{
return false ;
}
}
catch
(Exception)
{
return false ;
}
}
/// <summary>
/// 测试是否添加成功
/// </summary>
/// <returns></returns>
private bool testBoot()
{
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE/Microsoft/Windows
/CurrentVersion/Run"
);
string
[] subkeyNames;
subkeyNames = run.GetValueNames();
foreach (string keyName in subkeyNames)
{
if (keyName == "QQ截图" )
{
return true ;
}
}
return false ;
}
}
软件介绍
我简单说一下使用
1:智能启用 软件可以检测QQ,如果QQ运行,则是使软件处于未启用状态,如果退出QQ,软件会自动启用。
2:当然如果不适用智能启用,你也可以手动启用
4:可以设置开机自动启动
5:使用快捷键和QQ一样 ctrl+alt+A
总结:设置开机启动和智能启用,你任何时候只要按ctrl+alt+A 就可以自己使用截图了