Source:

#include<Windows.h>
#include<conio.h>

int main() {


	char stop = static_cast<char>(getch());

	while (stop != 's') {	// 'S' needs to be WIN+S

		keybd_event(VK_LWIN,  0x5b,  0, 0);                 // Press WIN KEY
		keybd_event(VK_LEFT, '0x25', 0, 0);					// Press LEFT KEY
		keybd_event(VK_LEFT, '0x25', KEYEVENTF_KEYUP, 0);   // Lift LEFT KEY
	}

	keybd_event(VK_LEFT, '0x25', KEYEVENTF_KEYUP, 0);       // Lift WIN KEY

	return 0;
}

At: while (stop != 's')

I wanna change the 's' to the key combination of: WIN+S
course ass you can see, the loop is going to hold down the WIN key all the time.

Or if anyone have another way to stop the loop maybe.

What are you trying to do? To be able to __stop__ the loop, your while condition must change, which it never will. You must change the value of 'stop' inside your loop! Your loop will not even start until you press a key other than 's'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.