Hotkeys without Timer And Form Click Through [Source]

Posts 1–2 of 2 · Page 1 of 1
Hotkeys without Timer And Form Click Through [Source]
Using windows functions to set Hotkeys globally without using timer

Tab, Shift, Alt+A, Ctrl+Alt+A

And click troughable form.
Shift to enable/disable form property.

 
Source Code

Code:
Imports System.Runtime.InteropServices

Public Class Form1
#Region " Functions"
    'hotkey stuff
    Private Declare Function UnregisterHotKey Lib "user32" Alias "UnregisterHotKey" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
    Private Declare Function RegisterHotKey Lib "user32" Alias "RegisterHotKey" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
    'click trough stuff
    <DllImport("user32.dll", EntryPoint:="GetWindowLong")> Public Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    End Function
    <DllImport("user32.dll", EntryPoint:="SetWindowLong")> Public Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    End Function

#End Region
#Region " Cons"
    'hotkey stuff
    Private Const WM_HOTKEY As Integer = &H312
    Public Const MOD_CONTROL As Integer = &H2
    Public Const MOD_SHIFT As Integer = &H4
    Public Const MOD_WIN As Integer = &H8
    Public Const MOD_ALT As Integer = &H1
    'click trough stuff
    Dim Toggle As Boolean = True
    Private InitialStyle As Integer
#End Region
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'hotkey stuff
        RegisterHotKey(MyBase.Handle, 100, MOD_SHIFT, 0) 'Shift hotkey
        RegisterHotKey(MyBase.Handle, 101, Nothing, Keys.Tab) 'Tab hotkey
        RegisterHotKey(MyBase.Handle, 102, MOD_ALT, Keys.A) 'Alt + A hotkey
        RegisterHotKey(MyBase.Handle, 103, MOD_CONTROL Or MOD_ALT, Keys.A) 'Ctrl + Alt + A hotkey
        'click trough stuff
        InitialStyle = GetWindowLong(Me.Handle, -20)

    End Sub
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        UnregisterHotKey(MyBase.Handle, 100)
        UnregisterHotKey(MyBase.Handle, 101)
        UnregisterHotKey(MyBase.Handle, 102)
        UnregisterHotKey(MyBase.Handle, 103)
    End Sub

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

        If m.Msg = WM_HOTKEY Then
            Select Case m.WParam.ToInt32

                Case 100
                    'Shift Pressed
                    'click trough stuff
                    If Toggle Then
                        Me.Text = "Can't Touch This"
                        SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20)
                        Toggle = Not Toggle

                    Else
                        Me.Text = "You Can Touch This"
                        SetWindowLong(Me.Handle, -20, InitialStyle)
                        Toggle = Not Toggle

                    End If

                Case 101
                    'Tab Pressed
                    Me.Text = m.WParam.ToInt32.ToString + ". Hotkey Tab Pressed"

                Case 102 'Alt + A Pressed
                    Me.Text = m.WParam.ToInt32.ToString + ". Hotkey Tab + A Pressed"

                Case 103 'Ctrl + Alt + A Pressed
                    Me.Text = m.WParam.ToInt32.ToString + ". Hotkey Ctrl + Tab + A Pressed"

            End Select
        End If
        MyBase.WndProc(m)
    End Sub
End Class
Click Trough Demo_mpgh.net.rar9 KB · 24 downloads 1/63 malicious
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?