我做的一个项目要用到后台监视功能.
即做一个后台运行的程序,监视浏览器的标题,
如果浏览器打开的页面标题与预先设定的标题相同,
就记录下来他的键盘操作记录,并根据记录给出提示.好像要用到api,没有高过,在网上搜了下也没有找到合适的代码(写的很乱.没有看懂)请高手给出完整的代码实例,谢谢.

解决方案 »

  1.   

    using System;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using SHDocVw;
    //引用SHDocVw.dll
    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                ShellWindowsClass shellWindows = new ShellWindowsClass();
                foreach (InternetExplorer ie in shellWindows)
                {
                    string filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower();                if (filename.Equals("iexplore"))
                    {
                        Console.WriteLine(ie.LocationName);
                    }
                }
            }    }
    }
      

  2.   

    可以使用Proccess对象。好像是在System命名空间下面的
      

  3.   

    是title吗?
    如果是的话,net中已经有header这个对象了亚
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;namespace bindingtest
    {
        public partial class Form1 : Form
        {
            Timer timer = new Timer();
            public Form1()
            {
                InitializeComponent();            timer.Interval = 1000;            timer.Tick += new EventHandler(timer_Tick);            timer.Start();
            }        void timer_Tick(object sender, EventArgs e)
            {
                string wintitle = "预设的标题";
                MonitorWindow(wintitle);
            }        void MonitorWindow(string titile)
            {
                Process[] procs = Process.GetProcesses("iexplore");            foreach (Process ele in procs)
                {
                    if (ele.MainWindowTitle.Equals(titile))
                    {
                        MessageBox.Show(titile + " find!");
                    }
                }
            }
        }
    }
      

  5.   

    回2楼:
    你说得代码我在2005测试没有通过,错误行:using SHDocVw;
    错误提示如下:
    错误 1 找不到类型或命名空间名称“SHDocVw”(是否缺少 using 指令或程序集引用?) D:\我的文档\Visual Studio 2005\Projects\TEST01\TEST01\Form2.cs 9 7 TEST01回6楼:
    你得代码我在2005下也没有通过,错误行:Process[] procs = Process.GetProcesses("IEXPLORE");
    错误提示:
    无法连接到远程计算机。
      

  6.   

    Process[] procs = Process.GetProcesses("iexplore"); 改成 
    Process[] procs = Process.GetProcesses("iexplore",Environment.MachineName);
      

  7.   

    用 API  枚举所有当前WINDOWS的窗体
    然后,得到进程数,判断进程名,得到当前进程名的窗体名 -->  判断即可