Jump to content

_IsPressed showing key press but no keys being pressed, why?


Recommended Posts

I have a USB and a PS2 keyboard hooked into my computer.
Windows 7 Pro x64
AutoIT 3.3.14.5

-- Code Removed due to Keylogger rules of Forum --

The code ran "_isPressed" in a loop and wrote to the console the key pressed.


Every so often _isPressed outputs multiple random stuck keys to console.  When I open a text editor however NO keys are being sent.

Why is this occurring and is it a concern?  

Edited by iAmNewbe
Typo in script
Link to comment
Share on other sites

For instance the code above will randomly display the equivalent of say for example the letters  "a, g, h, f, t, s, r"

I open a text editor and give it focus.  NOTHING is sent to the text window. Looking over at console write and the code for these letters are continually being sent to console until I manually press each keyboard key and then nothing is sent.  

I have tried one other keyboard I have a wireless one and disconnected the wired keyboards entirely.  Watching console write and randomly this still occurs.   Is it the code?   
If it were the keyboard actually sending these keys why do they not show up in a text editor?

 

Link to comment
Share on other sites

_isPressed gets the information which key was pressed.  Send or ControlSend can send keys to your application?!

Do you mean _isPressed shows keys were pressed without any action?

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Developers
1 hour ago, iAmNewbe said:

I run the following code which I got in part here on the forum somewhere, can't find the thread for credit to author.
 

#include <Misc.au3>

Whie 1
    For $i = 0 to 255
        If (_IsPressed(Hex($i))) Then
           ConsoleWrite("You pressed the: " & Hex($i) & " { " & $i & " } Key!" & @CRLF)
           Sleep(250)
        EndIf
WEnd

 

There is no way that code runs so why not post the real script instead?

... and please read this topic about keyloggers to ensure you stick within the boundaries of our forum rules:

 Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

On 7/22/2019 at 3:27 AM, Xenobiologist said:

_isPressed gets the information which key was pressed.  Send or ControlSend can send keys to your application?!

Do you mean _isPressed shows keys were pressed without any action?

Yes.  _isPressed is showing keys that are not physically pressed.  I have tried multiple keyboards and experience the same thing, this occurs intermittently.

Edited by iAmNewbe
Link to comment
Share on other sites

On 7/22/2019 at 4:39 AM, Jos said:

There is no way that code runs so why not post the real script instead?

... and please read this topic about keyloggers to ensure you stick within the boundaries of our forum rules:

 Jos

 

_isPressed is showing phantom key presses for me.  I am trying to find out why.  I have several keyboards, USB and PS2, they ALL show this same weird behavior,  I have tried on both Windows 7 and Windows 10.

I have had trouble with several applications acting funny and in some cases ending up in a hard reboot of the system. Left clicking items in Windows Explorer, Layers in graphic design software, photoshop like applications resulted in multiple selections.

I do not understand why _isPressed is showing phantom presses and none of them are actually getting sent.  I am confused on this.

I edited the OP to fix the typos, the script should run now.  I have an updated version using an array with name of keys instead of key codes but did not occur that this debugging falls into grey or black areas. Will not post that version unless you give me permission.

Questions: 
Why does _isPressed show phantom key presses? 

is this a bug in _isPressed?   

I have tried 3 different keyboards, wired and wireless. All result in same behavior. Is this stemming from outside the keyboards?

Edited by iAmNewbe
Link to comment
Share on other sites

  • Developers
4 minutes ago, iAmNewbe said:

Why does _isPressed show phantom key presses? 

is this a bug in _isPressed?   

Doubt that it is a bug as standard calls are used and as to "Why?" that is for you to find out...  maybe another program/script sending keypress messages to windows?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Just now, Jos said:

Doubt that it is a bug as standard calls are used and as to "Why?" that is for you to find out...  maybe another program/script sending keypress messages to windows?

Jos

When I physically press the keys shown via _isPressed the output stops for that key.   This occurs with ALL my keyboards on a random basis.  Does not seem to effect only a few applications but when it does.. I have to reboot the computer.     

Link to comment
Share on other sites

If you run the snippet Jos posted, what is your output?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

35 minutes ago, BrewManNH said:

If you run the snippet Jos posted, what is your output?

The snippit is quoted from my OP.  I fixed the typo's and For loop for the code to actually work, then removed the code in the OP due to reading Jos's link to the keylogger rules and replaced with description of what the code did.

To answer your question.

Output is either none OR random keys.

Loop 1 Output is ascii number of "q" key

Loop 2 Output is ascii number of "v" key

Loop 3 Output is ascii number of "5" key

etc...  Then it repeats.

Opening a text editor and putting focus on the editor NO keys are sent to the application unless I manually press a keyboard key. 

If I press the key written to console via _isPressed running in a loop, then that key no longer shows in the console.

This randomly occurs and once "cleared" different keys show up in console write.  There can be minutes to hours between occurrence.

What I am doing now is I wrote a script that runs this code but displays to a popup window the key displayed via _isPressed.  Every so often I open the popup and if keys are showing up I press those keys on the keyboard and they stop displaying.  If I manually press the key it shows up briefly then disappears and if when I do this a text editor is open and activated the key shows on the screen.  These _isPressed only displayed keys, this issue I am seeing, do NOT.

 

To help make this more clear.

_isPressed shows these random keys   "q, f, 4, h, z, t, e"  looping.

Noone has touched the keyboard.

I open NotePad++ and select the application.  NO keys are sent to NotePad++,  the keys above are vapor none of them are sent anywhere.

I manually press the "q" key.  q shows up in Notepad++ and now the _isPressed loop shows "f, 4, h, z, t, e"

I manually press the "4" key.  4 shows up in Notepad++ and now the _isPressed loop shows "f, h, z, t, e"

I continue until all these keys no longer appear in console.  

Minutes to hours later another random set of keys are looping via _isPressed running in a loop.  

 

 

 

 

Edited by iAmNewbe
Link to comment
Share on other sites

This is what it is doing right now

You pressed the: 00000029 { 41 } Key!
You pressed the: 0000002A { 42 } Key!
You pressed the: 0000002C { 44 } Key!
You pressed the: 0000002D { 45 } Key!
You pressed the: 0000002E { 46 } Key!
You pressed the: 0000002F { 47 } Key!
You pressed the: 00000030 { 48 } Key!
You pressed the: 00000034 { 52 } Key!
You pressed the: 00000036 { 54 } Key!
You pressed the: 00000039 { 57 } Key!
You pressed the: 0000003B { 59 } Key!

Then it loops back at "41" and continues again repeatedly.

I am NOT touching the keyboard.

Edited by iAmNewbe
Link to comment
Share on other sites

So, let me make sure I got this right:

1. You are running a script from SciTE that is doing a loop to check _IsPressed.

2. Every so often and at random it says a key is pressed when there is no key pressed. 

-----------

Jos - I don't know if you remember this but I remember when using send or control send every so often the wrong character would get sent. It drove me nuts. It would happen on multiple machines. I never did find a fix for it. I'm not saying his issue and mine are related yet the behavior of random characters from the keyboard are a common denominator for both problems. 

--------------------

Question - what happens if you increase the milliseconds a key has to be pressed in order for it to register? Worth a shot for I have nothing else. 

Link to comment
Share on other sites

Link to comment
Share on other sites

2 minutes ago, Nine said:

I tested it, for quite a long time, on 2 different machines (w7 & w10).  Nothing happens randomly.  Just seems to me that your PC and/or your KB is faulty...

I'm wondering if a separate piece of software is interfering. It would explain things for some will test and it shows nothing while others test and have issues.  

Link to comment
Share on other sites

8 minutes ago, Bert said:

I'm wondering if a separate piece of software is interfering. It would explain things for some will test and it shows nothing while others test and have issues. 

Could be but I find highly improbable that a legit software could send those random keys.  Unless the OS is corrupted or some virus type of software is hidden somewhere.  So I would tend to believe it is a hardware problem.

Link to comment
Share on other sites

21 minutes ago, Bert said:

So, let me make sure I got this right:

1. You are running a script from SciTE that is doing a loop to check _IsPressed.

2. Every so often and at random it says a key is pressed when there is no key pressed. 

Question - what happens if you increase the milliseconds a key has to be pressed in order for it to register? Worth a shot for I have nothing else. 

Yes.

The AutoIT / Scite script only checks for keypress and what key it is for testing.

This is not stemming from an AutoIT script, I just wrote / copied code to trace down what is going on in my applications and if it related to keyboard stuck keys.  
The keys tracked by _isPressed are not physically sent so is not stuck keys but somehow are being registered by _isPressed.  

Link to comment
Share on other sites

19 minutes ago, Nine said:

I tested it, for quite a long time, on 2 different machines (w7 & w10).  Nothing happens randomly.  Just seems to me that your PC and/or your KB is faulty...

I tested with 4 different keyboards including one wireless.  Tested on this same hardware with dual boot windows 7 and windows 10.  Same issue, all keyboards and both operating systems.

Link to comment
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
 Share

×
×
  • Create New...