我想做一个小程序,让它最小化后仍然能监视系统当前窗口的标题,如果发现指定的窗口标题,它给予相应的提示!
请问各位高手,我这个想法能实现吗?
有意 请附上部分源码,感谢!
请问各位高手,我这个想法能实现吗?
有意 请附上部分源码,感谢!
解决方案 »
- C#socke通讯异常问题
- help!!!!!!!!!!!!!!!!!!!!!!!!!
- 如何判断一个字符串是另一数组的子序列
- 菜鸟求教:杀QQ游戏进程问题
- 没有得到提交值怎么回事(有完全代码)
- 通过对象建立了一个数据源,在通过DATAGRID绑定数据源,当对象属性改变的时候如何能够让DATAGRID同步更新.
- 如何删除XML中指定的节点!
- c/s连接 acess数据库的问题
- Main()中的string args是什么意思
- 请问如何用IE控件的Navigate方法POST form?
- 寻找用于 Windows Mobile 5.0 Pocket PC SDK 的插件
- C++里面的CRC代码转为C#应该是?? 下面有C++CRC校验源码 (急需)
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;static class Program
{
[STAThread]
static void Main()
{
ContextMenu menu = new ContextMenu(new MenuItem[]{
new MenuItem("Exit", delegate(object sender, EventArgs e){ Application.Exit();})
}); notifyIcon1.ContextMenu = menu;
notifyIcon1.Icon = System.Drawing.SystemIcons.Question;
notifyIcon1.Text = "My application showing the active window...";
notifyIcon1.Visible = true; Timer timer = new Timer();
timer.Interval = 200;
timer.Tick += OnTimerTick;
timer.Start(); Application.Run();
timer.Dispose();
} static void OnTimerTick(object sender, EventArgs e )
{
char[] buf = new char[64];
IntPtr hWnd = GetForegroundWindow();
if (hWnd != IntPtr.Zero)
{
int length = GetWindowTextW(hWnd, buf, buf.Length);
if (length > 0)
{
notifyIcon1.Text = new string(buf, 0, length);
}
}
} static NotifyIcon notifyIcon1 = new NotifyIcon();
[DllImport("User32.dll", CharSet=CharSet.Unicode)]
extern static int GetWindowTextW(IntPtr hWnd, char[] str, int nMaxCount); [DllImport("User32.dll")]
extern static IntPtr GetForegroundWindow();
}