Sign in to follow this  
Followers 0
OldCoder

AnyKey()

12 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



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.


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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  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

Share this post


Link to post
Share on other sites

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


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

Share this post


Link to post
Share on other sites

#6 ·  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

Share this post


Link to post
Share on other sites

#7 ·  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

Share this post


Link to post
Share on other sites

Thanks.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

<snip>

Edited by Melba23
Code removed

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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


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
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0