Jump to content

Reading key from keyboard


Just1f
 Share

Recommended Posts

Hello,

I am working on an administrative tool for an online game. In this game there is a dialog box that can be open using the ENTER key. Nothing can be edited in this box excepted the prompt

Dialog box picture:

/-----------\

|... . ... .. .|

| ..... . . . .| <- game messages

|_______|

|_______| <-- prompt

I want users to be able to answers my questions using the prompt in the dialog box. So I send a text on the prompt of the dialogbox (eg.: a question) and waits

for them to answer.

I want to filter each key press so users can type some letters ("yn", or ASCII only, etc.) but cannot press DEL, SPACE, moove the mouse, etc. I also need it to detect ENTER.

Is that possible to read keypresses despite BlockInput() or to read each key and/or mouse event in a loop and forward them to the application only once filtered ?

Edited by Just1f
Link to comment
Share on other sites

In The HelpFile :) Well..It Should Be At Least...Lemme Check

Check if key has been pressed

#Include <Misc.au3>

_IsPressed($sHexKey[, $vDLL = 'user32.dll'])

Parameters

$sHexKey Key to check for

$vDLL Handle to dll or default to user32.dll

Return Value

True: 1

False: 0

Remarks

If calling this function repeatidly, should open 'user32.dll' and pass in handle.

Make sure to close at end of script

Related

Example

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1

Sleep ( 250 )

If _IsPressed("23", $dll) Then

MsgBox(0,"_IsPressed", "End Key Pressed")

ExitLoop

EndIf

WEnd

DllClose($dll)

Link to comment
Share on other sites

In The HelpFile :) Well..It Should Be At Least...Lemme Check

Okay so _IsPressed() will tell me if a key has been pressed, but how will I block other keys entries? Do I have to set each key of the keyboard as hotkey ?? :)

Is there a way to customize BlockInput()'s range ?

Edited by Just1f
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...