就像msn messenger,几分钟不动键盘鼠标就自动转入忙碌状态。
或者系统几分钟不动键盘鼠标就自动转入屏保状态。
谢谢!!!

解决方案 »

  1.   

    呵呵,用键盘和鼠标HOOK吧,设立一个TICK标志,当有键盘和鼠标事件触发时,就将这个TICK清零,并立即以秒为TICK单位递增,当这个TICK达到你所说的一定时间,就RUN你所说的一段代码.
    这个是肯定可以实现的.
      

  2.   

    每次当有鼠标键盘操作后kill原来的计时器重新set一个,设定好时间就可以了。
    可以判断消息类型,是鼠标键盘的,就kill.
      

  3.   

    this is a  way to monitor the keyboard input. 
    BOOL CApp::MonitorKeyboard()
        {
     if ( m_hKbrdThread )
         {
      // close thread hancle wich will terminate the thread 
      // (because I set m_hKbrdThread to NULL)
      // TerminateThread( m_hKbrdThread ); // terminate thread function is not
    supported
      CloseHandle( m_hKbrdThread );
      m_hKbrdThread = NULL;
      m_dwKbrdThreadID = NULL;
         }
     // create and start keyboard monitoring thread
     m_hKbrdThread = CreateThread( NULL, 0, CApp::KeyboardMonitorThread,
    (LPVOID)this, CREATE_SUSPENDED, &m_dwKbrdThreadID );
     if ( m_hKbrdThread == NULL )
      return FALSE;
     // change the thread priority
     SetThreadPriority( m_hKbrdThread, THREAD_PRIORITY_BELOW_NORMAL );
     ResumeThread( m_hKbrdThread );
     return TRUE;
        }....................DWORD CALLBACK CApp::KeyboardMonitorThread( LPVOID lData )
        {
     CApp * pApp = (CApp *)lData;
     int key_code = 0x41;
     // save the thread handle when this function is called 
     HTHREAD hThread = pApp->m_hKbrdThread;
     while( true )
         {
      if ( (GetAsyncKeyState( key_code ) & 0x8000) && (GetAsyncKeyState(
    VK_MENU ) & 0x8000) )
       pApp->OnHotKeyDown();
      Sleep( 100 );
      // this will kill the thread
    if ( pApp->m_hKbrdThread != hThread )
       break;
         }
     // kill the thread. 
     ExitThread(0);
     return 0;
        }
    //and i think mouse hook and keyboard hook can implement this too.
      

  4.   

    看不懂。
    若输入焦点在别的进程的窗口,你的线程能知道么?
    不用钩子,除非对所有窗口AttachThreadInput
      

  5.   

    this only monitor current process ,if you want to monitor all process,i think you should use hook or driver.
      

  6.   

    Win2000 下有个函数不知有没有用。BOOL GetLastInputInfo(
      PLASTINPUTINFO plii   // last input event
    );
      

  7.   

    哦……用一个全局钩子,效率怎么样啊? In355Hz大哥的这个方法不错,可以写一个服务,每隔几秒钟查询一次,比较一下时间,我的程序对时间要求并不精确,差几秒也没问题。各位还有什么更好的方法没有啊?分不够可以另开贴,请大家不吝赐教!!
      

  8.   

    查到了一篇有关文档:
    http://www.vckbase.com/vckbase/vckbase6/vc/nonctrls/system_30/0630001.htm