ezzetabi Posted October 30, 2004 Share Posted October 30, 2004 (edited) ...something like hotkeyset but with less limitations! And it should not 'steal' the key from other apps.This Func is, of course, based on the Larry idea of GetAsyncKeyState, so I thank him.In the #cs #ce section there is a list of some of 255 values that $hexKey can have.You can safely remove it if not needed.List toke from VirtualKeyCodes.aspexpandcollapse popup;In this little example pressing n will pop up a message ;pressing Esc will leave. While 1 If _IsPressed('1b') = 1 Then Exit;1b is ESC If _IsPressed('4e') = 1 Then MsgBox(0, '', 'Wow');4e is the N Sleep(10) Wend Exit Func _IsPressed($hexKey) ; $hexKey must be the value of one of the keys. ; _IsPressed will return 0 if the key is not pressed, 1 if it is. ; $hexKey should entered as a string, don't forget the quotes! ; (yeah, layer. This is for you) Local $aR, $bO $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then $bO = 1 Else $bO = 0 EndIf Return $bO EndFunc ;==>_IsPressed #cs 01 Left mouse button 02 Right mouse button 04 Middle mouse button (three-button mouse) 05 Windows 2000/XP: X1 mouse button 06 Windows 2000/XP: X2 mouse button 08 BACKSPACE key 09 TAB key 0C CLEAR key 0D ENTER key 10 SHIFT key 11 CTRL key 12 ALT key 13 PAUSE key 14 CAPS LOCK key 1B ESC key 20 SPACEBAR 21 PAGE UP key 22 PAGE DOWN key 23 END key 24 HOME key 25 LEFT ARROW key 26 UP ARROW key 27 RIGHT ARROW key 28 DOWN ARROW key 29 SELECT key 2A PRINT key 2B EXECUTE key 2C PRINT SCREEN key 2D INS key 2E DEL key 30 0 key 31 1 key 32 2 key 33 3 key 34 4 key 35 5 key 36 6 key 37 7 key 38 8 key 39 9 key 41 A key 42 B key 43 C key 44 D key 45 E key 46 F key 47 G key 48 H key 49 I key 4A J key 4B K key 4C L key 4D M key 4E N key 4F O key 50 P key 51 Q key 52 R key 53 S key 54 T key 55 U key 56 V key 57 W key 58 X key 59 Y key 5A Z key 5B Left Windows key 5C Right Windows key 60 Numeric keypad 0 key 61 Numeric keypad 1 key 62 Numeric keypad 2 key 63 Numeric keypad 3 key 64 Numeric keypad 4 key 65 Numeric keypad 5 key 66 Numeric keypad 6 key 67 Numeric keypad 7 key 68 Numeric keypad 8 key 69 Numeric keypad 9 key 6A Multiply key 6B Add key 6C Separator key 6D Subtract key 6E Decimal key 6F Divide key 70 F1 key 71 F2 key 72 F3 key 73 F4 key 74 F5 key 75 F6 key 76 F7 key 77 F8 key 78 F9 key 79 F10 key 7A F11 key 7B F12 key 7C-7F F13 key - F16 key 80H-87H F17 key - F24 key 90 NUM LOCK key 91 SCROLL LOCK key A0 Left SHIFT key A1 Right SHIFT key A2 Left CONTROL key A3 Right CONTROL key A4 Left MENU key A5 Right MENU key #ceEnjoy. Edited June 13, 2005 by ezzetabi Link to comment Share on other sites More sharing options...
gosu Posted October 30, 2004 Share Posted October 30, 2004 wonderful! thanks! i finally made a keylogger [quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
ezzetabi Posted October 30, 2004 Author Share Posted October 30, 2004 I am always happy to help. Link to comment Share on other sites More sharing options...
friends Posted October 31, 2004 Share Posted October 31, 2004 wow... that is great ! May be I can use it in future... I just loved it ! Link to comment Share on other sites More sharing options...
layer Posted November 10, 2004 Share Posted November 10, 2004 How the heck did you make a keylogger with this? FootbaG Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 10, 2004 Share Posted November 10, 2004 You can hotkey the keys to write themselves to an ini file for starters. The most primitive keylogger ever!!! (Usually you can't do this because AutoIt won't let you assign hotkeys to a normal key like a-z.) Link to comment Share on other sites More sharing options...
gosu Posted November 10, 2004 Share Posted November 10, 2004 How the heck did you make a keylogger with this?<{POST_SNAPBACK}>it´s very easy.$file = FileOpen("keylog.txt", 1) If $file = -1 Then Exit EndIf While 1 ;for the a If _IsPressed(41) Then _LogKeyPress("a") 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) FileWriteLine($file, "[ " &@MDAY & ". " &@MON & ". " &@YEAR & " " &@HOUR & ":" &@MIN & ":" &@SEC & " ] " & "Pressed Button: " & $what2log) EndFunc FileClose($file)Just a pretty much work, but it´s working perfectly. [quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
Klaatu Posted November 10, 2004 Share Posted November 10, 2004 (edited) Could something like this function be used to write the equivalent of AutoScriptWriter in AutoIt itself? Edited November 10, 2004 by Klaatu My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
layer Posted November 10, 2004 Share Posted November 10, 2004 How come 4e or some of the other "4x" statements don't work, while the rest of them do? FootbaG Link to comment Share on other sites More sharing options...
killaz219 Posted November 13, 2004 Share Posted November 13, 2004 This is awsome! ive been looking for one of these for a while. Thanks ezzetabi! Link to comment Share on other sites More sharing options...
ezzetabi Posted November 13, 2004 Author Share Posted November 13, 2004 Updated with Larry's advice. Link to comment Share on other sites More sharing options...
konan Posted November 15, 2004 Share Posted November 15, 2004 AutoScriptWriter use another dll file (ASWHook.dll) Link to comment Share on other sites More sharing options...
Klaatu Posted November 18, 2004 Share Posted November 18, 2004 (edited) Would something like this be feasable? Func Pressed() Local $KEYS, $I, $RESULT[255], $RI $KEYS = StringSplit("01,02,04,05,06,08,09,0C,_ 0D,10,11,12,13,14,1B,20,21,22,23,24,25,26,27,28,_ 29,2A,2B,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,5B,5C,60,61,62,63,_ 64,65,66,67,68,69,6A,6B,6C,6D,6E,6F,70,71,72,73,_ 74,75,76,77,78,79,7A,7B,7C,7D,7E,7F,80,81,82,83,_ 84,85,86,87,90,91,A0,A1,A2,A3,A4,A5", ",") $RI = 1 For $I = 1 To $KEYS[0] If _IsPressed ($KEYS[$I]) Then $RESULT[$RI] = $KEYS[$I] $RI = $RI + 1 EndIf Next $RESULT[0] = $RI - 1 ReDim $RESULT[$RI] Return $RESULT EndFunc ;==>Pressed Edited December 9, 2004 by Klaatu My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
this-is-me Posted November 18, 2004 Share Posted November 18, 2004 Klaatu Barada Nikto... (The day the earth stood still) Just wondering, are you submitting this because it allows a person to find out if multiple keys are pressed? Who else would I be? Link to comment Share on other sites More sharing options...
Klaatu Posted November 19, 2004 Share Posted November 19, 2004 Kind of. The function should return an array of all the keys currently pressed, but without a type of callback facility I could see where it would be difficult if not impossible to write an AutoScriptWriter type utility in pure AutoIt. I'm just throwing out some ideas to try to see what would actually work in this type of program, becuase I want to be able to write (or at least modify) such a program. I am comfortable (for the most part) writing AutoIt code; I do not see myself being able to use C or C++ to do it. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
ezzetabi Posted November 19, 2004 Author Share Posted November 19, 2004 (edited) I prefere, it is stupid using a so large array since Redim exists. (BTW, even if all values where ON, only 255 keys could be pressed) Also StringSplit can split using a single char, so you have to remove the blanks. Edit: it seems that Tidy have a bug. It moves the words inside string if it meets a comma. I change the separing char to a pipe. expandcollapse popupToolTip('Press all keys you want...') Sleep(3000) $a = _Pressed() $msg = '' For $c = 1 To $a[0] $msg = $msg & $a[$c] & @LF Next MsgBox(4096, 'You pressed: ', $msg) Func _Pressed() Local $Keys, $i, $Result[1], $ri $Keys = StringSplit("01|02|04|05|06|08|09|0C|"&_ "0D|10|11|12|13|14|1B|20|21|22|23|24|25|26|27|28|"&_ "29|2A|2B|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|5B|5C|60|61|62|63|"&_ "64|65|66|67|68|69|6A|6B|6C|6D|6E|6F|70|71|72|73|"&_ "74|75|76|77|78|79|7A|7B|7C|7D|7E|7F|80|81|82|83|"&_ "84|85|86|87|90|91|A0|A1|A2|A3|A4|A5","|") For $i = 1 To $Keys[0] If _IsPressed($Keys[$i]) Then _Enlarge($Result) $Result[$Result[0]] = $Keys[$i] Sleep(1) EndIf Next Return $Result EndFunc ;==>_Pressed Func _Enlarge(ByRef $Array) $Array[0] = UBound($Array) ReDim $Array[UBound($Array) + 1] EndFunc ;==>_Enlarge Edited November 19, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
Klaatu Posted November 19, 2004 Share Posted November 19, 2004 I am hurt, calling my way "stupid". While 1000 might be unecessarily large, you also have to look at execution time. Which is faster: rediming an array to add each element, or rediming at the very end to make it the right size? I don't know the answer to that, and I suspect neither do you. With something that captures key presses execution time is very critical, which is why this whole subdiscussion is more academic than practical, as a utility written in AutoIt would most likely be prone to missing key presses than one written in C or something where you can actually have a callback facility, hooking right into the keyboard driver (or whatever it is they hook into). Anyway, both ways work. One uses slightly more memory, and (I suspect) one is slightly slower, especially as the number of keys pressed at once increases. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
ezzetabi Posted November 19, 2004 Author Share Posted November 19, 2004 Never said you are stupid. Not even thought. Link to comment Share on other sites More sharing options...
ioliver Posted December 2, 2004 Share Posted December 2, 2004 ezzetabi, Thanks for _IsPressed. I'm trying to use it in a script right now. Thanks again, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
ezzetabi Posted December 2, 2004 Author Share Posted December 2, 2004 You are welcome. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now