Hallo Xulin!
Danke für deine Antwort! Dein vorgeschlagener Tipp hat leider nicht so gut funktioniert! Er zählt nämlich nicht die Anwendungen die in der Taskleiste zu sehen sind, sondern alle die visible sind. Hab dann diesen Tipp genommen: "Fenster, die in der Taskleiste zu sehen sind ". Aber trotzdem DANKE.
Falls es wenn interessiert, hier der Code (Modul):Option Explicit
' Benötigte API's
Private Declare Function EnumWindows Lib "user32" ( _
ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function GetParent Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare Function GetWindow Lib "user32" ( _
ByVal hWnd As Long, _
ByVal wCmd As Long) As Long
' Noch ein paar Konstanten
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Const GW_OWNER = 4
Private Const WS_EX_TOOLWINDOW = &H80&
Private Const WS_EX_APPWINDOW = &H40000
' Diese Funktion initialisiert das Ganze
Sub ew_go()
' Aufrufen, und ew_callback() übergeben.
' Der zweite Parameter ist egal, kann frei definiert werden
EnumWindows AddressOf ew_callback, 0
End Sub
' Diese Function nimmt die Callbacks entgegen.
' param ist der zweite Parameter von EnumWindows,
' handle stellt ein enumeriertes Fenster dar
Private Function ew_callback(ByVal handle As Long, ByVal param As Long) As Long
' Die Funktion ew_fenster() prüft das Fenster
ew_fenster handle
' TRUE zurückgeben, um Windows zu sagen: Alles OK
' und evtl. Fehler zu vermeiden ;)
ew_callback = True
End Function
' Diese Funktion prüft, ob das gefundene Fenster
' in der Taskleiste angezeigt wird
Private Sub ew_fenster(handle As Long)
Dim i1 As Long
Dim i2 As Long
Dim d1 As String
Dim d2 As String
' Fenster muss sichtbar sein UND darf kein Elternfenster haben
If IsWindowVisible(handle) And GetParent(handle) = 0 Then
' erweiterte Optionen abrufen
i1 = GetWindowLong(handle, GWL_EXSTYLE)
' nochmals Elternfenster prüfen:
i2 = GetWindow(handle, GW_OWNER)
' Prüfen, ob:
' - Kein ToolWindow und kein Childfenster oder
' - Anwendungsfenster und Childfenster
If ((i1 And WS_EX_TOOLWINDOW) = 0 And i2 = 0) Or _
((i1 And WS_EX_APPWINDOW) And (i2 <> 0)) Then
Form1.Label1(7).Caption = Form1.Label1(7).Caption + 1
End If
End If
End Sub Da ich "Form1.Label1(7).Caption" verwendet habe, ist der Code nicht schön. Aber ich weiß es im Moment nicht besser.
Leider geht das nicht:For i = 1 To i = 8
'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
Next Nur das geht: 'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
'push down tab
keybd_event VK_TAB, 0, 0, 0
'push up tab
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0 Was soll ich machen? Mit einer For-Schleife wäre es toll gewesen aber es funktioniert nicht. Nun ist mein Code wieder nicht variabel.
Gibt es etwas mit dem ich währende der Ausführung den Quellcode verändern kann? Wie oben zu sehen ist, einfach nur x mal kopieren...
Ich hoffe es kann mir da jemand weiterhelfen!
Liebe Grüße
anve |