Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

how does SendInput work in AHK vs win c++


  • Please log in to reply
No replies to this topic
place
  • Members
  • 34 posts
  • Last active: Oct 02 2014 04:43 AM
  • Joined: 18 Jan 2011

so i'm trying to send keystrokes to League of legends and in AHK it's simple enough just to do

SendInput, {ENTER}

and in c++ i've done something like this

#include "Windows.h"

void sendEnterKey();

void main() {
        sendEnterKey();
}

void sendEnterKey() {
	//define INPUT variable
	INPUT input;
	WORD vkey = VK_RETURN;
	input.type = INPUT_KEYBOARD;
	input.ki.wScan = MapVirtualKey(vkey, MAPVK_VK_TO_VSC);
	input.ki.time = 0;
	input.ki.dwExtraInfo = 0;
	input.ki.wVk = vkey;
	input.ki.dwFlags = 0;

	//simulate key down
	SendInput(1, &input, sizeof(INPUT));

	//simulate key up
	input.ki.dwFlags = KEYEVENTF_KEYUP;
	SendInput(1, &input, sizeof(INPUT));
}

But only the AHK code will work, and by work i mean; will make the chat box pop up or down when loaded into a LoL game.

 

can anyone explain what's going on? from the research i've done i hear it might be something to do with DirectInput.

 

also as a side note. if i try and send for example the letter 'M' using both methods to league of legends when the chat box IS already up, both then work. it's only keys such as Enter, Escape and all other game hotkeys that dont work using the C++ sendinput (or sendmessage for that matter)