Solved

Using INKEY$ in Visual Basic?

Posted on 2004-03-20
6
1,032 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 64
How can my static class become undefined?? 8 62
Where did System.Data.Objects go? 2 40
Formula problem with Excel attachment 6 39
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

856 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