Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Simulating button press with a string after button is pressed

$
0
0
Hi !
I want to make a program, that will check if a button SPACE (VK_SPACE) is pressed, and if so it will simulate button pressing with a string (like, first i input a text to the string, the text for example will be "im using dream in code" and then after i press for example SPACE the program will rewrite the text in a active window)
I dont know how to rewrite the text, and how to make it after a button is pressed.
Abotu that "if button is pressed".. i have tried this:
#include<windows.h>
#include<iostream>
using namespace std;

int main(void)
{
    bool done = false;

    while(!done)
        if(GetAsyncKeyState(VK_SPACE) != 0)
            done = true;

    cout << "You found the key!" << endl;
    cin.get();
    return 0;
}


but it terribly laggs my pc (100% usage) because its checking for that key in a loop till ill press the space, do you know how i can make it without lagging my pc ?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>