Newsgroup: it.comp.lang.visual-basic
Titolo: Tasto premuto+avvio

Vorrei sapere come posso far rilevare la pressione di un tasto durate
l'avvio di un file.
Quindi la sequenza è: tengo premuto il tasto Maiusc e avvio il file ==>> la
mia sub deve riconoscere la pressione del tasto.
Faccio presente che non voglio form da caricare!
Grazie
--------------------------------
Inviato via 
http://usenet.libero.it


.. forse la domanda è troppo difficile? perchè non mi risponde nessuno?


 l'avvio di un file.
Devi usare le api di windows....prova a guardare le funzioni 
getKeyboardState e getKeyState. Ti allego un esempio di utilizzo di 
getKeyboardState presa da 
allapi.net
. Credo che tu possa dattarla al tuo 
caso.
CIAO
Const VK_CAPITAL = &H14
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_USED = VK_SCROLL
Private Type KeyboardBytes
     kbByte(0 To 255) As Byte
End Type
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) 
As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As 
KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As 
KeyboardBytes) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim kbArray As KeyboardBytes, CapsLock As Boolean, kbOld As KeyboardBytes
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: 
http://www.allapi.net/
    'E-Mail: KPD...@Allapi.net
    'Get the current keyboardstate
    GetKeyboardState kbOld
    'Hide the form
    Me.Hide
    MsgBox "Keep your eyes on the little num-, shift-and scrolllock lights 
on the keyboard."
    TurnOff VK_CAPITAL
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 1000
    TurnOn VK_NUMLOCK
    Sleep 100
    TurnOn VK_CAPITAL
    Sleep 100
    TurnOn VK_SCROLL
    Sleep 300
    TurnOff VK_NUMLOCK
    Sleep 100
    TurnOff VK_CAPITAL
    Sleep 100
    TurnOff VK_SCROLL
    Sleep 500
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_CAPITAL
    Sleep 200
    TurnOff VK_CAPITAL
    Sleep 200
    TurnOn VK_CAPITAL
    Sleep 200
    TurnOff VK_CAPITAL
    Sleep 200
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_NUMLOCK
    TurnOn VK_SCROLL
    Sleep 200
    TurnOff VK_NUMLOCK
    TurnOff VK_SCROLL
    Sleep 200
    TurnOn VK_CAPITAL
    Sleep 400
    TurnOff VK_CAPITAL
    Sleep 200
    TurnOn VK_NUMLOCK
    Sleep 100
    TurnOn VK_CAPITAL
    Sleep 100
    TurnOn VK_SCROLL
    Sleep 300
    TurnOff VK_SCROLL
    Sleep 100
    TurnOff VK_CAPITAL
    Sleep 100
    TurnOff VK_NUMLOCK
    Sleep 1000
    Unload Me
End Sub
Private Sub TurnOn(vkKey As Long)
    'Get the keyboard state
    GetKeyboardState kbArray
    'Change a key
    kbArray.kbByte(vkKey) = 1
    'Set the keyboard state
    SetKeyboardState kbArray
End Sub
Private Sub TurnOff(vkKey As Long)
    'Get the keyboard state
    GetKeyboardState kbArray
    'change a key
    kbArray.kbByte(vkKey) = 0
    'set the keyboard state
    SetKeyboardState kbArray
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'restore the old keyboard state
    SetKeyboardState kbOld
End Sub