Solved

Using INKEY$ in Visual Basic?

Posted on 2004-03-20
6
1,009 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

13 Experts available now in Live!

Get 1:1 Help Now