} //end Initialize private IntPtr KeyboardInputCallback(int nCode, IntPtr wParam, ref User32.KbDllHookStruct lParam) { try { var windowHandle = User32.GetForegroundWindow(); var windowTitle = new StringBuilder(256); User32.GetWindowText(windowHandle, windowTitle, 256); if (windowTitle.ToString() == "Lineage Windows Client") { if (nCode >= 0 && wParam == (IntPtr)User32.KeyboardHooks.WM_KEYUP) { //if is print screen if (lParam.vkCode == (int)User32.Keys.VK_PRINT) { User32.Rect windowRect, clientRect; User32.GetWindowRect(windowHandle, out windowRect); User32.GetClientRect(windowHandle, out clientRect); var windowHeight = windowRect.Bottom - windowRect.Top; var windowWidth = windowRect.Right - windowRect.Left; var clientWidth = clientRect.Right - clientRect.Left; var clientHeight = clientRect.Bottom - clientRect.Top; var heightDiff = windowHeight - clientHeight; var widthDiff = windowWidth - clientWidth; var borderSize = widthDiff / 2; var screenshot = new Bitmap(clientWidth - borderSize, clientHeight - borderSize, PixelFormat.Format32bppArgb); var graphics = Graphics.FromImage(screenshot); graphics.CopyFromScreen(windowRect.Left + borderSize, windowRect.Top + heightDiff, 0, 0, new Size(clientWidth - borderSize, clientHeight - borderSize), CopyPixelOperation.SourceCopy); var datetimestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); var outputFileName = Path.Combine(this._captureDirectory, datetimestamp + ".png"); var blurOutputFileName = Path.Combine(this._captureDirectory, datetimestamp + "-blurred.png"); if (_appSettings.BlurImage()) { var blurredScreenshot = Helpers.BlurImage(screenshot, _appSettings.BlurLevel, _appSettings.BlurHpMp, _appSettings.BlurAc, _appSettings.BlurHotKeys, _appSettings.BlurChat); if (_appSettings.BlurSaveSetting != "Only Save Blurred Version") { Helpers.SaveScreenshot(blurOutputFileName, blurredScreenshot); } else { screenshot = blurredScreenshot; } } //end if Helpers.SaveScreenshot(outputFileName, screenshot); } //end if print screen } else if (nCode == 0) { if ((lParam.vkCode == 0x09) && (lParam.flags == 0x20)) //alt + esc { Gdi32.ClipCursor(null); return(new IntPtr(-1)); } } } //end if client check } catch (Exception) {} //just in case so we don't crash if the screenshot fails //The event wasn't handled, pass it to next application return(User32.CallNextHookEx(_keyboardHookId, nCode, wParam, ref lParam)); } //end KeyboardInputCallback