Solved

Using INKEY$ in Visual Basic?

Posted on 2004-03-20
6
1,026 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dialogbox API leak? 18 94
Hide vba in gp 7 94
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 51
how to know if my Checkbox is True in VB6.0? 9 55
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 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