最近遇到了一个问题,自己做的一个程序项目要判断ppt和word的状态,简单的说就是如果现在处于ppt或者word的编辑状态(能往上敲字),一个控件就激活,否则此控件就不能用,因为要自动监测,我想应该用到timer,但不知道具体怎么实现,用什么函数?
哪位高人帮我一下,谢谢

解决方案 »

  1.   

    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongDim hW As Long    hW = FindWindow("OpusApp", vbNullString)
        If hW Then MsgBox "WinWord.exe is running"
        
        hW = FindWindow("PP11FrameClass", vbNullString)
        If hW Then MsgBox "POWERPNT.exe is running"
      

  2.   

    谢谢楼上这位朋友,你这段代码我有几个问题
    1声明了那个FindWindowEx 怎么没用到呀
    2 OpusApp和PP11FrameClass这两个参数你是怎么得到的?
      

  3.   

    FindWindow
    是FindWindowA的别名(Alias)
    The FindWindow function retrieves the handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows.FindWindowEx
    是FindWindowExA的别名(Alias)
    The FindWindowEx function retrieves the handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the given child window.
      

  4.   

    2 OpusApp和PP11FrameClass这两个参数你是怎么得到的?
    你用SPY+就可得到。
    Excel Class is "XLMAIN"
    Word Class is "OpusApp"
    Powerpoint Class is "PP11FrameClass"
    Access Class is "OMain"
    Outlook Class is "rctrl_renwnd32"
      

  5.   

    1声明了那个FindWindowEx 怎么没用到呀
    判断ppt和word是否已经启动,用FindWindow就足够了。
      

  6.   

    http://www.aippt.cn