473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Low Level Keyboard Hooks in C#

Hi!
I need to prevent Task-Switching in my App, so I tried to implement a
low level keyboard hook in a extra class. But it seems that the
Parameters are not passed correctly to my Hook function. Similar
Examples in VB .NET work correctly.

Heres the Source Code:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Diagnostics;

public class LowLevelKeyboardHook :IDisposable
{
[DllImport("user32.dll")]
private static extern int SetWindowsHookExA(int IDHook, IntPtr lpfn,
int hMod,
int dwThreadID);

[DllImport("user32.dll")]
private static extern int UnhookWindowsHookEx(int hHook);

[DllImport("user32.dll")]
private static extern int CallNextHookEx(int hHook, int nCode, int
wParam, ref KBDLLHOOKSTRUCT lParam);

private delegate int LowLevelKeyboardProc(int nCode, int wParam,
KBDLLHOOKSTRUCT lParam);

public struct KBDLLHOOKSTRUCT
{
public int vkCode;
public int scanCode;
public int flags;
public int time;
public int dwExtraInfo;
}

private const int WH_KEYBOARD_LL = 13;
private int intLLKey;

public LowLevelKeyboardHook()
{
intLLKey = SetWindowsHookExA(WH_KEYBOARD_LL, new
LowLevelKeyboardProc(WindowKeyHook).Method.MethodH andle.GetFunctionPointer(),
System.Runtime.InteropServices.Marshal.GetHINSTANC E(System.Reflection.Assembly.GetExecutingAssembly( ).GetModules()[0]).ToInt32(),
0);
}

public int WindowKeyHook(int nCode, int wParam, KBDLLHOOKSTRUCT
lParam)
{
bool killKey = false;

if(killKey)
{
return 1;
}
else
{
return 0;
}
}

public void Dispose()
{
UnhookWindowsHookEx(intLLKey);
}
}
[b:2c1b8f9cf8]and the VB-Code, which worked[/b:2c1b8f9cf8]

Public Class frmMain
Inherits System.Windows.Forms.Form

Declare Function SetWindowsHookEx Lib "user32" Alias
"SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As
LowLevelKeyboardProcDelegate, ByVal hMod As Integer, ByVal dwThreadId
As Integer) As Integer
Declare Function UnhookWindowsHookEx Lib "user32" Alias
"UnhookWindowsHookEx" (ByVal hHook As Integer) As Integer
Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode As
Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As
Integer
Declare Function CallNextHookEx Lib "user32" Alias
"CallNextHookEx" (ByVal hHook As Integer, ByVal nCode As Integer,
ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer

Const WH_KEYBOARD_LL = 13

Structure KBDLLHOOKSTRUCT
Dim vkCode As Integer
Dim scanCode As Integer
Dim flags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure

Dim intLLKey As Integer

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.lblInfo = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'lblInfo
'
Me.lblInfo.Location = New System.Drawing.Point(16, 16)
Me.lblInfo.Name = "lblInfo"
Me.lblInfo.Size = New System.Drawing.Size(216, 88)
Me.lblInfo.TabIndex = 0
Me.lblInfo.Text = "Alt-Tab, Alt-Esc, Ctrl-Esc, and the Windows
key are disabled. Ctrl-Alt-Del and Al" & _
"t-F4 are still enabled. Close the application to reset the
keyboard. While this " & _
"program is running, the low-level keyboard effect is
global."
'
'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(248, 118)
Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.lblInfo})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmMain"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text = "LowLevel Keyboard Hook"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf
LowLevelKeyboardProc,
System.Runtime.InteropServices.Marshal.GetHINSTANC E(System.Reflection.Assembly.GetExecutingAssembly. GetModules()(0)).ToInt32(),
0)
End Sub

Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
UnhookWindowsHookEx(intLLKey)
End Sub

Private Function LowLevelKeyboardProc(ByVal nCode As Integer,
ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Dim blnEat As Boolean = False

Debug.WriteLine(nCode.ToString())

Select Case wParam
Case 256, 257, 260, 261
'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
blnEat = ((lParam.vkCode = 9) AndAlso (lParam.flags =
32)) Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 32))
Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 0))
Or _
((lParam.vkCode = 91) AndAlso (lParam.flags = 1))
Or _
((lParam.vkCode = 92) AndAlso (lParam.flags = 1))
End Select

If blnEat = True Then
Return 1
Else
Return CallNextHookEx(0, nCode, wParam, lParam)
End If
End Function
Friend WithEvents lblInfo As System.Windows.Forms.Label
End Class

hopefully somebody can help me!
thanks daFritz

----== 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 15 '05 #1
6 12971
intLLKey = SetWindowsHookExA(WH_KEYBOARD_LL, new
LowLevelKeyboardProc(WindowKeyHook).Method.Method Handle.GetFunctionPointer(),
System.Runtime.InteropServices.Marshal.GetHINSTAN CE(System.Reflection.Assembly.GetExecutingAssembly ().GetModules()[0]).ToInt32(),
0);


The second parameter should be a delegate, just like in the VB.NET
code. GetFunctionPointer() will not work as expected.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2
From what it looks like, you are trying to prevent OS
keyboard messaged from being processed by your app?

you might try to take a look at using the IMessageFilter
interface. This is a clean, totally managed way to do
this. When the keyboard event fires, the interfaces
PreFilterMessage function gets fired. you can then just
return the value of your killKey bool.

-----Original Message-----
Hi!
I need to prevent Task-Switching in my App, so I tried to implement alow level keyboard hook in a extra class. But it seems that theParameters are not passed correctly to my Hook function. SimilarExamples in VB .NET work correctly.

Heres the Source Code:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Diagnostics;

public class LowLevelKeyboardHook :IDisposable
{
[DllImport("user32.dll")]
private static extern int SetWindowsHookExA (int IDHook, IntPtr lpfn,int hMod,
int dwThreadID);

[DllImport("user32.dll")]
private static extern int UnhookWindowsHookEx(int hHook);
[DllImport("user32.dll")]
private static extern int CallNextHookEx (int hHook, int nCode, intwParam, ref KBDLLHOOKSTRUCT lParam);

private delegate int LowLevelKeyboardProc(int nCode, int wParam,KBDLLHOOKSTRUCT lParam);

public struct KBDLLHOOKSTRUCT
{
public int vkCode;
public int scanCode;
public int flags;
public int time;
public int dwExtraInfo;
}

private const int WH_KEYBOARD_LL = 13;
private int intLLKey;

public LowLevelKeyboardHook()
{
intLLKey = SetWindowsHookExA (WH_KEYBOARD_LL, newLowLevelKeyboardProc (WindowKeyHook).Method.MethodHandle.GetFunctionPoi nter(),System.Runtime.InteropServices.Marshal.GetHINSTAN CE (System.Reflection.Assembly.GetExecutingAssembly
().GetModules()[0]).ToInt32(),0);
}

public int WindowKeyHook(int nCode, int wParam, KBDLLHOOKSTRUCTlParam)
{
bool killKey = false;

if(killKey)
{
return 1;
}
else
{
return 0;
}
}

public void Dispose()
{
UnhookWindowsHookEx(intLLKey);
}
}
[b:2c1b8f9cf8]and the VB-Code, which worked[/b:2c1b8f9cf8]

Public Class frmMain
Inherits System.Windows.Forms.Form

Declare Function SetWindowsHookEx Lib "user32" Alias
"SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn AsLowLevelKeyboardProcDelegate, ByVal hMod As Integer, ByVal dwThreadIdAs Integer) As Integer
Declare Function UnhookWindowsHookEx Lib "user32" Alias"UnhookWindowsHookEx" (ByVal hHook As Integer) As Integer
Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode AsInteger, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) AsInteger
Declare Function CallNextHookEx Lib "user32" Alias
"CallNextHookEx" (ByVal hHook As Integer, ByVal nCode As Integer,ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Const WH_KEYBOARD_LL = 13

Structure KBDLLHOOKSTRUCT
Dim vkCode As Integer
Dim scanCode As Integer
Dim flags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure

Dim intLLKey As Integer

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call
End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing AsBoolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows FormDesigner
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.lblInfo = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'lblInfo
'
Me.lblInfo.Location = New System.Drawing.Point (16, 16) Me.lblInfo.Name = "lblInfo"
Me.lblInfo.Size = New System.Drawing.Size(216, 88)
Me.lblInfo.TabIndex = 0
Me.lblInfo.Text = "Alt-Tab, Alt-Esc, Ctrl-Esc, and the Windowskey are disabled. Ctrl-Alt-Del and Al" & _
"t-F4 are still enabled. Close the application to reset thekeyboard. While this " & _
"program is running, the low-level keyboard effect isglobal."
'
'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(248, 118)
Me.Controls.AddRange(New System.Windows.Forms.Control(){Me.lblInfo})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialo g
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmMain"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScre en
Me.Text = "LowLevel Keyboard Hook"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOfLowLevelKeyboardProc,
System.Runtime.InteropServices.Marshal.GetHINSTAN CE (System.Reflection.Assembly.GetExecutingAssembly.G etModules
()(0)).ToInt32(),0)
End Sub

Private Sub frmMain_Closing(ByVal sender As Object, ByVal e AsSystem.ComponentModel.CancelEventArgs) Handles MyBase.Closing UnhookWindowsHookEx(intLLKey)
End Sub

Private Function LowLevelKeyboardProc(ByVal nCode As Integer,ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer Dim blnEat As Boolean = False

Debug.WriteLine(nCode.ToString())

Select Case wParam
Case 256, 257, 260, 261
'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
blnEat = ((lParam.vkCode = 9) AndAlso (lParam.flags =32)) Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 32))Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 0))Or _
((lParam.vkCode = 91) AndAlso (lParam.flags = 1))Or _
((lParam.vkCode = 92) AndAlso (lParam.flags = 1)) End Select

If blnEat = True Then
Return 1
Else
Return CallNextHookEx(0, nCode, wParam, lParam) End If
End Function
Friend WithEvents lblInfo As System.Windows.Forms.LabelEnd Class

hopefully somebody can help me!
thanks daFritz

----== 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 15 '05 #3
Thanks, the provided links helped a lot understanding Low Level
Hooks;

:wink: daFritz

----== 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 15 '05 #4
The IMessageFilter is a good idea, but since the alt + tab message (or
similar hotkeys) are directly passed to windows (not over my app) it
won't work for me.

daFritz

----== 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 15 '05 #5
HookAPI is the API SDK that setup SYSTEM-WIDE hooks for all windows
platform,it could easily hook 32-bit windows system APIs or 32-bit
user-defined DLL, it could be used easily,and what you need to do is
only writing a DLL file named mydll.dll or mydll_9x.dll.

I think it will helpful for you.Please see the detail information at
http://www.programsalon.com/en/hookapi.htm
Nov 15 '05 #6
I have one app that uses Alt-mouseClick commands to enter a special
customization mode. However, due to the KVM I use, all mouse clicks are sent
as Alt-Click messages. This doesn't bother most software. However, it makes
that one certain program unusable (normal commands can't be processed). Does
anyone have any ideas how I could solve this issue? Could I write a program
to translate Alt-Clicks to regular clicks? It sounds like what I need is
similar to the topic of the OP. Thanks!
Regards,
Mountain

"daFritz" <da*****@inext-dot-at.no-spam.invalid> wrote in message
news:3f**********@127.0.0.1...
Hi!
I need to prevent Task-Switching in my App, so I tried to implement a
low level keyboard hook in a extra class. But it seems that the
Parameters are not passed correctly to my Hook function. Similar
Examples in VB .NET work correctly.

Heres the Source Code:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Diagnostics;

public class LowLevelKeyboardHook :IDisposable
{
[DllImport("user32.dll")]
private static extern int SetWindowsHookExA(int IDHook, IntPtr lpfn,
int hMod,
int dwThreadID);

[DllImport("user32.dll")]
private static extern int UnhookWindowsHookEx(int hHook);

[DllImport("user32.dll")]
private static extern int CallNextHookEx(int hHook, int nCode, int
wParam, ref KBDLLHOOKSTRUCT lParam);

private delegate int LowLevelKeyboardProc(int nCode, int wParam,
KBDLLHOOKSTRUCT lParam);

public struct KBDLLHOOKSTRUCT
{
public int vkCode;
public int scanCode;
public int flags;
public int time;
public int dwExtraInfo;
}

private const int WH_KEYBOARD_LL = 13;
private int intLLKey;

public LowLevelKeyboardHook()
{
intLLKey = SetWindowsHookExA(WH_KEYBOARD_LL, new
LowLevelKeyboardProc(WindowKeyHook).Method.MethodH andle.GetFunctionPointer()
, System.Runtime.InteropServices.Marshal.GetHINSTANC E(System.Reflection.Assemb
ly.GetExecutingAssembly().GetModules()[0]).ToInt32(), 0);
}

public int WindowKeyHook(int nCode, int wParam, KBDLLHOOKSTRUCT
lParam)
{
bool killKey = false;

if(killKey)
{
return 1;
}
else
{
return 0;
}
}

public void Dispose()
{
UnhookWindowsHookEx(intLLKey);
}
}
[b:2c1b8f9cf8]and the VB-Code, which worked[/b:2c1b8f9cf8]

Public Class frmMain
Inherits System.Windows.Forms.Form

Declare Function SetWindowsHookEx Lib "user32" Alias
"SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As
LowLevelKeyboardProcDelegate, ByVal hMod As Integer, ByVal dwThreadId
As Integer) As Integer
Declare Function UnhookWindowsHookEx Lib "user32" Alias
"UnhookWindowsHookEx" (ByVal hHook As Integer) As Integer
Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode As
Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As
Integer
Declare Function CallNextHookEx Lib "user32" Alias
"CallNextHookEx" (ByVal hHook As Integer, ByVal nCode As Integer,
ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer

Const WH_KEYBOARD_LL = 13

Structure KBDLLHOOKSTRUCT
Dim vkCode As Integer
Dim scanCode As Integer
Dim flags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure

Dim intLLKey As Integer

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.lblInfo = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'lblInfo
'
Me.lblInfo.Location = New System.Drawing.Point(16, 16)
Me.lblInfo.Name = "lblInfo"
Me.lblInfo.Size = New System.Drawing.Size(216, 88)
Me.lblInfo.TabIndex = 0
Me.lblInfo.Text = "Alt-Tab, Alt-Esc, Ctrl-Esc, and the Windows
key are disabled. Ctrl-Alt-Del and Al" & _
"t-F4 are still enabled. Close the application to reset the
keyboard. While this " & _
"program is running, the low-level keyboard effect is
global."
'
'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(248, 118)
Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.lblInfo})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmMain"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text = "LowLevel Keyboard Hook"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf
LowLevelKeyboardProc,
System.Runtime.InteropServices.Marshal.GetHINSTANC E(System.Reflection.Assemb
ly.GetExecutingAssembly.GetModules()(0)).ToInt32() , 0)
End Sub

Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
UnhookWindowsHookEx(intLLKey)
End Sub

Private Function LowLevelKeyboardProc(ByVal nCode As Integer,
ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Dim blnEat As Boolean = False

Debug.WriteLine(nCode.ToString())

Select Case wParam
Case 256, 257, 260, 261
'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
blnEat = ((lParam.vkCode = 9) AndAlso (lParam.flags =
32)) Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 32))
Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 0))
Or _
((lParam.vkCode = 91) AndAlso (lParam.flags = 1))
Or _
((lParam.vkCode = 92) AndAlso (lParam.flags = 1))
End Select

If blnEat = True Then
Return 1
Else
Return CallNextHookEx(0, nCode, wParam, lParam)
End If
End Function
Friend WithEvents lblInfo As System.Windows.Forms.Label
End Class

hopefully somebody can help me!
thanks daFritz

----== 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 15 '05 #7

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

Similar topics

1
by: Salim Ansari via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Salim Ansari Can anybody please give me sample code in C# to use keyboard hooks in C#? THat would be a great help. Thanks in...
7
by: Don Riesbeck Jr. | last post by:
I'm working on an application (OEM) using C# that utilizes input from a keyboard, and USB Barcode Scanner. The scanner is a HID Keyboard device, and input from it is sent to the system as if it...
1
by: Jigar mehta | last post by:
Hye, How to create systemwide hooks for keyboard for keys like WIN, ALT+TAB, CTRL+ALT+DEL even when the application does not have the focus on it... Thanks,
2
by: Christoph Brüser | last post by:
Hi, in my application I want to react to certain keys when a context menu is showing. So I installed a keyboard hook, but now whenever a key is pressed when the menu is showing, the application...
2
by: genojoe | last post by:
I have a Windows form application running that contains a button and textbox. An easy thing to do is to monitor the last time a keystroke was executed in the textbox. I can then click the button...
7
by: jpierson | last post by:
Hi, I am tryin to create a keyboard hook that sends the keystroke ctrl + pause/break. I haven't used keyboard hooks before so I'm not too sure how to use them public int MyKeyboardProc(int...
13
by: Hema | last post by:
hello all, I am working on a project related to Internet Explorer. I want my application to be invoked by a keypress( single key stroke or a combination). But this must get invoked only when the...
0
by: priya | last post by:
hello, I want to add a keyboard hook to my application.This should be detected only from IE.I searched on this and found the IEAccessible_final_sem_doc in the following link:...
9
by: Kbalz | last post by:
I have an application that minimizes itself, and I want it to listen for certain key commands, and when they are pressed, my program can react to them. So far I've gotten my application to react...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.