I need my WPF application to gain focus whenever the user press "window key + s".
My solution was to hook to the keyboard event with SetWindowsHookEx. however the handle I get in return is always 0. when I call to GetLastWin32Error the value is also 0 (i.e. so it actually reports that the previous operation succeeded)
_hookHandle = SetWindowsHookEx(WH_KEYBOARD_LL, _hookFunction, _hinstance, 0);
if (_hookHandle == IntPtr.Zero)
throw new Win32Exception(Marshal.GetLastWin32Error());
(It goes without saying that _hinstance has a valid value and so does _hookFunction)
Any Ideas? other solutions?
Thanks.