Home > Net >  VB.NET compiled program, set up a copy and paste the shortcut keys, program can also be used in the
VB.NET compiled program, set up a copy and paste the shortcut keys, program can also be used in the

Time:03-31

Make up a program, I want to use VB.NET set 2 shortcuts, and small keyboard - is copy, small keyboard + is increased, the function of the original input - + no, at VB.NET can be realized in the programming interface,

Private Sub Form1_KeyDown (sender As Object, e As KeyEventArgs) Handles Me. KeyDown
If e.K eyCode=109 Then
.
End the If
End Sub

I want to ask is, when I this program in the background, how to implement the two shortcuts can still continue to be valid, it is in other application interface, you can use these two shortcuts? Seek advice, thank you, find a, but this is the combined shortcut CTRL + T, don't know how to achieve a single key shortcuts,


Public Const WM_HOTKEY=& amp; H312
Public Const MOD_ALT=& amp; H1
Public Const MOD_CONTROL=& amp; The H2
Public Const MOD_SHIFT=& amp; H4
Public Const GWL_WNDPROC=(4)
Public Declare Auto Function RegisterHotKey Lib "user32. DLL Alias" _
"RegisterHotKey" (ByVal HWND As IntPtr, ByVal id As an Integer, ByVal fsModifiers As an Integer, ByVal vitamin k As an Integer) As Boolean
Public Declare Auto Function UnRegisterHotKey Lib "user32. DLL Alias" _
"UnregisterHotKey" (ByVal HWND As IntPtr, ByVal id As an Integer) As Boolean

Private Sub Form1_Load (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles MyBase. Load
RegisterHotKey (Handle, 0, MOD_CONTROL, Asc (" T ")) 'registered the key combination Ctrl + T

End Sub

Protected Overrides Sub WndProc (ByRef m As Message)
If m.M sg=WM_HOTKEY Then
If the Visible Then
Hide ()
The Else
Show ()
End the If
End the If
MyBase. WndProc (m)
End Sub


Private Sub Form1_Closed (ByVal sender As Object, ByVal e the As System. EventArgs) Handles MyBase, Closed
UnRegisterHotKey (Handle, 0)
End Sub

Help you, thank you
  • Related