Virtual Keys

Hi,
Lately I have been trying to figure out how to make 'Virtual Keys' work even if the console is minimized or if I'm running a game in full screen.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "stdafx.h"

#include <iostream>
#include <string>
#include <windows.h>

using namespace std;

void clipBoard(const char* output);

void test()
{
	GetAsyncKeyState(VK_INSERT);  
	string output = "Hello!";
    clipBoard(output.c_str());
    cout << "'" << output << "'" << " has been successfully copied\n";
	//
	
    output = "Goodbye!";
    clipBoard(output.c_str());
    cout << "'" << output << "'" << " has been successfully copied\n";
	//
}

int main()
{	
	SetConsoleTitle( TEXT( "Title!" ) );
	ShowWindow( GetConsoleWindow() , SW_MAXIMIZE); 	
        test();
}

void clipBoard(const char* output )
{	
    const size_t len = strlen(output) + 1;
    HGLOBAL hMem =  GlobalAlloc(GMEM_MOVEABLE, len);
    memcpy(GlobalLock(hMem), output, len);
    GlobalUnlock(hMem);
    OpenClipboard(0);
    EmptyClipboard();
    SetClipboardData(CF_TEXT, hMem);
    CloseClipboard();	
	cin.get();
}


Clipboard works totally fine, added cin.get() at the end of the function 'clipBoard' so when the function 'test()' runs it does not keep going on.
Last edited on
Bump
You can't. The game and your program are two separate processes, and your console program won't receive any input if it is not the focused window.
I see. So there's no way for the program to work without alt-tabbing while in a game? Because I viewed some information about GetAsyncKeyState that this works even when a game is running in full screen, program would still get keyboard input. Let's say fraps, hotkeys such as F9 to record a video totally works without alt-tabbing. So I don't really get it why it is most likely impossible '-'
I didn't say it was impossible. Just that it won't work the way you are trying to do it.

Sorry I won't say more. I'm not into helping people cheat on their video games.

(And if that's not what you're doing, don't be offended.)
Not my intention to 'cheat', I'm a staff member in a game. Thought it would be useful explaining stuff without explaining every time with typing. Anyway, thanks I guess?
Don't be offended. 99% of these types of questions are about how to automate something in a game that wasn't designed that way.

Check your PMs.
Topic archived. No new replies allowed.