Harmonful Posted April 8, 2010 Share Posted April 8, 2010 (edited) well when i use If _IsPressed(BE)Then FileWrite("Incomingoffers.txt",".") EndIf When I press one time:'.' i get this on my txt file ................... =S and i just want ONE '.' thx for ur time Edited April 8, 2010 by Ryona Link to comment Share on other sites More sharing options...
FinalVersion Posted April 8, 2010 Share Posted April 8, 2010 Well isn't this suspicious, looks like you're on your way to a Key Logger. But you have a fatal flaw. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
JohnOne Posted April 8, 2010 Share Posted April 8, 2010 Well isn't this suspicious, looks like you're on your way to a Key Logger. But you have a fatal flaw.Thats a huge assumption for such a small piece of code.I dont know much about that function but Im going to guess its something to do with your keyboards refresh rate (if thats how you phrase it).Personally I would just use HotKeySet() to trigger your function. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FinalVersion Posted April 8, 2010 Share Posted April 8, 2010 Thats a huge assumption for such a small piece of code.I dont know much about that function but Im going to guess its something to do with your keyboards refresh rate (if thats how you phrase it).Personally I would just use HotKeySet() to trigger your function.Not really if you think about it. I know that _IsPressed is in a while loop, and writing to a text file, little to convenient. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
JohnOne Posted April 8, 2010 Share Posted April 8, 2010 Well I think you are just jumping to conclusions, you even spotted an imaginary While loop. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 8, 2010 Moderators Share Posted April 8, 2010 JohnOne,No prizes for you today - it has nothing to do with the keyboard repeat rate, and there has to be a loop involved! FinalVersion,If Ryona is writing a keylogger using _IsPressed then it will be horribly inefficient and his/her keyboard will wear out before he/she finishes the coding. Ryona,The reason you are getting multiple "............." is because the _IsPressed is continually fired while the key is down. The loop in which you have your _IsPressed (and there has to be one or you would not get this problem) is running so fast that it fires several times before you release the key - even if you think you did so immediately.Just add a check to make sure the key is released before continuing:If _IsPressed("BE", $dll)Then FileWrite("Incomingoffers.txt",".") While _IsPressed("BE", $dll)Then Sleep(10) ; important to prevent 100% CPU usage in this tight little loop WEnd EndIfA couple of other points:- You should put the "BE" in quotes to ensure AutoIt treats it as a literal string, It works here because both characters are letters, but if they were both numeric you could run into problems.- As you are running _IsPressed in a loop, you should open the dll before entering to loop and close it afterwards. Running without the handle as you are means you force AutoIt to open and close the dll each time you call the function. It will work, but you are wasting time and CPU.The code above incorporates those changes. I hope that is all clear. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FinalVersion Posted April 8, 2010 Share Posted April 8, 2010 If you run what is provided, the script exits immediately. And the only way that I know of to monitor key strokes is with a loop. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
Harmonful Posted April 8, 2010 Author Share Posted April 8, 2010 JohnOne, No prizes for you today - it has nothing to do with the keyboard repeat rate, and there has to be a loop involved! FinalVersion, If Ryona is writing a keylogger using _IsPressed then it will be horribly inefficient and his/her keyboard will wear out before he/she finishes the coding. Ryona, The reason you are getting multiple "............." is because the _IsPressed is continually fired while the key is down. The loop in which you have your _IsPressed (and there has to be one or you would not get this problem) is running so fast that it fires several times before you release the key - even if you think you did so immediately. Just add a check to make sure the key is released before continuing: If _IsPressed("BE", $dll)Then FileWrite("Incomingoffers.txt",".") While _IsPressed("BE", $dll)Then Sleep(10) ; important to prevent 100% CPU usage in this tight little loop WEnd EndIf A couple of other points: - You should put the "BE" in quotes to ensure AutoIt treats it as a literal string, It works here because both characters are letters, but if they were both numeric you could run into problems. - As you are running _IsPressed in a loop, you should open the dll before entering to loop and close it afterwards. Running without the handle as you are means you force AutoIt to open and close the dll each time you call the function. It will work, but you are wasting time and CPU. The code above incorporates those changes. I hope that is all clear. M23 I got This error C:\Documents and Settings\Max\Mis documentos\Autoit\d.au3(10,31) : ERROR: syntax error While _IsPressed("BE", $dll)Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Max\Mis documentos\Autoit\d.au3 - 1 error(s), 0 warning(s) Any idea? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 8, 2010 Moderators Share Posted April 8, 2010 Ryona,My fault, there should not be a Then at the end of the While line. I blame it on Windows copy-paste facility myself. M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Harmonful Posted April 9, 2010 Author Share Posted April 9, 2010 THx! it works! 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