>>>>>>>URGENT:: VB5 & WinHook API 
Author Message
 >>>>>>>URGENT:: VB5 & WinHook API

     Please, I need urgent help in writing a program that must monitor all
keyboard events for the entire system.  I guess the way to do is to use
the SetWinHookEx (???) API call to set up the monitor and also pass the
address of a vb procedure (using Addressof) to the API function so that
the procedure can be called back when a event occurs.  The only poblem is
I don't know any thing about SetWinHookEx and other similar functions.  I
have tried to experiment with it but without any success.

**********************************************************

I rarely log into my AOL account.                    

**********************************************************



Fri, 29 Oct 1999 03:00:00 GMT  
 >>>>>>>URGENT:: VB5 & WinHook API

RSorensenc,

Quote:
>      Please, I need urgent help in writing a program that must monitor
all
> keyboard events for the entire system.

Unless you are an API guru and are ready to do some very unusual tricks,
preferably with a C DLL, your best bet is to pick up Desaware's SpyWorks.
Simply passing your own callback address to SetWindowsHookEx ain't gonna
cut it.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Fri, 29 Oct 1999 03:00:00 GMT  
 >>>>>>>URGENT:: VB5 & WinHook API

Two problems with this...first, you are not setting the gHW variable
anywhere.  You should set it to FormName.hWnd in the Form_Load.

More importantly, this code will only catch keyboard events going to that
particular form in your application.  Keyboard events to other apps, and
other controls on the form if you do not have KeyPreview on, will not be
caught.



Hi,
If you need more help just e-mail me...

Somewher in you form General Declarations:

        Dim lpPrevWndProc as long

        'All Declarations can be found using API Viewer tool
        Public Const WM_KEYFIRST = &H100
        Public Const WM_KEYDOWN = &H100
        Public Const WM_KEYUP = &H101
        Public Const WM_CHAR = &H102
        Public Const WM_DEADCHAR = &H103
        Public Const WM_SYSKEYDOWN = &H104

        Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA"
(ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
        Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal
hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Somewere in Form_load:
        'Starts message hook
        lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)

Somewhere in Form_Unload:
        'Ends message hook
        Dim temp As Long
        temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)

Somewher in you form module:
        Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As
Long, ByVal lParam As Long) As Long

                'Handle the messages the way you want
                Select Case uMgs
                Case WM_KEYDOWN:
                        ...
                        'If you want default message handling, you should also call...
                        WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)

                Case WM_KEYUP:
                        ...
                        'If you want default message handling, you should also call...
                        WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
                Case WM_CHAR:
                        ...
                        'If you want default message handling, you should also call...
                        WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)

                Case default:
                        'This one is important !!!
                        'If you don't do it all the message you
                        'don't handle will not be handled at all.
                        WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)

                End Select

        End Function

--
Sylvain Hamel
CAE Electronics Ltd
St-Laurent, Quebec, Canada



Quote:
> There is a couple of FREEWARE controls that might help.  One is
> MSGHOO32.OCX and the other is MSGTRAP.OCX.  You can probably find
> MSGHOO32.OCX by doing a search on Yahoo.  MSGTRAP.OCX is a VB 5 control
and
> can be found at http://members.aol.com/jfmk0000/MikoUtil.htm



> >      Please, I need urgent help in writing a program that must monitor
> all
> > keyboard events for the entire system.  I guess the way to do is to use
> > the SetWinHookEx (???) API call to set up the monitor and also pass the
> > address of a vb procedure (using Addressof) to the API function so that
> > the procedure can be called back when a event occurs.  The only poblem
is
> > I don't know any thing about SetWinHookEx and other similar functions.
I
> > have tried to experiment with it but without any success.

> > **********************************************************

> > I rarely log into my AOL account.                    

> > **********************************************************

----------


Mon, 01 Nov 1999 03:00:00 GMT  
 >>>>>>>URGENT:: VB5 & WinHook API

This is a multi-part message in MIME format.

------=_NextPart_000_01BC64F1.3B6F0A00
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit



Quote:
> Two problems with this...first, you are not setting the gHW variable
> anywhere.  You should set it to FormName.hWnd in the Form_Load.


this thread found typos in my code:
        "case default" Should have been "case else"
        "uMgs" Should have been "uMsg"

Quote:
> More importantly, this code will only catch keyboard events going to that
> particular form in your application.  Keyboard events to other apps, and
> other controls on the form if you do not have KeyPreview on, will not be
> caught.

This is true and I am sorry for the error.

Regards,

--
Sylvain Hamel
CAE Electronics Ltd
St-Laurent, Quebec, Canada

------=_NextPart_000_01BC64F1.3B6F0A00
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial">Chris Kaczor &lt;<font =

color=3D"#000000">&gt; wrote in article &lt;<font =

color=3D"#000000">&gt;...<br>&gt; Two problems with this...first, you =
are not setting the gHW variable<br>&gt; anywhere. &nbsp;You should set =
it to FormName.hWnd in the Form_Load.<br><br>Oups ! Not only that, Faraz =

typos in my code:<br>&#009;&quot;case default&quot; Should have been =
&quot;case else&quot;<br>&#009;&quot;uMgs&quot; Should have been =
&quot;uMsg&quot;<br><br>&gt; More importantly, this code will only catch =
keyboard events going to that<br>&gt; particular form in your =
application. &nbsp;Keyboard events to other apps, and<br>&gt; other =
controls on the form if you do not have KeyPreview on, will not =
be<br>&gt; caught.<br><br>This is true and I am sorry for the =
error.<br><br>Regards,<br><br>-- <br>Sylvain Hamel<br>CAE Electronics =
Ltd<br>St-Laurent, Quebec, Canada<br><br></p>
</font></font></font></font></font></body></html>
------=_NextPart_000_01BC64F1.3B6F0A00--



Sat, 06 Nov 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. using The Shell Command >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

2. <<<<<<<<ComboBox>>>>>>>>>>>>

3. >>>>>>While Not rst.EOF

4. PSUDOCODE HELP >>>>>>>>>>>

5. VB5 >>>>> Academic Version

6. >>>>> Serial Communications

7. !!! URGENT HELP REQUIRED !!!>>>>>>>>

8. <<<<HELP- OLE container Control>>>>>>>>>

9. >>= bitwise operations >>

10. Please Help --------->>>>AppLink Problem

11. VB3 ->->->->VBDOS??

12. >>>> HELP WITH RUNTIME FILES

 

 
Powered by phpBB® Forum Software