Solved

Using INKEY$ in Visual Basic?

Posted on 2004-03-20
6
1,015 Views
Last Modified: 2013-11-25
Is there any way to emulate INKEY$ in Visual Basic? I'm pretty sure there is some API in Windows that will let me. I can't use the form keypress events, because I'm emulating the DOS console as well (with the console API).
0
Comment
Question by:zadijan
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:fozylet
ID: 10642916
Public Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer

http://msdn.microsoft.com/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputFunctions/GetAsyncKeyState.asp
0
 

Author Comment

by:zadijan
ID: 10643211
Yes... but doesn't that only react to a specific key?
0
 

Author Comment

by:zadijan
ID: 10643220
Because what I'm looking for is a way to simulate a C-style getch() or getche().
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Accepted Solution

by:
fozylet earned 65 total points
ID: 10643317
oh... i thought you're looking to capture the key pressed. sorry!

with asynckeystate you can loop thru all the keys to see if any of those is pressed (that is what keyloggers do, and is pretty fast)
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 60 total points
ID: 10643901
You could use the GetKeyboardState() API  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputFunctions/GetKeyboardState.asp in combination with fozylet's
 GetAsyncKeyState() API to determine if a key has been pressed.  You would have to poll however.

Also, take a look at this article http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q177/9/92.asp&NoWebContent=1
as it may be of help to you as well.  But be sure to read those notes at the very bottom though.

Idle_Mind
0
 

Author Comment

by:zadijan
ID: 10644783
Ah... thank you very much for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA to copy paste columns form one file to other 20 85
Windows 10 start screen issues 9 51
VBA filters 2 50
SLMGR Switches Are Not Working On KMS Host 3 63
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now