Moderator            
            
            
            
                             
             
                Posts: 2502 from 2003/2/24            
            
                            
    
            
                            
                
			
				Since all MUI apps also appear as a commodity and my newest little side-project requires both hotkeys, the possibility to insert strings into the input stream and a GUI I tried to go that way.
From an old demo found on the AOS-DevCD (hotkey.c) and my own MUI-template I glued together this:
Code:
struct Hook brokerHook;
LONG BrokerHook_Func(void)
{
	struct Hook *hook = (struct Hook*)REG_A0;
//	struct Data *data = (struct Data*)hook->h_Data;
	PDB(("brokerhookn"));
	return 0;
}
struct EmulLibEntry BrokerHookfunc = {
		 TRAP_LIB, 0, (void (*)(void))BrokerHook_Func
     };
#define EVT_HOTKEY 1L
static ULONG mNew(struct IClass *cl,Object *obj,Msg msg)
{
	struct Data *data;
	ULONG bport = 0;
	char *hotkey, **ttypes;;
	if (!(obj = (Object *)DoSuperMethodA(cl,obj,msg)))
		return(0);
	GetAttr(MUIA_Application_BrokerPort,obj,&bport);
	GetAttr(MUIA_Application_Broker,obj,(ULONG*)&broker);
	(VOID*)brokerHook.h_Entry = (VOID *)&BrokerHookfunc;
	SetAttrs(obj,MUIA_Application_BrokerHook,&brokerHook,TAG_DONE);
	PDB(("%x %xn",bport,broker));
	if ((filter = CxFilter("rawkey control esc")))
	{
		PDB(("filter %xn",filter));
		AttachCxObj(broker, filter);
		/*if (sender = CxSender(broker, EVT_HOTKEY))
		{
			AttachCxObj(filter, sender);
		}*/
	}
	
	return(ULONG)obj;
}
As it is the hook is called when I change things in Exchange, but not when I hit "control ESC".
If I enable the "if (sender..." part hitting that hotkey freezes the system.
So how do connect "filter" to the broker/msgport of my app ?
How do I check which hotkey was triggered ( there will be atleast 3 in the finished app) ?