if(GetAsyncKeyState(VK_NUMPAD0)&1)
{
//code goes here
}

#include <windows.h>
int main()
if(GetAsyncKeyState(VK_NUMPAD1)&1)
bool Project = true
else
if (GetAsyncKeyState (VK_NUMPAD0)&1)
bool Project = false
if Project = true
{
for(;;){
Sleep(100);
keybd_event(VkKeyScan('z'),0,0,0);
keybd_event(VkKeyScan('s'),0,0,0);
}
return 0;
}
if Project = false
{
for(;;){
Sleep(100);
keybd_event(VkKeyScan('z'),0,0,0);
keybd_event(VkKeyScan('s'),0,0,0);
}
}


#include <windows.h>
bool Running;
int main(){
while (true){ //infinite loop
if(GetAsyncKeyState(VK_NUMPAD1)&1)//if numpad1 is pressed start pressing keys
Running = true;
while (Running) { //as long as Running == true, will continue to press buttons
keybd_event(VkKeyScan('z'),0,0,0);
keybd_event(VkKeyScan('z'),0,KEYEVENTF_KEYUP,0);//lifts up z key
keybd_event(VkKeyScan('s'),0,0,0);
keybd_event(VkKeyScan('s'),0,KEYEVENTF_KEYUP,0); //lifts up s key
Sleep(100);
if (GetAsyncKeyState(VK_NUMPAD0)&1)
Running = false; // if you press numpad0 it will stop pressing buttons
}
}
return 1; //although this will never be reached because of the infinite loop, it is necessary...
}
nice catch#include <windows.h>
bool Running;
int main(){
Running = false;
while (true){ //infinite loop
if(GetAsyncKeyState(VK_NUMPAD1)&1)//if numpad1 is pressed start pressing keys
Running = true;
while (Running) { //as long as Running == true, will continue to press buttons
keybd_event(VkKeyScan('z'),0,0,0);
keybd_event(VkKeyScan('z'),0,KEYEVENTF_KEYUP,0);//lifts up z key
keybd_event(VkKeyScan('s'),0,0,0);
keybd_event(VkKeyScan('s'),0,KEYEVENTF_KEYUP,0); //lifts up s key
Sleep(100);
if (GetAsyncKeyState(VK_NUMPAD0)&1)
Running = false; // if you press numpad0 it will stop pressing buttons
}
}
return 1; //although this will never be reached because of the infinite loop, it is necessary...
}