| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | hswitch |
Hi Arne,
PC> Is there a way to hook the keyboard to watch for a hot-key
PC> from a detached program?
MS> yes. just use a KBDMonitor.
AdB> But DosMonReg requires a session number, and then works only for that
AdB> session... Is there a way to make it work for all sessions?
Place a hook in a .DLL.
Below is an example which monitors mousemoves, independent of which program
is on top. Since the time in the hook procedure must be as short as
possible, an event semaphore is used to signal back to the main program,
which takes the actions:
#define SEM_MOUSEMOVE "\\SEM32\\MOUSEMV"
// In e.g. HookDll.Dll
/*****************************************************************************
Hook which monitors mouse moves
****************************************************************************/
BOOL _export EXPENTRY RecordHook(HAB hab, PQMSG pqmsg, USHORT fs)
{
static int Count;
USHORT ErrorFlag;
static HEV SemMouseMove;
if(pqmsg->msg == WM_MOUSEMOVE)
{
Count++;
if(Count==25) // Wait for 25 mousemove events
{
Count=0;
ErrorFlag=DosOpenEventSem(SEM_MOUSEMOVE,&SemMouseMove);
if(!ErrorFlag)
{
ErrorFlag=DosPostEventSem(SemMouseMove);
ErrorFlag=DosCloseEventSem(SemMouseMove);
}
}
}
return(FALSE); // Operation has ended, so originator may continue
}
// In the main program
MODULE ModuleHandle; // Handle for input hook
DosQueryModuleHandle("HookDll.dll",&ModuleHandle);
// Set an input hook
WinSetHook(hab, NULLHANDLE, HK_INPUT, (PFN)RecordHook, ModuleHandle);
... (and an WaitEventSem() in a seperate thread)
Bye, Johan.
--- The-Box Point 0.15+ PC
* Origin: johan{at}bitbike.com - CIS: 100120,2502 (2:283/512.16)SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 @PATH: 283/512 280/801 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.