Please explain this program

Can somebody explain this program line by line in simple words
i am new to c and c++
so i just know about basics
i want to know about the keywords and functions and what they are doing in this code.

#define WINVER 0x0500
#include <windows.h>

int main()
{

ShowWindow(FindWindowA("ConsoleWindowClass", NULL), false);



INPUT ip;

Sleep(5000);


ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0;
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;


ip.ki.wVk = 0x5B;
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));


ip.ki.wVk = 0x52;
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));


ip.ki.wVk = 0x5B;
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));


ip.ki.wVk = 0x52;
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));


return 0;
}

[/code]
#define WINVER 0x0500 //a hex constant for what version of windows this was built under.
#include <windows.h> //pull in windows specific (NOT C++!!!!) libraries.

int main() //program starts here, this is the entry point.
{

ShowWindow(FindWindowA("ConsoleWindowClass", NULL), false);
//windows specific gui function call to show a window.


INPUT ip; //defines a variable of a nonstandard type. windows code is full of nonstandard types.

Sleep(5000); //do absolutely nothing for 5000 units, probably miliseconds, this is not the standard sleep but a windows one I think.


ip.type = INPUT_KEYBOARD; //windows specific stuff follows, nothing c++ here, this is pure Microsoft gibberish.


ip.ki.wScan = 0;
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;


ip.ki.wVk = 0x5B;
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));


ip.ki.wVk = 0x52;
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));


ip.ki.wVk = 0x5B;
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));


ip.ki.wVk = 0x52;
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));


return 0; //end of main. tell the operating system the program is done successfully.
}

this is a terrible program to learn c++ language; its almost 100% GUI nonstandard stuff. Almost no keywords or language items in it!!!
Last edited on
thank you Jonnin. for your help

but i also want to know about these line

ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0;
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;

can you please suggest me something to understand these lines....
Topic archived. No new replies allowed.