Jump to content

Next Keypress [Solved]


Danyg
 Share

Recommended Posts

I'm looking for a function that gets the next keypress a user performs.


If it's a specific key ("t"), it has to perform something.

if it is anything else, it has to do something different.

 

You would think that this would be easy using the IsPressed() function, but it can only detect for specific keys - I need a way to be able to detect if any key whatsoever has been pressed.

 

Edited by Danyg
Link to comment
Share on other sites

The problem with that approach is the "do something else" part will run if nothing is pressed. I need to wait (sleep) until something is pressed and then evaluate what was prsesed.

 

If it was "t" then do something.

If it was anything else, do something else.

Link to comment
Share on other sites

  • Moderators

Danyg,

Welcome to the AutoIt forums.

Checking for "the next keypress a user performs" gets us perilously close to keylogger territory - and as you can see from this announcement we have strict rules on what is allowed to be discussed in this forum.

If you want to check for just a few keys, then _IsPressed or HotKeySet would be a sensible place to start looking in the Help file.

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

 

Link to comment
Share on other sites

1 minute ago, Melba23 said:

Danyg,

Welcome to the AutoIt forums.

Checking for "the next keypress a user performs" gets us perilously close to keylogger territory - and as you can see from this announcement we have strict rules on what is allowed to be discussed in this forum.

If you want to check for just a few keys, then _IsPressed or HotKeySet would be a sensible place to start looking in the Help file.

M23

 

Hello M23

I am not interested in logging keys - Hell, I'm not even interested in what key was pressed (unless it was the one I'm using).

If this is not okay to discuss on AutoIT Forums, then perhaps you can help me with my original problem.

 

I have a function that I want to run whenever the PAUSE button is pressed, followed by a "t". If another key is pressed than t, the function should just cancel.

HotKeySet("{PAUSE}", "Start")

While 1
Sleep(100)
WEnd

Func Start()
If _IsPressed(54) Then
;Do something
Else
;Do nothing
EndFunc

 

Link to comment
Share on other sites

  • Developers

The best alternative I can think of is to check for the "t" in the first x seconds after Pause was pressed. in case it isn't, you abandon the func.
Anything else will be a sort of keylogger since you need to monitor all keystrokes. This is possible too but not to be discussed here as indicated.

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

  • Moderators

@AutoBert in the future, how about offering suggestions without the constant RTFM vibe? Believe it or not, we're actually trying to welcome and encourage new folks to the forum ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

  • Recently Browsing   0 members

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