473,664 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting keypress when form is inactive (no focus)

Hi,
I was working on a screen capturing application which must do its work
when a key (eg: CTRL) is pressed while the application is resides in
tray as a notification icon.

I mean, while my application resides as a notification icon, it must
do the work when a specific key is pressed such as CTRL.

Is it possible to work for an app which hasn't got focus and which is
inactive?

Note: I've done capturing coding part, the thing i want to do is to
implement a kind of keypress listener while user exploring other
windows and my program is inactive as well, but is in the tray bar as
notify icon as minimized.

A good example for my question is that program:
http://www.wisdom-soft.com/downloads...hunterfree.zip

Thanks!
Jan 2 '08 #1
5 6421
"kimiraikko nen" <ki************ *@gmail.comschr ieb
Hi,
I was working on a screen capturing application which must do its
work when a key (eg: CTRL) is pressed while the application is
resides in tray as a notification icon.

I mean, while my application resides as a notification icon, it must
do the work when a specific key is pressed such as CTRL.

Is it possible to work for an app which hasn't got focus and which
is inactive?

http://msdn2.microsoft.com/en-us/lib...89(VS.85).aspx

(look for keyboard hooks)
Armin
Jan 2 '08 #2
On Jan 2, 4:17 pm, "Armin Zingler" <az.nos...@free net.dewrote:
"kimiraikko nen" <kimiraikkone.. .@gmail.comschr ieb
Hi,
I was working on a screen capturing application which must do its
work when a key (eg: CTRL) is pressed while the application is
resides in tray as a notification icon.
I mean, while my application resides as a notification icon, it must
do the work when a specific key is pressed such as CTRL.
Is it possible to work for an app which hasn't got focus and which
is inactive?

http://msdn2.microsoft.com/en-us/lib...89(VS.85).aspx

(look for keyboard hooks)

Armin
So you say i need to call Windows API a kind of p/invoke? This link
contains no VB example so i don't know how to declare and which Proc
type i must use.
Jan 2 '08 #3
On Jan 2, 9:46 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
On Jan 2, 4:17 pm, "Armin Zingler" <az.nos...@free net.dewrote:
"kimiraikko nen" <kimiraikkone.. .@gmail.comschr ieb
Hi,
I was working on a screen capturing application which must do its
work when a key (eg: CTRL) is pressed while the application is
resides in tray as a notification icon.
I mean, while my application resides as a notification icon, it must
do the work when a specific key is pressed such as CTRL.
Is it possible to work for an app which hasn't got focus and which
is inactive?
http://msdn2.microsoft.com/en-us/lib...89(VS.85).aspx
(look for keyboard hooks)
Armin

So you say i need to call Windows API a kind of p/invoke? This link
contains no VB example so i don't know how to declare and which Proc
type i must use.
I have seen a few articles on codeproject.com about using key hooks.
You might try searching there for some examples:

http://www.codeproject.com/info/sear...ey+hook&sbo=kw

Thanks,

Seth Rowe [MVP]
Jan 2 '08 #4
You either need to install a system wide keyboard hook in C++ (not very
smart, and a little tricky) or register a hot key.
Here's how to register a hot key in .NET.
http://www.dotnet2themax.com/ShowCon...0-c2bb7075ba78
Otherwise do a search for SetWindowsHookE x API and prepare to get your hands
dirty. :-)
"kimiraikko nen" <ki************ *@gmail.comwrot e in message
news:f4******** *************** ***********@j20 g2000hsi.google groups.com...
Hi,
I was working on a screen capturing application which must do its work
when a key (eg: CTRL) is pressed while the application is resides in
tray as a notification icon.

I mean, while my application resides as a notification icon, it must
do the work when a specific key is pressed such as CTRL.

Is it possible to work for an app which hasn't got focus and which is
inactive?

Note: I've done capturing coding part, the thing i want to do is to
implement a kind of keypress listener while user exploring other
windows and my program is inactive as well, but is in the tray bar as
notify icon as minimized.

A good example for my question is that program:
http://www.wisdom-soft.com/downloads...hunterfree.zip

Thanks!
Jan 3 '08 #5
On Jan 3, 12:06 pm, "CMoya" <m...@nospam.co mwrote:
You either need to install a system wide keyboard hook in C++ (not very
smart, and a little tricky) or register a hot key.
Here's how to register a hot key in .NET.http://www.dotnet2themax.com/ShowCon...7a-0323-47eb-b...
Otherwise do a search for SetWindowsHookE x API and prepare to get your hands
dirty. :-)

"kimiraikko nen" <kimiraikkone.. .@gmail.comwrot e in message

news:f4******** *************** ***********@j20 g2000hsi.google groups.com...
Hi,
I was working on a screen capturing application which must do its work
when a key (eg: CTRL) is pressed while the application is resides in
tray as a notification icon.
I mean, while my application resides as a notification icon, it must
do the work when a specific key is pressed such as CTRL.
Is it possible to work for an app which hasn't got focus and which is
inactive?
Note: I've done capturing coding part, the thing i want to do is to
implement a kind of keypress listener while user exploring other
windows and my program is inactive as well, but is in the tray bar as
notify icon as minimized.
A good example for my question is that program:
http://www.wisdom-soft.com/downloads...hunterfree.zip
Thanks!
Cmoya, that link was "awesome" very thanks, but i need to add
something to facilitate people's work who are searching similiar help.

One thing is missing in article:

If you do not use "Imports System.Runtime. InteropServices " as
declaration, you get "marshal is not declared" error as well. After
this addition, it works.

Thanks.
Jan 3 '08 #6

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

Similar topics

1
1668
by: Paul Tsai | last post by:
Dear All, I used csharp web form to develop my company web application, and my question is how shuld I do if I want to focus on my textbox(ex. like Java Script form.txtID.focus()). Thanks !! Sincerely yous, Paul
3
2261
by: Gidi | last post by:
Hi, Is it possible to know when TextBox loses focus to which object it lost it? what i mean is when the LostFocus Event occur is it possible to know which object got the focus instead? thanks,
1
6055
by: guy | last post by:
Is it possible to select all text in a asp text box when it gets focus? How?
3
2343
by: Chris | last post by:
I have a form that calls ShowDialog on a number of different forms at different times. I want to be able to know anytime the form loses focus. But Form.Focused isn't ever true once a control has focus and Form.Leave does not fire when showdialog is called on another form. Anyone have any idea how to capture the form losing focus? Chris
2
1569
by: krunalK | last post by:
hi I am working on window appication. and i have put a shortcut key for different action like say F1 is press then new record etc like that now when i have focus in datagrid i am getting keydown when working in datagrid cell so i am not getting which key is pressed and am not able to make my shortcut working. plz give me some solution
3
2598
by: papalarge | last post by:
I have a VB.NET application that consists of a toolbar and a subwindow that I want to function together and not independently. So when I give focus to one, I want to make sure that the other is visible on the screen (brought to front, right behind the one in focus). I've played with the activated event of each form, but everything I've tried so far fails, as it's a pretty cyclical process that gets initiated. I'd love any help......
1
4169
by: Manikandan | last post by:
Hi, I have a form with progress bar. I'm querying sql server with large number of records(around 1 lakh) for export The records are written to a text file I'm showing the process running by updating the progress bar If the form loses focus(i.e selecting any other application) means progress bar is not updating The coding is below
3
2656
by: =?Utf-8?B?SmVzc2U=?= | last post by:
I have searched and searched, with no luck. I have a Form that has several event listeners in it (Keypresses, speech recognition, afew others). When I click a component in the form (such as a button), the form itself loses focus. How can I get it back? I have tried this.Focus() from w/in the form in a timer with no luck as well as several other things. Thanks!
1
1316
by: dotnutshell | last post by:
I need to work out wether my windows form has focus of the mouse and keyboard. My project is the following: 2 or more applications. 1 application is a controller talking to some hardware The client application are connected using a named pipe or .NET remoting. When an event occurs on the hardware, the controlling process also sends the events to the clients which are connected. Now the clients could be numerous, but I only want the...
0
8348
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
8861
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
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
8636
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
7375
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
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
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.