Coolest thing you've ever done in console?

What is the coolest thing you've done with console programming?
Since "coolest" is a relative term I'll list a few project details that I am the most proud of.

Remote Application Installation: There is nothing nefarious about how I did this, I have the full permission of all parties involved. I use the credentials of the user who runs the application to pull a list of PC's form the user specified OU in Active Directory. Then from this I execute a Wake On LAN command (MAC's are pulled from the DNS ARP table) and have the application sleep for 10 mins. (start up + scan disk time) before I copy out the required installation files for the application I intend to install. I create and execute a Serivice on the remote machine to first kill the application if it is running in memory (this is because most installations we do are upgrades) then run the installation file which upon completion I test to see if the installation was successful or if it failed and send that data back to the PC that started the installation. This entire process runs in a seperate thread per PC which exits with the remote host name and an appropriate error code sent to the PC that started the installation. If the point of failure is anywhere after the files are copied out (i.e. if the PC is ON and responding but for some reason not cooperating) I find and kill the "winlogon.exe" process which automatically causes the remote host to reboot regardless of what it is doing, the thread then waits 10 more mins (while the target PC reboots), and starts the process over again.

Cryptanalysis: This isn't 100% done yet but I'm working on a console application that analyses and breaks subsitution ciphers. I've broken Ceasar and Vigenère ciphers already and am working on breaking XOR encryption. If you're looking for ideas for a project to do then I highley recommend this one, the Strings library feels like it was built for it. Also skip breaking the Vigenère (polyalphabitic) cipher, XOR is the same thing only with a larger working set, this will save you about a week and if you're like me it will save you from some misconseptions about the process. From here I plan on "playing" with the public encryption ciphers next, just to evaluate them of course.
Last edited on
@Computergeek01

Sounds like a lot of fun, I can't wait for the day when I can make something useful outside of solutions to exercises.
I have to admit that "cool" and "console" don't really go together for me.

Computergeek's applications sounds like interesting and challenging problems. But I don't think "cool!".

When it comes to console specific things, the only things I've seen and thought were pretty "cool" -- but rather pointless -- are some of the ascii animation. For example (esp. the aquarium)
http://cs.hbg.psu.edu/~jjb24/animations2.html

(I've never done any animation this involved; just ascii spinners and progress bars.)

Andy
Last edited on
closed account (3hM2Nwbp)
http://pastie.org/2075811

Did that almost 5 years ago to pass time during an elective course.
Here's my console program. I compiled it with MS Visual C++ 2008 Express Edition. I call it 'Glowing Colors'. Hope you think it's 'cool' also.

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// Glowing Colors.cpp : main project file.

#include <stdafx.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
using namespace System;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void setcursor(bool visible, DWORD size) // set bool visible = 0 - invisible, bool visible = 1 - visible
{
	if(size == 0)
	{
		size = 20;	// default cursor size
	}
	CONSOLE_CURSOR_INFO lpCursor;	
	lpCursor.bVisible = visible;
	lpCursor.dwSize = size;
	SetConsoleCursorInfo(console,&lpCursor);
}


void gotoXY(int x, int y) 
{ 
CursorPosition.X = x; 
CursorPosition.Y = y; 
SetConsoleCursorPosition(console,CursorPosition); 
}

void gotoXY(int x, int y, string text) 
{ 

CursorPosition.X = x; 
CursorPosition.Y = y; 
SetConsoleCursorPosition(console,CursorPosition);
cout << text;
}

string Shadow[5] = { "","\xB0","\xB1","\xB2"," " };
string  Style[5][12] = { 
{""," "," "," "," "," "," "," "," "," "," "," " },
{"","\xDA","\xC4","\xBF","\xB3","\xD9","\xC0","\xC3","\xB4","\xC2","\xB3","\xC1"},
{"","\xC9","\xCD","\xBB","\xBA","\xBC","\xC8","\xCC","\xB9","\xCB","\xBA","\xCA"},
{"","\xD5","\xCD","\xB8","\xB3","\xBE","\xD4","\xC6","\xB9","\xD1","\xB3","\xCF"},
{"","\xD6","\xC4","\xB7","\xBA","\xBD","\xD3","\xC7","\xC6","\xD2","\xBA","\xD0"}
};


/*╔═════════════════════════════════════════════════════════════════════════════════╗
  ║		       What gets shown by the arrays in the calling of Box()        ║░
  ║                                                                                 ║░	 
  ║     Shadow[?] [0] = "", [1] = "░", [2] = "▒", [3] = "▓", [4] = "█"              ║░
  ║       Type[?] [1] = "┌ ─ ┐ │ ┘ └ ├ ┤ ┬ │ ┴"                                     ║░
  ║		  [2] = "╔ ═ ╗ ║ ╝ ╚ ╠ ╣ ╦ ║ ╩"                                     ║░
  ║	          [3] = "╒ ═ ╕ │ ╛ ╘ ╞ ╡ ╤ │ ╧"                                     ║░
  ║	          [4] = "╓ ─ ╖ ║ ╜ ╙ ╟ ╢ ╥ ║ ╨"                                     ║░
  ║                                                                                 ║░
  ╚═════════════════════════════════════════════════════════════════════════════════╝░
    ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
*/

void Box(int style, int across, int down, int amount, int rows, int color, int shadow, int shadow_color)
{
int x,y, go;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
for (x=rows; x>0; x--)
	{
	  for (y=amount; y>0 ;y--)
	  { gotoXY((across+y)-1,(down+x)-1);
	     {
	       if (y==1 && x==1)
	       {
		  cout << Style[style][1];
		  for (go=amount-2; go>0 ;go--)
			{ 
			  cout << Style[style][2];
			 }
		  cout << Style[style][3];
			}
	  else if ( (y>=1 && y<=amount-1) && x!=1 )
	        {
		  gotoXY((across+y),(down+x)-1);
		  cout << Style[style][4];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),shadow_color);
		   cout << Shadow[shadow];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
		  y--;
		for (go=amount-2; go>0 ;go--)
		  { gotoXY((across+y),(down+x)-1);
		     cout << " ";
		    y--;
		  }
		  gotoXY(across+y,(down+x)-1);
		  cout << Style[style][4];
		}
	  else if (y==amount && x==rows)
	      {
		  y--;
		  gotoXY(across+y,(down+x)-1);
		  cout << Style[style][5];
		 	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),shadow_color);
			cout << Shadow[shadow];
			gotoXY(across+y,(down+x));
			cout <<  Shadow[shadow] << Shadow[shadow];
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
		  y--;
		  for (go=amount-2; go>0 ; go--)
		  {
		    gotoXY(across+y,(down+x)-1);
		    cout << Style[style][2];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),shadow_color);
		   gotoXY(across+y,(down+x));
		   cout << Shadow[shadow];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
		   y--;
		  }
		  gotoXY(across+y,(down+x)-1);
		  cout << Style[style][6];
	       }
	    }
	  }
	}
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color );
}

void WaitKey()
{
while (_kbhit()) _getch(); // Empty the input buffer
_getch(); // Wait for a key
while (_kbhit()) _getch(); // Empty the input buffer (some keys sends two messages)
}

int main()
{
	int width = 57;
	int height = 30; 
	
	int color[] = {19,22,24,23,31,23,24,22};
	string text = "Welcome to C++ Programming!!";
	int x,y;
	Console::SetWindowSize(width, height );
	Box(1,0,0,57,30,120,0,0);  // Gray background box
	for (x = 3;x<21;x++)
	{
		Box(2,5,5,47,x,192,1,128);  // Blue box
		Console::SetWindowSize(width, height );
		Sleep(100);
	}
	for (x = 3;x<33;x++)
	{
		Box(3,13,9,x,5,23,2,64);   // Red box for text
		Console::SetWindowSize(width, height );
		Sleep(100);
	}
	
	Console::SetWindowSize(width, height );

	for (y = 0;y<7;y++)
   {
	   for (x=0; x<=7;x++)
	   {
		   SetConsoleTextAttribute(console, color[x]);
		   gotoXY(15,11, text );
		   Sleep(130);
	   }
	   Sleep(80);
	}
	for (x=0; x<=4;x++)	   
	{
		SetConsoleTextAttribute(console, color[x]);
		gotoXY(15,11, text );
		Sleep(130);
	}
	setcursor(0,0);
	
	for (x = 3;x<35;x++)
	{
		Box(3,12,18,x,3,23,2,64);  // 2nd red box for 'Press any key... '
		Console::SetWindowSize(width, height );
		Sleep(100);
	}
					
	for (x=0; x<=4;x++)	   
	{
		SetConsoleTextAttribute(console, color[x]);
		gotoXY(13,19, "Press any key to continue..." );
		Sleep(130);
	}
	WaitKey();
	exit(0);
}


PS: Edited program to increase 'WOW' factor, and make it more console friendly.

whitenite1
Last edited on
closed account (3hM2Nwbp)
^ Awesome
All these are pretty cool, I kinda get what you mean, andywestken, but I would say "cool!" cause I'm just amazed that someone can do stuff like that, by just typing. (I know C++ isn't really just "typing" but, if someone were to give you the source code of something, you could just type it, and it could do something amazing)
I finally learned how to to create scrolling text, without using left$,mid$ or right$, since they aren't in C++. So, I changed the program a bit, to add a little more interesting visual candy. Hope everyone enjoys it. Still using MS Visual C++ 2008 Express Edition.
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// Pulsating Text.cpp : Defines the entry point for the console application.

#include <stdafx.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <windows.h>

using namespace std;
using namespace System;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void setcursor(bool visible, DWORD size) // set bool visible = 0 - invisible, bool visible = 1 - visible
{
	if(size == 0)
	{
		size = 20;	// default cursor size
	}
	CONSOLE_CURSOR_INFO lpCursor;	
	lpCursor.bVisible = visible;
	lpCursor.dwSize = size;
	SetConsoleCursorInfo(console,&lpCursor);
}


void gotoXY(int x, int y) 
{ 
CursorPosition.X = x; 
CursorPosition.Y = y; 
SetConsoleCursorPosition(console,CursorPosition); 
}

void gotoXY(int x, int y, string text) 
{ 

CursorPosition.X = x; 
CursorPosition.Y = y; 
SetConsoleCursorPosition(console,CursorPosition);
cout << text;
}

string Shadow[5] = { "","\xB0","\xB1","\xB2"," " };
string  Style[5][11] = { 
{""," "," "," "," "," "," "," "," "," "," " },
{"","\xDA","\xC4","\xBF","\xB3","\xD9","\xC0","\xC3","\xB4","\xC2","\xC1"},
{"","\xC9","\xCD","\xBB","\xBA","\xBC","\xC8","\xCC","\xB9","\xCB","\xCA"},
{"","\xD5","\xCD","\xB8","\xB3","\xBE","\xD4","\xC6","\xB9","\xD1","\xCF"},
{"","\xD6","\xC4","\xB7","\xBA","\xBD","\xD3","\xC7","\xC6","\xD2","\xD0"}
};

enum {
  black,          //  0
  dark_blue,      //  1
  dark_green,     //  2
  dark_cyan,      //  3
  dark_red,       //  4
  dark_magenta,   //  5
  dark_yellow,    //  6
  light_gray,     //  7
  dark_gray,      //  8
  light_blue,     //  9
  light_green,    // 10
  light_cyan,     // 11
  light_red,      // 12
  light_magenta,  // 13
  light_yellow,   // 14
  white           // 15
  };

void Box(int style, int across, int down, int amount, int rows, int b_color, int f_color, int shadow, int shadow_bc, int shadow_fc)
{
int color = (f_color+(b_color*16));
int shadow_color = (shadow_fc+(shadow_bc*16));
int x,y, go;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
for (x=rows; x>0; x--)
	{
	  for (y=amount; y>0 ;y--)
	  { gotoXY((across+y)-1,(down+x)-1);
	     {
	       if (y==1 && x==1)
	       {
		  cout << Style[style][1];
		  for (go=amount-2; go>0 ;go--)
			{ 
			  cout << Style[style][2];
			 }
		  cout << Style[style][3];
			}
	  else if ( (y>=1 && y<=amount-1) && x!=1 )
	        {
		  gotoXY((across+y),(down+x)-1);
		  cout << Style[style][4];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),shadow_color);
		   cout << Shadow[shadow];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
		  y--;
		for (go=amount-2; go>0 ;go--)
		  { gotoXY((across+y),(down+x)-1);
		     cout << " ";
		    y--;
		  }
		  gotoXY(across+y,(down+x)-1);
		  cout << Style[style][4];
		}
	  else if (y==amount && x==rows)
	      {
		  y--;
		  gotoXY(across+y,(down+x)-1);
		  cout << Style[style][5];
		 	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),shadow_color);
			cout << Shadow[shadow];
			gotoXY(across+y,(down+x));
			cout <<  Shadow[shadow] << Shadow[shadow];
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
		  y--;
		  for (go=amount-2; go>0 ; go--)
		  {
		    gotoXY(across+y,(down+x)-1);
		    cout << Style[style][2];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),shadow_color);
		   gotoXY(across+y,(down+x));
		   cout << Shadow[shadow];
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
		   y--;
		  }
		  gotoXY(across+y,(down+x)-1);
		  cout << Style[style][6];
	       }
	    }
	  }
	}
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color );
}

void BoxLineAcross(int style, int across, int down, int amount)
{
		gotoXY(across,down);
			cout << Style[style][7];
		for ( int x=1;x<amount-1;x++)
			cout << Style[style][2];
		cout << Style[style][8];
}

void BoxLineDown(int style, int across, int down, int amount)
{
		gotoXY(across,down);
			cout << Style[style][9];
		for ( int x=1;x<amount-1;x++)
			{
			gotoXY(across,down+x);
			cout << Style[style][4];
			}
		gotoXY(across,down+amount-1);
		cout << Style[style][10];
}
void WaitKey()
{
while (_kbhit()) _getch(); // Empty the input buffer
_getch(); // Wait for a key
while (_kbhit()) _getch(); // Empty the input buffer (some keys sends two messages)
}

int main()
{
	int width = 57;
	int height = 30; 
	int len = 0;
	int t = 0;
	char holder;
	int color[] = {19,22,24,23,31,23,24,22};
	string text = "Welcome to Pulsating Text Demo!!";
	string PressKey = "Press any key to continue... ";
	int x,y;
	Console::SetWindowSize(width, height );
	Box(1,0,0,57,30,light_gray,dark_gray,0,0,0);  // Gray background box
	BoxLineAcross(1,0,3,57); // Top Line
	BoxLineAcross(1,0,26,57);// Bottom Line
	for (x = 3;x<21;x++)
	{
		Box(2,5,5,47,x,light_red,black,2,light_gray,dark_gray);  // Red box
		BoxLineDown(3, 15, 5, x);
		BoxLineDown(3, 42, 5, x);
		Console::SetWindowSize(width, height );
		Sleep(100);
	}
	for (x = 3;x<37;x++)
	{
		Box(3,11,9,x,5,dark_blue,light_gray,2,light_red,dark_red);   // Blue box for text
		Console::SetWindowSize(width, height );
		Sleep(100);
	}
	
	Console::SetWindowSize(width, height );

	for (y = 0;y<9;y++)
   {
	   for (x=0; x<=7;x++)
	   {
		   SetConsoleTextAttribute(console, color[x]);
		   gotoXY(13,11, text );
		   Sleep(130);
		   
	   }
	   Sleep(80);
	}
	for (x=0; x<=4;x++)	   
	{
		SetConsoleTextAttribute(console, color[x]);
		gotoXY(13,11, text );
		Sleep(130);
	}

	setcursor(0,0);
	
	for (x = 3;x<35;x++)
	{
		Box(3,12,18,x,3,dark_blue,light_gray,2,light_red,dark_red);  // 2nd red box for 'Press any key... '
		Console::SetWindowSize(width, height );
		Sleep(100);
	}
	
	len = PressKey.length();
	do
	{
		SetConsoleTextAttribute(console, color[t]);
		gotoXY( 15,19, PressKey);  // scrolling the string called PressKey
		t++;
		if (t==8)
			t=0;
		holder = PressKey[0];
		for ( x=0;x<len;x++)
			PressKey[x] = PressKey[x+1];
		PressKey[len] = holder;
		Sleep(130);
	} while (_kbhit() == '\0' );

exit(0);
}
Topic archived. No new replies allowed.