Click here to Skip to main content
15,900,424 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How does a Classic ASP/VB programmer become an ASP.NET Pin
Kevin McFarlane2-Apr-07 4:41
Kevin McFarlane2-Apr-07 4:41 
AnswerRe: How does a Classic ASP/VB programmer become an ASP.NET Pin
kubben2-Apr-07 5:46
kubben2-Apr-07 5:46 
QuestionTrial Version Pin
Socheat.Net2-Apr-07 1:09
Socheat.Net2-Apr-07 1:09 
AnswerRe: Trial Version Pin
CPallini2-Apr-07 1:59
mveCPallini2-Apr-07 1:59 
AnswerRe: Trial Version Pin
Nick Rioux2-Apr-07 10:41
Nick Rioux2-Apr-07 10:41 
GeneralRe: Trial Version Pin
Socheat.Net2-Apr-07 21:25
Socheat.Net2-Apr-07 21:25 
QuestionReturn code 200 or 304 by means of SetETag [modified] Pin
alexburzak2-Apr-07 0:38
alexburzak2-Apr-07 0:38 
QuestionAbout global keyboard hook in VB2005 Pin
Asasin8101622-Apr-07 0:16
Asasin8101622-Apr-07 0:16 
After a long time searching...
After so many mouse-click...
Surfed so many pages

I think it is ok to work as a global hook but it doesn't work.
I don't know where the problem is.

Here is my steps:
1.open a new windows aplication project.
2.add a module with code below
<br />
Module Module1<br />
    Declare Function GetCurrentThreadId Lib "kernel32" Alias "GetCurrentThreadId" () As Integer<br />
    Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As HOOKPROC, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer<br />
    Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Integer) As Integer<br />
    Declare Function CallNextHookEx Lib "user32" Alias "callnexthookex" (ByVal hHook As Integer, ByVal ncode As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer<br />
<br />
    Public Delegate Function HOOKPROC(ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer<br />
<br />
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer<br />
<br />
    Public hnexthookproc As Integer = 0<br />
<br />
    Public Const PM_KEY_PrintScreen = &H2c<br />
<br />
    Public Structure KbStruct<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 />
    Public Enum HookType<br />
<br />
        WH_KEYBOARD = 2<br />
<br />
    End Enum<br />
<br />
    Public Sub UnHook() 'close Hook <br />
        If hnexthookproc <> 0 Then<br />
            UnhookWindowsHookEx(hnexthookproc)<br />
            hnexthookproc = 0<br />
        End If<br />
    End Sub<br />
<br />
    Public Function SetHook() 'set Hook <br />
        If hnexthookproc <> 0 Then<br />
            Exit Function<br />
        End If<br />
<br />
        hnexthookproc = SetWindowsHookEx(HookType.WH_KEYBOARD, AddressOf MyKeyboardProc, 0, GetCurrentThreadId())<br />
    End Function<br />
<br />
<br />
    Public Function MyKeyboardProc(ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer<br />
        MyKeyboardProc = 0<br />
        If nCode < 0 Then<br />
            MyKeyboardProc = CallNextHookEx(hnexthookproc, nCode, wParam, lParam)<br />
            Exit Function<br />
        End If<br />
<br />
        If wParam = PM_KEY_PrintScreen Then<br />
            MyKeyboardProc = 1<br />
            MsgBox("HOOK!")<br />
        End If<br />
    End Function<br />
End Module<br />

3.call my function to set hook in form_load and close in form_close:
<br />
Public Class Form1<br />
<br />
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
        Call SetHook()<br />
    End Sub<br />
<br />
    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed<br />
        Call UnHook()<br />
    End Sub<br />
<br />
End Class<br />

AnswerRe: About global keyboard hook in VB2005 Pin
Duncan Edwards Jones2-Apr-07 0:34
professionalDuncan Edwards Jones2-Apr-07 0:34 
GeneralRe: About global keyboard hook in VB2005 Pin
Asasin8101622-Apr-07 6:19
Asasin8101622-Apr-07 6:19 
QuestionIs it possible to grab a pop up message written by javascript from a html page in a webbrowser control? Pin
astcws1-Apr-07 23:33
astcws1-Apr-07 23:33 
AnswerRe: Is it possible to grab a pop up message written by javascript from a html page in a webbrowser control? Pin
Dave Kreskowiak2-Apr-07 1:12
mveDave Kreskowiak2-Apr-07 1:12 
Questionremoving excel filters using VB macro Pin
Keshav V. Kamat1-Apr-07 21:54
Keshav V. Kamat1-Apr-07 21:54 
AnswerRe: removing excel filters using VB macro Pin
Keshav V. Kamat2-Apr-07 18:25
Keshav V. Kamat2-Apr-07 18:25 
Questioncrystal report..... Pin
Member 38798811-Apr-07 20:31
Member 38798811-Apr-07 20:31 
AnswerRe: crystal report..... Pin
freefika2-Apr-07 10:32
freefika2-Apr-07 10:32 
QuestionBack button does not work in IE? Pin
porsti1-Apr-07 20:24
porsti1-Apr-07 20:24 
QuestionHow to Connect Remote Database In Vb.Net For MS Access Database Pin
Kiran S. S.1-Apr-07 19:54
Kiran S. S.1-Apr-07 19:54 
AnswerRe: How to Connect Remote Database In Vb.Net For MS Access Database Pin
_mubashir1-Apr-07 21:28
_mubashir1-Apr-07 21:28 
GeneralRe: How to Connect Remote Database In Vb.Net For MS Access Database Pin
Kiran S. S.3-Apr-07 1:55
Kiran S. S.3-Apr-07 1:55 
QuestionSOUND FREQUENCY Problem Pin
Dahlia Lahla1-Apr-07 17:25
Dahlia Lahla1-Apr-07 17:25 
AnswerRe: SOUND FREQUENCY Problem Pin
Dave Kreskowiak1-Apr-07 17:45
mveDave Kreskowiak1-Apr-07 17:45 
QuestionRe: SOUND FREQUENCY Problem Pin
Dahlia Lahla3-Apr-07 12:54
Dahlia Lahla3-Apr-07 12:54 
QuestionCrystal Reports in VB.Net 2003 Pin
Kusal1-Apr-07 17:07
Kusal1-Apr-07 17:07 
AnswerRe: Crystal Reports in VB.Net 2003 Pin
Tirthadip1-Apr-07 18:31
Tirthadip1-Apr-07 18:31 

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.