2017-11-06 9 views

답변

0

Desktop Objects를 사용해 보았습니다. 희망하는 창 제목을 찾으려고합니다. 그 때문에, 여기에 방법

'부정적 사례의 경우

Msgbox IsProcessRunning("HP Unified",True) 
'Positive Case 
Msgbox IsProcessRunning("HPE Unified",True) 
Public Function IsProcessRunning(ByVal Title,ByVal Contains) 
    Dim blnIsRunning : blnIsRunning = False 
    Set objDesc = Description.Create 
    objDesc("micClass").Value = "Window" 
    Set objCollection = Desktop.ChildObjects(objDesc) 
    intWindowsCount = objCollection.Count - 1 
    For intCount = 0 To intWindowsCount 
     On Error Resume Next 
     If IsObject(objCollection(intCount)) Then 
      strWindowTitle = objCollection(intCount).GetROProperty("title") 
      On Error GoTo 0 
      If strWindowTitle <> "" Then 
       If Contains And Instr(strWindowTitle,Title) > 0 Or Not Contains And Trim(Title) = Trim(strWindowTitle) Then 
        blnIsRunning = True 
        Exit For 
       End If 
      End If    
     End If 
    Next 
    IsProcessRunning = blnIsRunning 
End Function