programadorvb6 Posted August 23, 2013 at 09:16 AM Report #522459 Posted August 23, 2013 at 09:16 AM Olá bom dia. Tenho este código exemplo que me detecta, o pressionar da combinação entre duas teclas ALT+F10, mas gostaria de lhes adicionar mais a tecla: SHIFT ou seja ( SHIFT + ALT+F10 ). Como o posso fazer? Grato desde já pela vossa atenção. ProgramadorVB6 Imports System.Runtime.InteropServices Public Class Form1 Public Const MOD_ALT As Integer = &H1 'Alt key Public Const WM_HOTKEY As Integer = &H312 ' <DllImport("User32.dll")> _ Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer End Function <DllImport("User32.dll")> _ Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr, ByVal id As Integer) As Integer End Function Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_HOTKEY Then Dim id As IntPtr = m.WParam Select Case (id.ToString) Case "100" MessageBox.Show("Pressionou as teclas ALT+F9") Case "200" MessageBox.Show("Pressionou as teclas ALT+F10") End Select End If MyBase.WndProc(m) End Sub Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing UnregisterHotKey(Me.Handle, 100) UnregisterHotKey(Me.Handle, 200) End Sub Private Sub Form_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load RegisterHotKey(Me.Handle, 100, MOD_ALT, Keys.F9) RegisterHotKey(Me.Handle, 200, MOD_ALT, Keys.F10) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Me.Hide() End Sub End Class ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé.
programadorvb6 Posted August 24, 2013 at 10:54 AM Author Report #522558 Posted August 24, 2013 at 10:54 AM (edited) Arranjei esta solução, não sei se será a mais indicada .. Imports System.Runtime.InteropServices Public Class Form1 Public Const MOD_CONTROL As Integer = &H2 'Tecla: Control Public Const MOD_SHIFT As Integer = &H4 'Tecla: Shift Public Const MOD_ALT As Integer = &H1 'Tecla: Alt Public Const WM_HOTKEY As Integer = &H312 'Liga. <DllImport("User32.dll")> _ Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer End Function <DllImport("User32.dll")> _ Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr, ByVal id As Integer) As Integer End Function Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_HOTKEY Then Dim id As IntPtr = m.WParam Select Case (id.ToString) Case "100" MessageBox.Show("Pressionou as teclas ALT+F9") Case "200" MessageBox.Show("Pressionou as teclas ALT+F10") Case "300" ' MessageBox.Show("Pressionou as teclas CTRL+ALT+SHIFT+F10") Me.Show() End Select End If MyBase.WndProc(m) End Sub Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing UnregisterHotKey(Me.Handle, 100) UnregisterHotKey(Me.Handle, 200) UnregisterHotKey(Me.Handle, 300) End Sub Edited August 24, 2013 at 10:55 AM by programadorvb6 ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now