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"
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.
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"
If hW Then MsgBox "WinWord.exe is running"
hW = FindWindow("PP11FrameClass", vbNullString)
If hW Then MsgBox "POWERPNT.exe is running"
1声明了那个FindWindowEx 怎么没用到呀
2 OpusApp和PP11FrameClass这两个参数你是怎么得到的?
是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.
你用SPY+就可得到。
Excel Class is "XLMAIN"
Word Class is "OpusApp"
Powerpoint Class is "PP11FrameClass"
Access Class is "OMain"
Outlook Class is "rctrl_renwnd32"
判断ppt和word是否已经启动,用FindWindow就足够了。