473,800 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

win32 global hook

Hello,

http://msdn.microsoft.com/msdnmag/is...0/cuttingedge/

I don't know if any of you are familiar with Dino Esposito article in
MSDN magazine on .NET Hooks but I used the class he created named
LocalWindowsHoo k that imports the below API calls

protected static extern IntPtr SetWindowsHookE x(HookType code,
HookProc func,
IntPtr hInstance,
int threadID);

and a few other necessary functions from user32.dll to implement a
hook.

I ended up changing his Install function from

public void Install()
{
m_hhook = SetWindowsHookE x(
m_hookType, m_filterFunc,
IntPtr.Zero,
(int)AppDomain. GetCurrentThrea dId());
}

to

public void Install()
{
m_hhook = SetWindowsHookE x(
m_hookType,
m_filterFunc,
GetHInstance(),
0);
}

public static IntPtr GetHInstance()
{
return
Marshal.GetHINS TANCE(System.Re flection.Assemb ly.GetExecuting Assembly().GetM odules()[0]);
}

In an attempt to create a global hook using WH_KEYBOARD.

The problem I have is it doesn't work. It works globally with
WH_KEYBOARD_LL but as soon as I use WH_KEYBOARD it doesn't work at
all. This meaning it doesn't capture keyboard strokes in either the
windows form or anywhere else. Now Dino's code worked fine for a
local hook (aka the form) but I want a global or system hook.

Now I have the class he wrote in an external DLL but there must be
something else i am missing. If anyone has any suggestions they would
be very much appreciated.

Thanks very much.

Dino Esposito modified project and my test windows form can be found
here

http://scaninc.ca/hook/globalhook.zip

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 17 '05 #1
0 1870

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1492
by: Tom Brown | last post by:
Hi, I created a win32 service for XPPro called N4010ATestService.py (see below). The service runs as a particular user with administrative rights. It starts a thread that creates a simple socket server (N4010ASocketServer.py -- also below) that just waits for 20 character string. When I run the socket server by itself the test client can connect to the server and send a 20 character string just fine. When I run the service, the server...
3
12603
by: paul francis | last post by:
Hi Please help because I'm really stuck: I'm trying to write an application in C# which can be used to track the mouse pointer position on any window. I'm trying to use a Global mouse hook to do this but with limited success. According to the documentation (as I understand it) you can only do Global hooks in ..Net if the delegate procedure passed to SetWindowsHookEx is external.
2
2238
by: Tim | last post by:
Please advise if you can. Presumably initialisation of members in member initialisation lists is perfomed by 'C' run-time startup. If the CRT was never started-up would those members be garbage? Which of these fundamental language support features could I expect to be absent (and anything else I might have missed): static data zeroing global data zeroing
0
2757
by: sharp | last post by:
I've done enough reading through the groups to know that a Global Keyboard hook is not possible via C# (.NET) itself. From what I have seen proposed is that you need to write a global hook in a C++ dll and PInvoke that dll. Well, I'm not a C++ dev but need to get a global hook from C#. Are there any samples anywhere on how to write the C++ hook and use it from C#?
3
4038
by: Arnold | last post by:
Hola, hace unos meses pregunte sobre hacer un hook global al teclado y me dieron varios articulos, uno de ellos estaba en VB .net y era el unico que atrapaba los accesos directos (CTRL + ESC, CTRL + Q, ALT + F, etc). No encuentro el articulo, alguien lo tiene a mano o sabe como controlar si es un acceso directo? Gracias.
2
4712
by: Lunchtimemama | last post by:
I am trying to modify another application's window (Google Talk) to insert some UI of my own. I think the best method would be to install a remote local hook in gtalk's thread that intercepts the paint message and injects the custom UI. From the reading I've done, it is possible to install a system hook with an unmanaged stub that passes execution off to a managed C# delegate (http://www.codeproject.com/csharp/GlobalSystemHook.asp), but...
1
3315
by: Anonieko | last post by:
Global.asax? Use HttpModules Instead! In a previous post, I talked about HttpHandlers - an underused but incredibly useful feature of ASP.NET. Today I want to talk about HttpModules, which are probably more common than HttpHandlers, but could still stand to be advertised a bit more. HttpModules are incredibly easy to explain, so this will hopefully be a short-ish post. Simply put, HttpModules are portable versions of the global.asax....
21
5251
by: Paul Edwards | last post by:
I have written a public domain (not GPL etc) C runtime library (PDPCLIB) for DOS, OS/2 and MVS. You can see it here: http://sourceforge.net/projects/pdos/ I now wish to port it to Win32, so that I can create executables to run under Windows 98 command prompt where every byte of the executable is from public domain code. I'm only interested in writing strictly conforming C89 programs,
1
2598
by: JJ | last post by:
I'd like to know whether or not I can use a global WH_SHELL hook in Vista? Thanks
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.