'Code donated by SpegettiProg, AKA Numbchucks, AKA SiLentThReaD, AKA BLOW-T0RCH
'Feel free to distribute both code and video instruction
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(32, 24)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(248, 80)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Alt to IE"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(328, 141)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Int32, _
ByVal lParam As Int32) As Boolean
'Above we import 2 functions from user32
Private Const WM_SYSKEYDOWN As Integer = &H104
Private Const WM_SYSKEYUP As Integer = &H105
'Above we specify the values of the for our WM_Messages
Dim wParam As Integer
Dim lParam As Integer
'Above we declare our wParam and lParam
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim IE_Handle As Integer 'Declaring our window handle
IE_Handle = FindWindow("IEFrame", vbNullString)
'Geting our window handle using the FindWindow function we imported.
'IEFrame is the class name of IE. You could have also
'used the title in place of
AppActivate("Google")
'Not recommended to hard code anything, but this is just for testing sake.
'We active the IE window that has google open
wParam = &H12
lParam = &H20380001
'Above we assign our params the values we got from spy++
PostMessage(IE_Handle, WM_SYSKEYDOWN, wParam, lParam)
PostMessage(IE_Handle, WM_SYSKEYUP, wParam, lParam)
'Above, we simulate a alt keystroke
SendKeys.Send("f")
SendKeys.Send("r")
'Above, we use SendKeys to active the properties window
End Sub
End Class