I managed to make a program like the LOST example i mentioned, here is the code
Code:
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <time.h>
HANDLE wHnd; // Handle to write to the console.
HANDLE rHnd; // Handle to read from the console.
bool numbers = false;
void WINAPI NewThread();
int main()
{
DWORD dwID;
HANDLE hThread;
int input1, input2, input3, input4, input5, input6;
// Set up the handles for reading/writing:
wHnd = GetStdHandle(STD_OUTPUT_HANDLE);
rHnd = GetStdHandle(STD_INPUT_HANDLE);
// Change the window title:
SetConsoleTitle(L"LOST");
// Set up the required window size:
SMALL_RECT windowSize = {0, 0, 79, 49};
// Change the console window size:
SetConsoleWindowInfo(wHnd, TRUE, &windowSize);
// Create a COORD to hold the buffer size:
COORD bufferSize = {80, 50};
// Change the internal buffer size:
SetConsoleScreenBufferSize(wHnd, bufferSize);
hThread = CreateThread(
0,
NULL,
(LPTHREAD_START_ROUTINE)NewThread,
NULL,
NULL,
&dwID);
printf("\n\n");
while (TRUE)
{
scanf("%d%d%d%d%d%d", &input1, &input2, &input3, &input4, &input5, &input6);
if(input1 == 4 && input2 == 8 && input3 == 15 && input4 == 16 && input5 == 23 && input6 == 42)
numbers = true;
}
}
void WINAPI NewThread()
{
CHAR_INFO consoleBuffer[1*4];
char tempBuffer[6];
sprintf(tempBuffer, "%d", 108*60);
consoleBuffer[0].Char.UnicodeChar = tempBuffer[0];
consoleBuffer[0].Attributes = BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE;
consoleBuffer[1].Char.UnicodeChar = tempBuffer[1];
consoleBuffer[1].Attributes = BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE;
consoleBuffer[2].Char.UnicodeChar = tempBuffer[2];
consoleBuffer[2].Attributes = BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE;
consoleBuffer[3].Char.UnicodeChar = tempBuffer[3];
consoleBuffer[3].Attributes = BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE;
// Set up the positions:
COORD charBufSize = {4,1};
COORD characterPos = {0,0};
SMALL_RECT writeArea = {0,0,3,0};
time_t start = time(NULL);
start = start+(108*60);
while (TRUE)
{
WriteConsoleOutput(wHnd, consoleBuffer, charBufSize, characterPos, &writeArea);
sprintf(tempBuffer, "%d", start-time(NULL));
consoleBuffer[0].Char.UnicodeChar = tempBuffer[0];
consoleBuffer[1].Char.UnicodeChar = tempBuffer[1];
consoleBuffer[2].Char.UnicodeChar = tempBuffer[2];
consoleBuffer[3].Char.UnicodeChar = tempBuffer[3];
Sleep(100);
if (numbers == true)
{
start = time(NULL)+(108*60);
numbers = false;
}
}
}
Probably not the easiest way of doing it, but it works perfectly.
Thanks for all help
I know it's not good to have infinite loops, but it works for now...