Sep 24, 2013 at 9:42pm UTC
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 Sep 24, 2013 at 9:48pm UTC
Sep 25, 2013 at 11:45am UTC
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.
Sep 25, 2013 at 12:03pm UTC
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 '-'
Sep 25, 2013 at 1:44pm UTC
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.)
Sep 25, 2013 at 2:17pm UTC
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?
Sep 26, 2013 at 1:36am UTC
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.