3

I'm trying to implement a simulation of pressing a key (backspace) using Virtual-Key Codes. Running the code while a text file is open works as expected (deletes the text), but running it while Win 8 photo App is open does not do anything (I would expect it to go up one level to the upper photo album for example).

Does anyone have an idea why? What do I need to do in order to simulate a backspace key press in Win8 photo App?

My code:

INPUT input;

input.type = INPUT_KEYBOARD;
input.ki.wScan = 0;
input.ki.dwFlags = 0;
input.ki.time = 0;
input.ki.dwExtraInfo = NULL;
input.ki.wVk = VK_BACK;

SendInput(1, &(input), sizeof(INPUT));

input.type = INPUT_KEYBOARD;
input.ki.wScan = 0;
input.ki.dwFlags = KEYEVENTF_KEYUP;
input.ki.time = 0;
input.ki.dwExtraInfo = NULL;
input.ki.wVk = VK_BACK;

SendInput(1, &(input), sizeof(INPUT));
eskadi
  • 245
  • 3
  • 17
  • "I would expect" "for example" Instead of these vague, non-committal phrases, can you confirm that pressing backspace in "Win 8 photo App" performs the action you're expecting? – Lightness Races in Orbit Jan 12 '14 at 14:16
  • I am sorry I was vague. While pressing backspace in Win8 Photo App you go up one level, that is why that's what I am expecting to happen when I simulate it. – eskadi Jan 12 '14 at 14:24
  • You are setting the [`uiAccess="true"`](http://msdn.microsoft.com/en-us/library/bb756929.aspx) property, signing your code and putting it into the correct location? – Anya Shenanigans Jan 13 '14 at 12:28
  • I am writing a simple c++ application. Is the uiAccess property is relevant in this kind of application? – eskadi Jan 16 '14 at 06:32
  • 1
    Your code works for me in a plain console C++ application and Windows 8.1 Update 1 "Photos" app. – Yirkha Apr 17 '14 at 01:50
  • 1
    I believe your question is answered in this thread: http://stackoverflow.com/questions/18647053/sendinput-not-equal-to-pressing-key-manually-on-keyboard-in-c – NiRR Jun 02 '14 at 05:40

0 Answers0