473,802 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

keyboard hooks in C#

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 IE browser is
open. I learnt that SetWindowsHookE x must be used along with few
others. But my doubt is how to call my application? Can i implement the
keyboard hooks related methods in the same project as my application or
should this be else where(i.e as a new project)? wats the difference
between the keyboard hooks and hot keys... i have been serching abt
this for a long time that right now i am confused.
I am new to .NET and all these window hooks. Please help me.
thanks,
hema

Apr 1 '06 #1
13 3200
Your app has a dependency upon Internet Explorer. This means that you should
probably build your app so that it launches Internet Explorer when it
starts, rather then depending upon the user to launch Internet Explorer.
Otherwise, this is not something that you can fix by modifying your app, as
your app hasn't started yet before Internet Explorer is required to be
launched.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Hema" <he*********@ya hoo.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
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 IE browser is
open. I learnt that SetWindowsHookE x must be used along with few
others. But my doubt is how to call my application? Can i implement the
keyboard hooks related methods in the same project as my application or
should this be else where(i.e as a new project)? wats the difference
between the keyboard hooks and hot keys... i have been serching abt
this for a long time that right now i am confused.
I am new to .NET and all these window hooks. Please help me.
thanks,
hema

Apr 1 '06 #2
Hello, Kevin!

KS> Your app has a dependency upon Internet Explorer. This means that you
KS> should probably build your app so that it launches Internet Explorer
KS> when it starts, rather then depending upon the user to launch Internet
KS> Explorer. Otherwise, this is not something that you can fix by
KS> modifying your app, as your app hasn't started yet before Internet
KS> Explorer is required to be launched.

The solution here can be Browser Helper Object, that will 'live' inside IE and notify main app about different events.


--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 1 '06 #3
hi,
Thanks for the reply! let me explain my project to u first. This is
called Talkative Browser. I have added a button to the IE toolbar. When
the button is pressed,it retrieves the URL of the current web page and
then extracts the HTML source code.From this the Text area is parsed
and sent to MS speech engine to be read out. This is working well with
button click. I want the same functionlity getting invoked when i press
a key. my questions are:
1.is it possible to add a keyboard hook to this project.
2.i cant jus invoke IE , its not my functionality, only after a URL is
launched i can make it speak.so how do i proceed in here.
3.My query earlier was how to add the hook procedure function to the
SetWindowsHookE x in this case. The work starts only after the button is
pressed. i.e Exec of IOleCommandTarg et initiates the work after the
button click.

this is my problem.Once again thanks for the reply.
Hema

Apr 1 '06 #4
Yeah, I misunderstood the question. I thought he meant that his app must
start up IE in order to work. It sounds more like he wants to add a keyboard
shortcut to IE to start his app.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Vadym Stetsyak" <va*****@ukr.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hello, Kevin!

KS> Your app has a dependency upon Internet Explorer. This means that you
KS> should probably build your app so that it launches Internet Explorer
KS> when it starts, rather then depending upon the user to launch Internet
KS> Explorer. Otherwise, this is not something that you can fix by
KS> modifying your app, as your app hasn't started yet before Internet
KS> Explorer is required to be launched.

The solution here can be Browser Helper Object, that will 'live' inside IE
and notify main app about different events.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Apr 1 '06 #5
Hi Hema,

The following articles may be helpful:

http://www.codeproject.com/system/hooksys.asp
http://www.codeproject.com/csharp/globalsystemhook.asp

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Hema" <he*********@ya hoo.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
hi,
Thanks for the reply! let me explain my project to u first. This is
called Talkative Browser. I have added a button to the IE toolbar. When
the button is pressed,it retrieves the URL of the current web page and
then extracts the HTML source code.From this the Text area is parsed
and sent to MS speech engine to be read out. This is working well with
button click. I want the same functionlity getting invoked when i press
a key. my questions are:
1.is it possible to add a keyboard hook to this project.
2.i cant jus invoke IE , its not my functionality, only after a URL is
launched i can make it speak.so how do i proceed in here.
3.My query earlier was how to add the hook procedure function to the
SetWindowsHookE x in this case. The work starts only after the button is
pressed. i.e Exec of IOleCommandTarg et initiates the work after the
button click.

this is my problem.Once again thanks for the reply.
Hema

Apr 1 '06 #6
Hello,
Thanks for the links u have provided me.I went thru them.The second article
on Global hooks was very useful.I understood most of the stuff in there.The
first article was highly overwhelming for me. I am new to Window programming
environment and cudn't get wat was there in it. One thing i got was
something related to BHO. I have actully done my Button click invokation and
related works in IObjectWithSite and IOleCommandTarg et only. So it was
assuring in some way.

Now as for my doubts after reading the articles are these:
1.As u know, i want my application to detect the keypress after IE is opened.
How to do this? BHO?
2.Is wat i am trying to do some way related to application specific hooks?
(not surely System hooks?)
3.I learnt that SetWindowsHooks Ex, InstallHooks,.. ... are needed for my work.
How will i specify that i want the application i.e. my dll
(TalkativeBrows er.dll- the one i have developed) to get invoked with the
HookProc?
4.Should the hook procedure i will developing be in a separate project?

I might have repeated wat i have been saying in my previous queries. Sorry
abt that. Thats b'coz i am still not able to grasp the idea.

Please help me.
Thanks,
Hema
Apr 3 '06 #7
Hello,
I have used the IObjectWithSite and IOleCommandTarg et for my applciation
already.Will this hook that i am adding will come in the IObjectWithSite
again.How different is this going to be?

Thanks,
Hema
Apr 3 '06 #8
I think you are thinking along the right lines with respect to a Browser
Helper Object. There are several different ways to detect a keypress
globally, but that may not be what you really want, and since the dependency
is upon the browser, a BHO would be the most efficient that I can think of.
In addition, you may only want to detect the keypress when the browser has
the focus, which simplifies the process a great deal, since you don't really
need a system hook, but only a hook into the browser's message loop. Is that
the case?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"GEETHA" <LM**@EMAIL.COM > wrote in message
news:00******** *************** *******@ureader .com...
Hello,
Thanks for the links u have provided me.I went thru them.The second
article
on Global hooks was very useful.I understood most of the stuff in
there.The
first article was highly overwhelming for me. I am new to Window
programming
environment and cudn't get wat was there in it. One thing i got was
something related to BHO. I have actully done my Button click invokation
and
related works in IObjectWithSite and IOleCommandTarg et only. So it was
assuring in some way.

Now as for my doubts after reading the articles are these:
1.As u know, i want my application to detect the keypress after IE is
opened.
How to do this? BHO?
2.Is wat i am trying to do some way related to application specific hooks?
(not surely System hooks?)
3.I learnt that SetWindowsHooks Ex, InstallHooks,.. ... are needed for my
work.
How will i specify that i want the application i.e. my dll
(TalkativeBrows er.dll- the one i have developed) to get invoked with the
HookProc?
4.Should the hook procedure i will developing be in a separate project?

I might have repeated wat i have been saying in my previous queries. Sorry
abt that. Thats b'coz i am still not able to grasp the idea.

Please help me.
Thanks,
Hema

Apr 3 '06 #9
hello kevin,
this is Geetha only.I have got some problem with the logging in with my id,..
.. dont know the problem,since i am due to complete my project in few days, i
have created this id.Sorry for the trouble.

Has for the question u have asked.If u mean to say that this message loop
means informing the browser that my application must be invoked when a key
is pressed,then yes thats wat i want.

i have started with the BHO stuff.i think i will call the Hooks related
functionalities i.e. Installhook in IObjectWithSite .SetSite(). then it will
go on as a normal keyboard hook.But how will i call my application's dll
from the HookProc available? mine is not a function right. My application
also uses this same interface to do further processing.i dont know how to do
this and i am struck here.

Hope u get my id and reply back.
Thanks and regards,
geetha
Apr 4 '06 #10

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

Similar topics

1
3135
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 advance Salim -----------------------
7
10697
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 were a keyboard. I need to be able to identify input from the scanner and keyboard independently. I've looked at DirectX.DirectInput, and using user32.dll to hook into the keyboard messages, but neither method seems to allow for identification of...
1
1479
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
5434
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 crashes and sometimes throws a NullReferenceException in system.windows.forms.dll. I assume that the hook somehow messes up the context menu's message loop or something like this. I also had this problem with a mouse hook, so i guess its a...
2
3534
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 and it will say: "The last keystroke in the textbox was 10 minutes ago." This is not what I want to do. What I would like to see is a message that says: "The last keystroke in any running application on this computer was 23 minutes ago." My...
7
26544
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 nCode, int wParam, int lParam) {
0
1186
by: Hema | last post by:
Hi all, I have developed a BHO that installs low level keybaord hooks and CBT hooks globally whenever IE is opened.The keys that are pressed when IE is active are to be captured.I am trying to check whether the IE is active first, If it is i set a boolean flag.In the key hook proc ,if the flag is set, the keys are sent for further processing.The keyboard hooks is working fine(when checked separately), but the CBT hooks is not working...
9
10982
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 as I intend while the program has focus, but when the application loses focus, the listening stops. I am using VS 2008 beta 2, with .net 3.5.
0
2820
by: Studlyami | last post by:
I have a simple application which includes a default window (named Window1) with no additional xaml. Window1 consists of a timerclass object which contains a timer running at 60hrz. public Window1() {//in Window1.xaml.cs MainTimerClass = new TimerClass(); //my timer class object }
0
9699
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
10305
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
10285
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
10063
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
9115
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...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.