Jump to content

Recommended Posts

Posted (edited)

I've been looking for a way to do this for some time now that wasn't too hard on the system, and while _IsPressed() worked OK, I was worried about the drag it could have on some users' CPUs. I haven't done extensive testing of this, but it seems to work pretty good. Hope this is helpful. :)

AnyKey()

<snip>

Cheers. :)

Edited by Melba23
Code removed
"Intelligence is the ability to adapt to change."                                      - Stephen Hawking                                        "...not the ability to exploit others."                                                  - OldCoder
Posted

how is

2 = Return associated keyboard codes

3 = Return associated keyboard/mouse button codes

not considered a keylogger...

I say this prematurely based off the description.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Posted

Unfortunately, this API function is totally unreliable due to the way messages are received and pulled from the input buffer.

Try Yashied's Hotkey UDF if _IsPressed() won't handle your needs.

Posted (edited)

how is

not considered a keylogger...

I say this prematurely based off the description.

I suppose if it was recording keys and not just testing for their switching it might be. Is there some kind of paranoia in these parts about keyloggers? A part of programing, in any language, is the ability to give a user the option to input information into one's program. Without this very fundamental acquisition of data, a very large hole is left in one's programing repertoire. Besides, what's the basic difference between what I have made and _IsPressed()?

Unfortunately, this API function is totally unreliable due to the way messages are received and pulled from the input buffer.

Try Yashied's Hotkey UDF if _IsPressed() won't handle your needs.

Thanks for the advice. I, thus far, have had no problems with this function. It seems to perform well at relatively low CPU consumption.

An application can call this function to retrieve the current status of all the virtual keys. The status changes as a thread removes keyboard messages from its message queue. The status does not change as keyboard messages are posted to the thread's message queue, nor does it change as keyboard messages are posted to or retrieved from message queues of other threads. (Exception: Threads that are connected through AttachThreadInput share the same keyboard state.)

Of course I've mostly been using it to detect if any key has been pressed on the keyboard or mouse, not to record keys and steal people's passwords. So, it may not be fully tested, and I concede the point. Thanks. :)

Edited by OldCoder
"Intelligence is the ability to adapt to change."                                      - Stephen Hawking                                        "...not the ability to exploit others."                                                  - OldCoder
Posted

sorry in retrospect that did appear more accusatory than the question sounded in my head. It certainly does not seem to log keys as they are pressed in any fashion that i can determine, but i also cant get option 0 to return anything but 1 (i was expecting mouse clicks to not do so).

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

  • 2 weeks later...
Posted (edited)

OldCoder,

I can't get this code to work properly. It always returns 0. With a debugging ConsoleWrite I've found that $t = 0 and that forces a return in the error check code, ie 2nd line of the Func AnyKey().

Is it supposed to wait for a key before returning? Sorry, I don't get it at all.

4Eyes

<snip>

Edited by Melba23
Code removed
Posted (edited)

OldCoder,

I can't get this code to work properly. It always returns 0. With a debugging ConsoleWrite I've found that $t = 0 and that forces a return in the error check code, ie 2nd line of the Func AnyKey().

Is it supposed to wait for a key before returning? Sorry, I don't get it at all.

4Eyes

<snip>

Yeah, my bad. I had forgotten to make allotments for no GUI present. Here's an updated code that should work in most, if not all, situations.

<snip>

Hope that helps. Cheers. :)

Edited by Melba23
Code removed
"Intelligence is the ability to adapt to change."                                      - Stephen Hawking                                        "...not the ability to exploit others."                                                  - OldCoder
  • 1 year later...
Posted

I played with this a bit; my compiler seems mad that the $current_win and $child_hWnd are "possibly used before declaration". Doesn't seem like a big deal, though...

Robert,

Keep in mind the last posting date was April 11, 2011 so there are bound to be version difference complications considering the age of the example(s).

  • Moderators
Posted

Hi,

This is a keylogger, pure and simple. Thread locked and all code removed. :naughty:

Please read the announcement about keyloggers and remind yourselves what is considered to be one. FireFox's now removed script qualified 100% - please think before posting such things in future. I do not want to come over all heavy, but I will if people keep posting scripts like this. Be warned. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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