Results 1 to 5 of 5

Thread: knowing what key is pressed when the app is starting

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Location
    France
    Posts
    1

    knowing what key is pressed when the app is starting

    I would like to start an app in visible mode or invisible mode depending on a key pressed on the keyboard when it starts.

    Does anybody know how to do ?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Hmmm. Intresting question. Off the top of my head, I'd say start your app wtih a Splash screen. Put some code in the Form KeyPress event, and show or don't show the start up form depending on what key was captured in this event.

    Hope this helps.

  3. #3
    Matthew Gates
    Guest
    Use the GetAsyncKeyState API function to detect key presses.


    VB Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" _
    2. (ByVal vKey As Long) As Integer
    3.  
    4. Private Sub Timer1_Timer()
    5.    If GetAsyncKeyState(vbKeyA) Then Msgbox "A key was pressed": Exit Sub
    6. End Sub

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    For Matthew Gates: Given renaud's question, where would you put your Timer? On the main app form? A startup form which loads, but does not show?

  5. #5
    Matthew Gates
    Guest
    Originally posted by Hack
    For Matthew Gates: Given renaud's question, where would you put your Timer? On the main app form? A startup form which loads, but does not show?

    If you wish, you can have the form hidden. You could also use a class or even a module, I assume, along with the SetTimer and KillTimer API functions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width