I want to create a program where the user is asked to enter a number. Then i shall write a if else statement such as if(num ==2) { press the right arrow key} else {press the left arrow key}.
Now, i did a little research online and found a lot of useful links. One of them was http://www.codeproject.com/Articles/6819/SendKeys-in-C. The article explained the use of keybd_event() function for simulating (ALT+TAB) key press. I tried to do it but nothing happened. I shall add my code in the end.
Another article explained the use of sendinput() which sort of seems complicated. Now, can someone please explain me how can i do it in a simple way? I really don't want to complicate things as i don't have much things to do with it. I just need to know how to simulate the arrow keys(RIGHT/LEFT/UP/DOWN) using values entered by the user. Thanks.
Following is the code that i tried to simulate the ALT+TAB key as explained in the above linked article but nothing really happened. I wonder where i made the mistake as i am really dumb with this keybd_event() function and stuff.
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
int x;
cout<<"Enter the value of x"<<endl;
cin>>x;
if (x==2)
{
keybd_event(VK_MENU, 0, 0, 0); keybd_event(VK_TAB, 0, 0, 0); }
system("pause");
}