Sign in to follow this  
Followers 0
Harmonful

Help with _IsPressed

10 posts in this topic

#1 ·  Posted (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 by Ryona

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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. :)

M23

P.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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

THx!

it works!

:(

Share this post


Link to post
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
Sign in to follow this  
Followers 0