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

Home Posts Topics Members FAQ

SetWindowsHookE x C# trap key combinations

Hi,

Can't seem to find any sensible C# examples of this, struggling to work out
the correct way to trap key combinations using SetWindowsHookE x with
WH_KEYBOARD_LL, such as ALT-ESC.

private int InterpretKey(in t nCode, IntPtr wParam, IntPtr lParam)
{

.....

hookStruct = (KeyboardHookSt ruct)Marshal.Pt rToStructure(lP aram,
typeof(Keyboard HookStruct));

if (hookStruct.vkC ode == VK_MENU &&
(hookStruct.fla gs & VK_ESCAPE ) == hookStruct.flag s)
{
handled = true;
....
}

.....

}


Sep 22 '06 #1
1 8447
Ok figured this out, there's different codes for the flag checks.

if (hookStruct.vkC ode == ESCAPE &&
(hookStruct.fla gs & LLKHF_ALTDOWN) == hookStruct.flag s)
"Mike Carlisle" wrote:
Hi,

Can't seem to find any sensible C# examples of this, struggling to work out
the correct way to trap key combinations using SetWindowsHookE x with
WH_KEYBOARD_LL, such as ALT-ESC.

private int InterpretKey(in t nCode, IntPtr wParam, IntPtr lParam)
{

....

hookStruct = (KeyboardHookSt ruct)Marshal.Pt rToStructure(lP aram,
typeof(Keyboard HookStruct));

if (hookStruct.vkC ode == VK_MENU &&
(hookStruct.fla gs & VK_ESCAPE ) == hookStruct.flag s)
{
handled = true;
....
}

....

}

Sep 22 '06 #2

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

Similar topics

36
9485
by: rbt | last post by:
Say I have a list that has 3 letters in it: I want to print all the possible 4 digit combinations of those 3 letters: 4^3 = 64 aaaa
1
3099
by: bugs bunny via .NET 247 | last post by:
Does anyone have actually used SetWindowsHookEx() to hook upShellExecute() so as to find what application was started bywindows or which folder is currently browsed by explorer. I knowone thing and that is ... Windows uses ShellExecute() to doalmost every task. I need some implementation help. I want to trigger an userdefined function when suppose Notepad is opened or in simplecase a messagebox that says Notepad has started. If anyone has a...
15
11901
by: bruno | last post by:
I need some help on how write SetWindowsHookEx in vb.net 2005 to hook kb input. this is the statement: hHOOKKb = SetWindowsHookEx( _ WH_KEYBOARD, _ lpfn, _ hMod, _ dwThreadId) And this is from MSDN Library: lpfn Pointer to the hook procedure.
3
5014
by: Robert W. | last post by:
In my WinForms app I wanted to implement a Read-Only textbox. I didn't like the appearance a textbox takes on when the ReadOnly property is set true so instead I trapped the KeyPress event with a generic event handler: private void textBoxMakeReadOnly(object sender, KeyPressEventArgs e) { e.Handled = true; }
4
6065
by: abcd | last post by:
I am having trouble with pyHook on python 2.4.1. Basically I have a python app that uses pyHook to capture keyboard events and write them straight to a file. The application is running as a service on a windows machine. If I am at that windows machine the application works just fine, logging my keystrokes. However, if I use Remote Desktop to connect to the machine and open up say Notepad it doesn't capture the keystrokes. Is this a...
2
3324
by: Charles Law | last post by:
I'll kick myself when you tell me, but ... I have a user control on a form, and I want the user control to see the arrow keys when I press them. If I press just about any other key the control's KeyDown event is fired, but not when I press a direction key. I want to see them in the KeyDown event so that I can respond as soon as the key is depressed, and I want to detect when the key is held down so that I can perform an action...
2
3894
by: KWhat4 | last post by:
I seem to have an issue that I cant resolve. I have a jni dll that calls SetWindowsHookEx with a callback to HookKeyboardProc (basically a real simple global keyboard hook). Now the dll almost works all the jni hooks are fine and the program appears to run but the callback (HookKeyboardProc) does not seem to get executed or possibly never returns from execution. The code is as follows. None of the variables being set in the code...
5
4562
krungkrung
by: krungkrung | last post by:
Hi everyone! Im new to vb.net. I'm currently recoding my vb6.0 codes to vb.net(for upgrading purposes), unfortunately some of the codes dont work/execute the way it executes in vb6.0, though I never get any error. That is, the program runs without error but the function being called dont execute. Can anybody help me figure out this matter?? ***HERES WHAT SHOULD THE PROGRAM DO.... message box should always display at the center of the owner...
2
2898
by: niksoftware | last post by:
I'm making a kiosk style desktop replacement. Im using setwindowshookex to run a callback system to trap the keys just trapping "windows" key atm. if I step through just as the program goes the the keyboardcallback function declaration line it pauses for seconds before moving to the next line. This directly precedes the new variable declaration of the callback variable While running this leads to only 1 press of the "windows" keys...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
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.