I am new to programming and also to stackoverflow and C++ is a very complicated language so please help help me here because I can't figure this out
#include <shlobj.h>
#include <shlwapi.h>
#include <objbase.h>
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char key_press;
int ascii_value;
key_press=getch();
ascii_value=key_press;
if(ascii_value==32) {
ShellExecute(NULL, "open", "C:\\Users\\Usman\\Desktop\\Folders-Files\\Performance\\code\\bat\\downloads-folder-organizer.bat", NULL, NULL, SW_SHOWNORMAL);
}
return 0;
}
The above code is meant to run a file "downloads-folder-organizer.bat" when I press the spacebar by detecting ascii value of a pressed key. However I can only do this once because after that the program closes. I googled and googled but no one seemed to address this problem because they were all talking about keeping the console window from closing, infinite loops etc. Can anyone help me?
Aucun commentaire:
Enregistrer un commentaire