vba通過findwindow穫取窗口句柄後併判斷是否爲活動窗口

2017-09-17 08:00:00
zstmtony
原創
2909

vba通過findwindow穫取窗口句柄後併判斷是否爲活動窗口


'定義Findwindow windows API 函數
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long  '定義GetForegroundWindows API 穫取最前麵窗體 Private Declare Function GetForegroundWindow Lib "user32" () As Long
 '可以通過查看前景窗口是否爲指定窗口判斷
 hwd1 = FindWindow("#32770", "QQ用戶登録")
  
   '穫得指定窗口句柄 hwd2 = GetForegroundWindow

'穫得前景窗口句柄 If hwd1 = hwd2 Then MsgBox "指定窗口爲活動狀態!"
'判斷是否相衕
分享