C#中的键盘钩子 [英] keyboard hooks in C#

查看:128
本文介绍了C#中的键盘钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发一个与Internet Explorer相关的项目。我想通过按键(单键击或

组合)调用我的

应用程序。但是只有当IE浏览器打开时才能调用它。我了解到SetWindowsHookEx必须与少量其他人一起使用。但我怀疑的是如何调用我的申请?我可以在与我的应用程序相同的项目中实现

键盘钩子相关的方法,或者

这应该在哪里(即作为一个新项目)?在键盘挂钩和热键之间消耗差价

...我已经很长时间了,这很长一段时间我现在很困惑。

我不熟悉.NET和所有这些窗口挂钩。请帮帮我。

谢谢,

hema

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 SetWindowsHookEx 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

推荐答案

你的应用依赖Internet Explorer。这意味着您应该构建您的应用程序,以便在它启动时启动Internet Explorer,而不是根据用户启动Internet Explorer。

否则,这不是你可以修改你的应用程序的东西,因为

你的应用程序还没有开始之前需要Internet Explorer

推出。


-

HTH,


Kevin Spencer

Microsoft MVP

专业Numbskull


如果没有作品,请告诉我你的认证,

我将展示我的认证

* by *我的作品。


" Hema" <他********* @ yahoo.com>在消息中写道

news:11 ********************** @ i40g2000cwc.googlegr oups.com ...
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*********@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
大家好,
我正在开发一个与Internet Explorer相关的项目。我想通过按键(单键击或
组合)调用我的
应用程序。但是只有在IE浏览器打开时才能调用它。我了解到SetWindowsHookEx必须与少数其他人一起使用。但我怀疑的是如何调用我的申请?我可以在与我的应用程序相同的项目中实现与键盘钩子相关的方法,或者它应该在哪里(即作为一个新项目)?看看键盘挂钩和热键之间的区别......我已经很长时间了,这很长一段时间我现在很困惑。
我是.NET的新手这些窗口挂钩。请帮帮我。
谢谢,
hema
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 SetWindowsHookEx 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



你好,凯文!


KS>您的应用依赖于Internet Explorer。这意味着你

KS>应该建立你的应用程序,以便它启动Internet Explorer

KS>当它开始时,而不是依赖于用户启动互联网

KS>资源管理器。否则,这不是你可以解决的问题

KS>修改你的应用,因为你的应用还没有开始互联网

KS>资源管理器需要启动。


此处的解决方案可以是浏览器帮助程序对象,它将在IE中生存并通知主应用程序有关不同事件。



-

问候,Vadym Stetsyak

www: http://vadmyst.blogspot.com


hi,

感谢您的回复!让我先解释一下我的项目。这是名为Talkative Browser的
。我在IE工具栏中添加了一个按钮。当按下按钮时,它会检索当前网页的URL,然后

然后提取HTML源代码。从这里解析文本区域

并发送到MS语音引擎进行读取。这与

按钮点击效果很好。我希望在按下

键时调用相同的功能。我的问题是:

1.可以为这个项目添加一个键盘钩子。

2.i cant jus调用IE,它不是我的功能,只有在URL是

推出我可以让它说话。我该如何继续这里。

3.我之前的查询是如何将钩子程序功能添加到

在这种情况下为SetWindowsHookEx。只有在按下按钮后才开始工作。即,在点击

按钮后,IOleCommandTarget的Exec启动工作。


这是我的问题。再次感谢您的回复。

Hema


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
SetWindowsHookEx in this case. The work starts only after the button is
pressed. i.e Exec of IOleCommandTarget initiates the work after the
button click.

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


这篇关于C#中的键盘钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆