Click here to Skip to main content
15,993,921 members
Home / Discussions / C#
   

C#

 
GeneralRe: Mouse Button > keystroke Pin
Kentamanos11-Feb-04 11:30
Kentamanos11-Feb-04 11:30 
GeneralRe: Mouse Button > keystroke Pin
Spanky311-Feb-04 11:44
Spanky311-Feb-04 11:44 
GeneralRe: Mouse Button > keystroke Pin
Kentamanos11-Feb-04 11:55
Kentamanos11-Feb-04 11:55 
GeneralRe: Mouse Button > keystroke Pin
Spanky311-Feb-04 11:54
Spanky311-Feb-04 11:54 
GeneralNearly Sorted! Pin
Spanky311-Feb-04 12:02
Spanky311-Feb-04 12:02 
GeneralRe: Nearly Sorted! Pin
Spanky311-Feb-04 12:15
Spanky311-Feb-04 12:15 
GeneralRe: Nearly Sorted! Pin
Kentamanos11-Feb-04 12:18
Kentamanos11-Feb-04 12:18 
GeneralRe: Nearly Sorted! Pin
Spanky311-Feb-04 12:21
Spanky311-Feb-04 12:21 
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1052&lngWId=10


This one is definately low level enough Big Grin | :-D

seems it anyway

Public Class frmMain<br />
    Inherits System.Windows.Forms.Form<br />
<br />
    Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As LowLevelKeyboardProcDelegate, ByVal hMod As Integer, ByVal dwThreadId As Integer) As Integer<br />
    Declare Function UnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal hHook As Integer) As Integer<br />
    Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer<br />
    Declare Function CallNextHookEx Lib "user32" Alias "CallNextHookEx" (ByVal hHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer<br />
<br />
    Const WH_KEYBOARD_LL = 13<br />
<br />
    Structure KBDLLHOOKSTRUCT<br />
        Dim vkCode As Integer<br />
        Dim scanCode As Integer<br />
        Dim flags As Integer<br />
        Dim time As Integer<br />
        Dim dwExtraInfo As Integer<br />
    End Structure<br />
<br />
    Dim intLLKey As Integer<br />
<br />
#Region " Windows Form Designer generated code "<br />
<br />
    Public Sub New()<br />
        MyBase.New()<br />
<br />
        'This call is required by the Windows Form Designer.<br />
        InitializeComponent()<br />
<br />
        'Add any initialization after the InitializeComponent() call<br />
<br />
    End Sub<br />
<br />
    'Form overrides dispose to clean up the component list.<br />
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
        If disposing Then<br />
            If Not (components Is Nothing) Then<br />
                components.Dispose()<br />
            End If<br />
        End If<br />
        MyBase.Dispose(disposing)<br />
    End Sub<br />
<br />
    'Required by the Windows Form Designer<br />
    Private components As System.ComponentModel.IContainer<br />
<br />
    'NOTE: The following procedure is required by the Windows Form Designer<br />
    'It can be modified using the Windows Form Designer.  <br />
    'Do not modify it using the code editor.<br />
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
        Me.lblInfo = New System.Windows.Forms.Label()<br />
        Me.SuspendLayout()<br />
        '<br />
        'lblInfo<br />
        '<br />
        Me.lblInfo.Location = New System.Drawing.Point(16, 16)<br />
        Me.lblInfo.Name = "lblInfo"<br />
        Me.lblInfo.Size = New System.Drawing.Size(216, 88)<br />
        Me.lblInfo.TabIndex = 0<br />
        Me.lblInfo.Text = "Alt-Tab, Alt-Esc, Ctrl-Esc, and the Windows key are disabled. Ctrl-Alt-Del and Al" & _<br />
        "t-F4 are still enabled. Close the application to reset the keyboard. While this " & _<br />
        "program is running, the low-level keyboard effect is global."<br />
        '<br />
        'frmMain<br />
        '<br />
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
        Me.ClientSize = New System.Drawing.Size(248, 118)<br />
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblInfo})<br />
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog<br />
        Me.MaximizeBox = False<br />
        Me.MinimizeBox = False<br />
        Me.Name = "frmMain"<br />
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen<br />
        Me.Text = "LowLevel Keyboard Hook"<br />
        Me.ResumeLayout(False)<br />
<br />
    End Sub<br />
<br />
#End Region<br />
<br />
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
        intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32(), 0)<br />
    End Sub<br />
<br />
    Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing<br />
        UnhookWindowsHookEx(intLLKey)<br />
    End Sub<br />
<br />
    Private Function LowLevelKeyboardProc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer<br />
        Dim blnEat As Boolean = False<br />
<br />
        Select Case wParam<br />
            Case 256, 257, 260, 261<br />
                'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key<br />
                blnEat = ((lParam.vkCode = 9) AndAlso (lParam.flags = 32)) Or _<br />
                ((lParam.vkCode = 27) AndAlso (lParam.flags = 32)) Or _<br />
                ((lParam.vkCode = 27) AndAlso (lParam.flags = 0)) Or _<br />
                ((lParam.vkCode = 91) AndAlso (lParam.flags = 1)) Or _<br />
                ((lParam.vkCode = 92) AndAlso (lParam.flags = 1))<br />
        End Select<br />
<br />
        If blnEat = True Then<br />
            Return 1<br />
        Else<br />
            Return CallNextHookEx(0, nCode, wParam, lParam)<br />
        End If<br />
    End Function<br />
    Friend WithEvents lblInfo As System.Windows.Forms.Label<br />
End Class<br />

QuestionHow do you do: On Explorer, right click on file -&gt; Open with...-&gt; MyApp.exe ? Pin
mdundek11-Feb-04 7:01
mdundek11-Feb-04 7:01 
AnswerRe: How do you do: On Explorer, right click on file -&gt; Open with...-&gt; MyApp.exe ? Pin
Heath Stewart11-Feb-04 9:43
protectorHeath Stewart11-Feb-04 9:43 
Questionhow to draw an X axis by datetime data! Pin
Member 185560811-Feb-04 4:23
Member 185560811-Feb-04 4:23 
AnswerRe: how to draw an X axis by datetime data! Pin
leppie11-Feb-04 6:05
leppie11-Feb-04 6:05 
GeneralComputer Info Pin
Kenneth Childs11-Feb-04 4:11
Kenneth Childs11-Feb-04 4:11 
GeneralRe: Computer Info Pin
hxxbin11-Feb-04 4:21
hxxbin11-Feb-04 4:21 
GeneralRe: Computer Info Pin
Kenneth Childs11-Feb-04 5:01
Kenneth Childs11-Feb-04 5:01 
GeneralRe: Computer Info Pin
Heath Stewart11-Feb-04 9:38
protectorHeath Stewart11-Feb-04 9:38 
GeneralRe: Computer Info Pin
Heath Stewart11-Feb-04 9:51
protectorHeath Stewart11-Feb-04 9:51 
GeneralRe: Computer Info Pin
Daniel Turini11-Feb-04 4:33
Daniel Turini11-Feb-04 4:33 
Generalcreating and editing Resource files Pin
POKRI11-Feb-04 3:57
POKRI11-Feb-04 3:57 
GeneralRe: creating and editing Resource files Pin
OmegaSupreme11-Feb-04 9:29
OmegaSupreme11-Feb-04 9:29 
GeneralRe: creating and editing Resource files Pin
Heath Stewart11-Feb-04 9:34
protectorHeath Stewart11-Feb-04 9:34 
GeneralPDF Viewer Pin
Mahesh Varma11-Feb-04 2:34
Mahesh Varma11-Feb-04 2:34 
GeneralRe: PDF Viewer Pin
Heath Stewart11-Feb-04 2:53
protectorHeath Stewart11-Feb-04 2:53 
GeneralTable Names Of a MS Access Database Pin
Daminda11-Feb-04 1:06
Daminda11-Feb-04 1:06 
GeneralRe: Table Names Of a MS Access Database Pin
Heath Stewart11-Feb-04 3:04
protectorHeath Stewart11-Feb-04 3:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.