Gå til innhold

Anbefalte innlegg

Videoannonse
Annonse

Tja, vel, det er mulig. Lim dette inn i en form:

 


Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long

Private Const MOD_ALT = &H1
Private Const MOD_CONTROL = &H2
Private Const MOD_SHIFT = &H4
Private Const PM_REMOVE = &H1
Private Const WM_HOTKEY = &H312

Private Type POINTAPI
x As Long
y As Long
End Type

Private Type Msg
hWnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type

Private bCancel As Boolean

Private Sub ProcessMessages()

Dim Message As Msg
'loop until bCancel is set to True
Do While Not bCancel
   'wait for a message
   WaitMessage
   'check if it's a HOTKEY-message
   If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
       'minimize the form
       Me.Show
   End If
   'let the operating system process other events
   DoEvents
Loop

End Sub

Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim ret As Long
bCancel = False
'register the Ctrl-F hotkey
ret = RegisterHotKey(Me.hWnd, &HBFFF&, MOD_CONTROL, vbKeyTab)
'show some information
MsgBox "Press Ctrl-tab to show the form"
'process the Hotkey messages
ProcessMessages

End Sub

Private Sub Form_Unload(Cancel As Integer)

bCancel = True
'unregister hotkey
UnregisterHotKey Me.hWnd, &HBFFF&

End Sub

Lenke til kommentar

Det er mulig å få til dette på en enklere måte uten API calls.

 

En idé som bare spratt opp for meg, helt utrolig på denne tiden av døgnet :cool:

 

Dim CTRL_NEDE As Boolean

Private Sub Form_Load()
   Form1.KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyControl Then
       CTRL_NEDE = True
   ElseIf KeyCode = vbKeyTab And CTRL_NEDE Then
       Form2.Show vbModal
       CTRL_NEDE = False
   End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyControl Then
       CTRL_NEDE = False
   End If
End Sub

 

ASCII er tallkodene for hver bokstav/tast på tastaturet se mer her

http://www.asciitable.com/

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...