Sign in to follow this  
Followers 0
Just1f

Reading key from keyboard

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



_IsPressed()

Hotkeyset("{ENTER}", "") which will take over enter...and not let it do anything :)

Share this post


Link to post
Share on other sites

_IsPressed()

Hotkeyset("{ENTER}", "") which will take over enter...and not let it do anything :)

Thank you for that quick answer.

Do you know where _IsPressed() and affiliated are documented ?

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0