Click here to Skip to main content
15,861,172 members
Home / Discussions / C#
   

C#

 
AnswerRe: How do I change the ALT-TAB icon ? Pin
Heath Stewart19-Jan-04 4:25
protectorHeath Stewart19-Jan-04 4:25 
GeneralReplacement for multiple inheritance Pin
Severino18-Jan-04 23:25
Severino18-Jan-04 23:25 
GeneralRe: Replacement for multiple inheritance Pin
Colin Angus Mackay19-Jan-04 2:09
Colin Angus Mackay19-Jan-04 2:09 
GeneralSoftware Testing tool Pin
Member 33502218-Jan-04 22:47
Member 33502218-Jan-04 22:47 
GeneralRe: Software Testing tool Pin
Colin Angus Mackay19-Jan-04 2:11
Colin Angus Mackay19-Jan-04 2:11 
GeneralWindows Service with Balloon Tooltips Pin
jochen vg18-Jan-04 22:40
jochen vg18-Jan-04 22:40 
GeneralRe: Windows Service with Balloon Tooltips Pin
Heath Stewart19-Jan-04 4:21
protectorHeath Stewart19-Jan-04 4:21 
GeneralWH_KEYBOARD Global Hook Pin
gekoscan18-Jan-04 20:55
gekoscan18-Jan-04 20:55 
Hello,

http://msdn.microsoft.com/msdnmag/issues/02/10/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 LocalWindowsHook that imports the below API calls

protected static extern IntPtr SetWindowsHookEx(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 = SetWindowsHookEx(
m_hookType, m_filterFunc,
IntPtr.Zero,
(int)AppDomain.GetCurrentThreadId());
}

to

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

public static IntPtr GetHInstance()
{
return Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]);
}

In an attempt to create a global hook using WH_KEYBOARD.

The problem I have is it doesn't work. Hmmm | :| 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


GeneralRe: WH_KEYBOARD Global Hook Pin
Duncan Edwards Jones18-Jan-04 21:37
professionalDuncan Edwards Jones18-Jan-04 21:37 
GeneralI don't believe this is the case Pin
gekoscan18-Jan-04 22:11
gekoscan18-Jan-04 22:11 
GeneralRe: I don't believe this is the case Pin
Duncan Edwards Jones19-Jan-04 1:55
professionalDuncan Edwards Jones19-Jan-04 1:55 
GeneralPreview of custom file type Pin
Shree18-Jan-04 20:54
Shree18-Jan-04 20:54 
GeneralRe: Preview of custom file type Pin
Heath Stewart19-Jan-04 3:51
protectorHeath Stewart19-Jan-04 3:51 
Generalseparated from its underlying RCW when accessing a chat frame. Pin
Andrlage18-Jan-04 11:00
Andrlage18-Jan-04 11:00 
GeneralPersist data across pages using Web Table Control Pin
caheo18-Jan-04 10:19
caheo18-Jan-04 10:19 
GeneralRe: Persist data across pages using Web Table Control Pin
Mazdak18-Jan-04 10:32
Mazdak18-Jan-04 10:32 
GeneralRe: Persist data across pages using Web Table Control Pin
Heath Stewart18-Jan-04 12:01
protectorHeath Stewart18-Jan-04 12:01 
GeneralRe: Persist data across pages using Web Table Control Pin
caheo18-Jan-04 13:55
caheo18-Jan-04 13:55 
GeneralRe: Persist data across pages using Web Table Control Pin
Heath Stewart19-Jan-04 3:00
protectorHeath Stewart19-Jan-04 3:00 
GeneralAdded method with a wizard Pin
Anonymous18-Jan-04 10:06
Anonymous18-Jan-04 10:06 
GeneralRe: Added method with a wizard Pin
Mazdak18-Jan-04 10:19
Mazdak18-Jan-04 10:19 
GeneralRe: Added method with a wizard Pin
leppie18-Jan-04 11:35
leppie18-Jan-04 11:35 
GeneralRe: Added method with a wizard Pin
Mazdak18-Jan-04 20:12
Mazdak18-Jan-04 20:12 
GeneralRe: Added method with a wizard Pin
Guillermo Rivero18-Jan-04 10:32
Guillermo Rivero18-Jan-04 10:32 
GeneralC# - Multidimensionnal array of pointers Pin
Orahn18-Jan-04 7:05
Orahn18-Jan-04 7:05 

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.