Global Hotkeys C# issue!

07/16/2009 15:05 byte1918#1
Hi.
I am trying to make a simple application in c#, and I need to make the hotkeys work when Conquer window has focus. I have managed to make the hotkeys work globally in windows with

Code:
public class User32
	{
		[DllImport("user32.dll")]
		public static extern bool RegisterHotKey(IntPtr hWnd,int id,int fsModifiers,int vlc);
		[DllImport("user32.dll")]
		public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
	}
the code is longer

If anyone can give me a link or something from where to start from I will be very thankful.

Thanks in advance.
07/16/2009 15:35 IAmHawtness#2
What kind of hotkeys are you talking about? The built-in Windows hotkeys, or something else?
07/16/2009 16:23 byte1918#3
Quote:
Originally Posted by IAmHawtness View Post
What kind of hotkeys are you talking about? The built-in Windows hotkeys, or something else?
Well.. I'm speaking about custom hotkeys, so far my application does what I want it to do when I press ctrl+w(my hotkey of choice) but this works only while I am in windows, if I switch the focus to conquer window (opengl) my app can't listen for the hotkey event therefor nothing happens.

I want to make the hotkey work in conquer too.

Thx for answering though.

EDIT: Just tested and it seems it works when I'm in full screen but not when I'm in window mode, and I have no idea why.
07/16/2009 17:02 IAmHawtness#4
Quote:
Originally Posted by byte1918 View Post
Well.. I'm speaking about custom hotkeys, so far my application does what I want it to do when I press ctrl+w(my hotkey of choice) but this works only while I am in windows, if I switch the focus to conquer window (opengl) my app can't listen for the hotkey event therefor nothing happens.

I want to make the hotkey work in conquer too.

Thx for answering though.

EDIT: Just tested and it seems it works when I'm in full screen but not when I'm in window mode, and I have no idea why.
Custom hotkeys? Like when you press ctrl+w, your program does something in CO?

If that's the case, you should try using GetAsyncKeyState API.

And if you want it only to work when the Conquer window is active, you could use GetForegroundWindow
07/16/2009 17:27 byte1918#5
Thank you very much for your answer. I will take a look and see if it works. Atm I'm happy that for some odd reason my application works when in full screen. I usually play co in window mode, but when I'll use the app I will play in full screen mode and that's at gw, once per week. Btw it's not something worth releasing, it's just basic stuff anyone could do with enough spare time :P.

ty one more time.