/*** This file belongs to the Gotcha! distribution. Copyright (C) 1998-2002 Thorsten Thielen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***/ #define INCL_WIN #define INCL_DOS #include #include "../id.h" //#define __PMPRINTF__ //#include "PMPRINTF.H" /* pre-accelerator input hook, undocumented, */ #define HK_PREACCEL 17 HAB habDLL; HWND hwndFrame; HMODULE hMod; BOOL usePMps; void EXPENTRY InitDLL (HAB hab, HWND hwnd, BOOL g_usePMps) { habDLL = hab; hwndFrame = hwnd; usePMps = g_usePMps; DosLoadModule (NULL, 0, "GOTCHDLL", &hMod); } BOOL EXPENTRY InputProc (HAB hab, PQMSG pqmsg, ULONG ul) { USHORT usFlags; USHORT usScan; if (pqmsg->msg != WM_CHAR || (usFlags = SHORT1FROMMP(pqmsg->mp1), usScan = SHORT2FROMMP (pqmsg->mp2), (usFlags & KC_SCANCODE)) == 0){ return FALSE; } if (CHAR4FROMMP(pqmsg->mp1) == 0x54 ) { if (usFlags & KC_KEYUP) { WinPostMsg (hwndFrame, WM_COMMAND, MPFROM2SHORT (WID_PB_SETTINGS,0), 0); /*DosBeep( 1000, 10 ); DosBeep( 2000, 20 ); DosBeep( 3000, 30 ); */ return TRUE; } else { /* DosBeep( 3000, 30 ); DosBeep( 2000, 20 ); DosBeep( 1000, 10 );*/ return TRUE; } } else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 ) && (usFlags & KC_CTRL)) { if (usFlags & KC_KEYUP) { WinPostMsg (hwndFrame, WM_COMMAND, MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), MPFROMLONG(1)); return TRUE; } } else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 ) && (usFlags & KC_SHIFT)) { if (usFlags & KC_KEYUP) { WinPostMsg (hwndFrame, WM_COMMAND, MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), 0); return TRUE; } } else if (!usePMps && (usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 )) { if (usFlags & KC_KEYUP) { WinPostMsg (hwndFrame, WM_COMMAND, MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), 0); return TRUE; } } return FALSE; } void EXPENTRY StartInputHook (void) { WinSetHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod); } void EXPENTRY StopInputHook (void) { WinReleaseHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod); DosFreeModule (hMod); } USHORT Version (VOID) { return 2; }