// Called whenever user presses a keyboard key.
// Checks whether poe is running, if so checks item on hotkey pressed and evaluates it.
LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ){
	char pressedKey;
	// Declare a pointer to the KBDLLHOOKSTRUCTdsad
	KBDLLHOOKSTRUCT *pKeyBoard = (KBDLLHOOKSTRUCT *)lParam;
	switch( wParam )
	{
	case WM_KEYDOWN: // When the key has been pressed down
		{
		//get the key code
		pressedKey = (char)pKeyBoard->vkCode;
		if ((pressedKey == -94) || (pressedKey == -93)){	//Ctrl
			CtrlPressed = TRUE;
		}
		}
		break;
	case WM_KEYUP: 
       {
		//get the key code
        pressedKey = (char)pKeyBoard->vkCode;
		if ((pressedKey == -94) || (pressedKey == -93)){	//Ctrl
			CtrlPressed = FALSE;
		}else if (pressedKey == 68){	//d){
			if (CtrlPressed && IsPoEActive()){
				POINT p;
				GetCursorPos(&p);
				//Copy item to clipboard
				ItemToClipboard();
				//Read from Clipboard
				Sleep(5);
				HANDLE h;
				if (!OpenClipboard(NULL)){
					return CallNextHookEx( NULL, nCode, wParam, lParam);
				}
				h = GetClipboardData(CF_TEXT);
				const char* output = evaluateItem((char*)h);
				const size_t len = strlen(output) + 1;
				HGLOBAL hMem =  GlobalAlloc(GMEM_MOVEABLE, len);
				memcpy(GlobalLock(hMem), output, len);
				GlobalUnlock(hMem);
				EmptyClipboard();
				SetClipboardData(CF_TEXT, hMem);
				CloseClipboard();
				if (len > 1) {
					PressKeyboardKey(VK_RETURN);
					PressKeyboardKey(65);	//ctrl+a
					PressKeyboardKey(86);	//ctrl+v
					PressKeyboardKey(VK_RETURN);
				}else if (UseDoubleclick){
					mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0);
					mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
				}
			}
		}
		}
		break;
	}
    //
	return CallNextHookEx( NULL, nCode, wParam, lParam);
}
示例#2
0
void RppTreeWalker::evaluateItemComposite(const ItemComposite *itemComposite)
{
    if (!itemComposite)
        return;
    for (int i = 0; i < itemComposite->count(); ++i) {
        evaluateItem(itemComposite->item(i));
    }
}