26. februar 2005 - 03:25Der er
8 kommentarer og 1 løsning
Program logger
Hejsa.. Er ved at lege lidt med et keylogger program, så ville høre om dette var muligt: kan man fx hvis jeg sidder og bruger computeren og åbner et nyt vindue, fx Denne Computer eller et program som Microsoft Word, "logge" at de programmer bliver åbnet. Så at programmet selv finder titlen på programmet??
Private Const GW_CHILD = 5 Private Const GW_HWNDFIRST As Long = 0 Private Const GW_HWNDNEXT As Long = 2
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long
Public Function GetTitle(ByVal lhWnd As Long) As String Dim strSpace As String * 255 GetTitle = Trim$(Left$(strSpace, GetWindowText(lhWnd, strSpace, 255))) End Function
Public Function IsVisible(ByVal lhWnd As Long) As Boolean IsVisible = IIf(IsWindowVisible(lhWnd), True, False) End Function
Private Sub Form_Load() Dim hWndNext As Long Dim strTitle As String
hWndNext = GetWindow(GetDesktopWindow(), GW_CHILD) Do While hWndNext
If IsVisible(hWndNext) Then
strTitle = GetTitle(hWndNext) If Len(strTitle) Then ' Tilføj til en ListBox List1.AddItem strTitle End If
End If
hWndNext = GetWindow(hWndNext, GW_HWNDNEXT) Loop End Sub '----------------------------------- Form1 -----------------------------------
hej... næsten, dog ik helt.. det er ikke alle åbne vinduer jeg vil have, den skal kun checke hvis der bliver åbnet et nyt et, fx hvis loggeren er startet og jeg så åbner internet explorer, så skriver den det ned og venter på jeg åbner en ny ting. håber du forstår :)
men det skal laves så den i en tekstfil skriver fx [Denne Computer], og ikke ALLE tingene som er åbent, kun den ene ting.. og det er det som er problemet, så et lille hint ville være en go ting :)
arg :S kan godtnok ik få det til.. her er min kode i timeren, og ved godt det er skidt!:
Private Sub Timer1_Timer() Dim hWndNext As Long Dim strTitle As String Dim i As Integer Dim Count As Integer Dim onlist As String Count = List1.ListCount onlist = ""
hWndNext = GetWindow(GetDesktopWindow(), GW_CHILD) Do While hWndNext
If IsVisible(hWndNext) Then
strTitle = GetTitle(hWndNext)
For i = 0 To Count If strTitle = List1.List(i) Then onlist = "yes" End If Next
If onlist <> "yes" Then 'If Len(strTitle) Then ' Tilføj til en ListBox List1.AddItem strTitle 'End If End If
End If
hWndNext = GetWindow(hWndNext, GW_HWNDNEXT) Loop End Sub
Private Const GW_CHILD = 5 Private Const GW_HWNDNEXT As Long = 2
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long
Public Function GetTitle(ByVal lhWnd As Long) As String Dim strSpace As String * 255 GetTitle = Trim$(Left$(strSpace, GetWindowText(lhWnd, strSpace, 255))) End Function
Public Function IsVisible(ByVal lhWnd As Long) As Boolean IsVisible = IIf(IsWindowVisible(lhWnd), True, False) End Function
Private Sub Form_Load() Timer1.Interval = 1000 ' 1000 = 1 Sekundt End Sub
Private Sub Timer1_Timer() Dim hWndNext As Long Dim strTitle As String Dim strhWnd As String Static stahWnd As String
hWndNext = GetWindow(GetDesktopWindow(), GW_CHILD) Do While hWndNext
If IsVisible(hWndNext) Then
strTitle = GetTitle(hWndNext) If Len(strTitle) Then
If InStr(1, stahWnd, "#" & hWndNext & "#") = 0 Then ' Tilføj til en ListBox List1.AddItem strTitle End If strhWnd = (strhWnd & "#" & hWndNext & "#")
End If
End If
hWndNext = GetWindow(hWndNext, GW_HWNDNEXT) Loop stahWnd = strhWnd End Sub '----------------------------------- Form1 -----------------------------------
mange tak :) det virker nu perfekt :) endnu engang har du virkelig fortjent dine point :)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.