Beispiel #1
0
//------------This-function-is-repeatedly-called-this-executes-when-a-key-is-pressed-on-the-keyboard---/
LRESULT EXPORTED_DLL_FUNCTION kbdHookProc_Hemavathi(int nCode,WPARAM wParam,LPARAM lParam)
{
    if(nCode<0)												//---Do not process further if a system key is pressed---//
    {
        return CallNextHookEx (ghKeyHook,nCode,wParam,lParam);   //---Call the next hook procedure in the hook chain---//
    }
    if(nCode==HC_NOREMOVE)
    {
        return CallNextHookEx (ghKeyHook,nCode,wParam,lParam);
    }

    char ch;
    BYTE ks[256];                                //---a byte for getting the keyboard ststus---//
    WORD w;										 //---a word for holding the character value of the key---//
    //pressed used by the ToAsccii where the value is set into this---//
    UINT scan=0;
    ::GetKeyboardState(ks);
    ::ToAscii(wParam,scan,ks,&w,0);
    ch = char(w);


    if(isspace(ch))
    {
        kFlag.c_bit = FALSE;
        kFlag.found = FALSE;
        kFlag.s_bit = TRUE;
    }


    if((GetKeyState(VK_SCROLL ) & 0x0001))
    {
        if(isalpha(ch) || ispunct(ch) || isdigit(ch) )											 //---If key is pressed and is not a control key---//
        {
            //::MessageBox(NULL,"bgfbg","bgfbgfb",MB_OK);
            if((lParam & 0x80000000) == 0x00000000)   //---If key is pressed and is not a control key---//
            {
                FindCharacters(ch);									//---Find the glyph code--//
                PushBackspaces();
            }
            else // key released
            {
                PushKeys();
                return TRUE;
            }
        }

        if( (isalnum(ch) || ispunct(ch)) &&!(GetKeyState(VK_MENU) & 0x80))    //---If the key pressed is a alpha key and when not
        {   //---- Alt is down posts only the the promted message--//
            return TRUE;
        }
        else
        {
            return CallNextHookEx(ghKeyHook,nCode,wParam,lParam);
            //---Call the next hook procedure in the hook chain---//
        }

    }

    return CallNextHookEx(ghKeyHook,nCode,wParam,lParam);
}
Beispiel #2
0
LRESULT EXPORTED_DLL_FUNCTION callWndRetProc(int nCode,WPARAM wParam,LPARAM lParam)
{
	if(nCode<0)
	{
		return CallNextHookEx(ghCallWndProcRetHook,nCode,wParam,lParam);
	}

	CWPRETSTRUCT *p=(CWPRETSTRUCT*)lParam;
	if(p->message==WM_KEYDOWN)
	{
		if(p->wParam==VK_BACK)
		{
			PushKeys();
		}
	}
		LRESULT ret=CallNextHookEx(ghCallWndProcRetHook,nCode,wParam,lParam);

	return ret;
}
Beispiel #3
0
//-----------------------------------------------------------
//entry point for component
void DoPushKeys(TPushKeys* TPK,CString keys)
{
	//set DOS flag
	DOSKey=TPK->UseANSI;

	//set global access
	GTPK=TPK;

	//extract {}} }}} {{{ {} 4} type thing
	bool lb=false, rb=false;
	CString tv="";
	int lastbrace=-1;
	int cnt=0;
	for (int i=1;i<=keys.GetLength();i++)
	{
		char sc=keys[i];

		if (sc=='{')
		{
			//if processed left brace last then delete
			if (!lb)
			{
				lb=true;
				rb=false;
				tv+=sc;
				cnt++;
				lastbrace=cnt;
			}
		}
		else if (sc=='}')
		{
			//ditto for right brace (or left brace not previous)
			if (!rb && lb && cnt-lastbrace>1)
			{
				rb=true;
				lb=false;
				tv+=sc;
				cnt++;
			}
		}
		else
		{
			tv+=sc;
			cnt++;
		}
	}


	//orphan {
	if (lb)
	{
		tv.Delete(lastbrace,1);
	}

	//delete trailing
	int tvl=tv.GetLength();
	if (tv>0)
	{
		if (tv[tvl]=='{')
		{
			tv.Delete(tvl,1);
		}
	}

	keys=tv;

	//call appropriate routine
	if (DOSKey)
	{
		PushDOSKeys(keys);
	}
	else
	{
		PushKeys(keys);
	}
}