Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
im building a program (form app)

i need the program to detemine a combination of two keys while its minimized to system tray.

the combination may be any Two key on the keyboard(determeind by the user)but they have to be pressed togater(pritty much at the same way u do ctrl+s to save)

theres a database of key combos but i still need to responde to every key press to compare it to the database.

Thank you in advance, Tsahi.



Edit: Additional information moved from "no solution" here

let me focus u guys on my first problem,

I need to do make an Event of key down WHILE the program is minimized to system tray (the program will run at the Background, its an ultility\support program)

the second thing (which is less complicated for me) is to find a way to capture some key combination.

Tsah.
Posted
Updated 24-Apr-12 11:09am
v2
Comments
Sandeep Mewara 23-Apr-12 1:25am    
And what exactly your question is? Where are you stuck?
tsahi-al 23-Apr-12 3:39am    
i just dont find a way to do all these things at once, i need to keep track on the keys while it at systemtray, i meneged to get only 1 key but only when the form is opened

<pre lang="c#"> private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (selectKey == true)
{
firstKey = e.KeyChar.ToString();
MessageBox.Show(firstKey);
selectKey = false;
labelError.Visible = false;
}
</pre>
[no name] 24-Apr-12 15:12pm    
I believe that the term you are searching for is "global keyhook"
Nelek 24-Apr-12 17:11pm    
Please don't add solutions to give more information about your problem. Use "improve question" to add it to you original post or click on "have a question or comment" if what you want to directly comunicate with someone that wrote you
tsahi-al 24-Apr-12 17:32pm    
Nelek, ur right, im sorry.

Wes Aday, What global hooks are?
I just started to read about them but I'm not counting on them, some anti virus might see the program im building as a KeyLogger and dispose it, am i right?

how do i use them? what r they? a referenc? or a third party programs?
i read about it in this site at : http://www.codeproject.com/Articles/1264/KeyBoard-Hooks
please explain abit more, i heavent find alot of information about this subject.
I'm just stuck with this program for about a week and I need to finish it in a few days.

Ive found this Low level hook may some one please help me analize the code(i wish to learn some more about it.)

http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx

Tsahi.

I don't know how to get hotkey pressed event in C#. But in C++, there're 2 way that I know:
- Use GetAsyncKeyState API function
- Use SendMessage API function with WM_SETHOTKEY message
Sorry for my English :)
 
Share this answer
 
Comments
tsahi-al 24-Apr-12 14:05pm    
its not so helping since i need find a way to make the keydown event while the program is at system tray

maybe a BGworker may help me?
SASS_Shooter 24-Apr-12 17:15pm    
You will never get the keydown event while the program is at the system tray unless you do what vquangchung indicated: hooking into the GetAsyncKeyState or one of the other kernel level commands. You cannot do it with just your own code.
tsahi-al 24-Apr-12 21:26pm    
Ok so the queshtion is how do i get a guide or something about it, i never used Shell or kernall comands via C#, tryed to google it but i find only blury guides.
ive found a bugy version of some kind of key hooker in VB, first ive fixed the code than ive translated it to C# and now its kinda works :)
took me about 5 houers to fix and translate the code but it was worth every second :D
thank you everybody for the help :)

Tsahi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900