Avatar of Richard
Richard
Flag for United States of America asked on

VB6 key press at program start

Using VB6, I'm trying to detect if a couple of keys are pressed at the time the icon to start the program is clicked.  I need to detect if a particular key combination is pressed before any forms are displayed, so I can't use something like form.keypress (no form loaded yet).
Visual Basic Classic

Avatar of undefined
Last Comment
Richard

8/22/2022 - Mon
John Tsioumpris

This is somewhat a strange question....i guess that the application starts...performs some "work" and then it shows...
May something like this :http://www.vbforums.com/showthread.php?27616-Recoginition-of-keypress-thru-API(Window-API) could help but i am not sure
Richard

ASKER
Hi John,
Thanks for the quick reply.  I have seen programs which if started (clicking the icon) with a particular key held down (when the icon is clicked) sets a debug mode or changes the logging mode of the program.  In my case, what I want to do is to change the behavior of a routine which connects to a SQL server.  If the server is off (and proper key not pressed) a message is shown that the server is off and the program terminates.  If a key is pressed, and the server is off, the user is prompted to change to a different server.  I'm trying to make it as difficult as possible for a user to change to a different server.
John Tsioumpris

Interesting thinking....how about loading a small hidden form that watches for the key and then proceed...
I found a post about running a process in memory but its a bit of a hack : http://www.vbforums.com/showthread.php?728585-How-do-I-execute-a-program-from-memory
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Richard

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.