Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 15:44

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



(Request) Console in C++

Discussion on (Request) Console in C++ within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
The Steven's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 415
Received Thanks: 67
(Request) Console in C++

Hi,

kurz ne blöde frage

Wenn ich ne Console in C++ erstelle (CMD),
quasi mit color,title,echo off & am ende cls,
wie kann ichs dazu bringen dass man auch eine normale Eingabe machen kann anschliessend, ohne dass sich das Programm schliesst, bzw. mit Pause
im anschluss schliesst? Die Systembefehle usw weiß ich ja, nur meine Frage ist halt obs möglich ist, die normale cmd.exe ausm sys32 Ordner zu "Klonen" mit Hilfe von C++, quasi das gleiche wie cmd.exe nur mit anderen Farben, nem anderen Titel & ohne das Echo.
Am ende soll dann alles gecleart werden damit man die Commands eingeben kann, ins leere Fenster.

Beispiel: (Als CMD, welches normalerweise als C++ Datei sein sollte)


PS: Brauche nur nen tipp, nicht füttern bitte
PS²: Ich nutze das Buch C++ Von A-Z, sobalds ankommt (nächste Woche?)
Ist das zu empfehlen?

Danke schonmal!

Lg.
The Steven is offline  
Old 12/19/2011, 20:47   #2
 
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
std::cin
MoepMeep is offline  
Old 12/19/2011, 21:44   #3
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
Quote:
Originally Posted by MoepMeep View Post
std::cin
Ich glaub er meint die Konsole mit den ganzen Batchbefehlen.


Probiger mal:

system("title Coole Konsole");
system("cmd")

könnte klappen, bin mir aber unsicher
jacky919 is offline  
Thanks
1 User
Old 12/19/2011, 21:46   #4
 
The Steven's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 415
Received Thanks: 67
Okay, da kommen wir dem ganzen schon näher, danke!

So nun gehts weiter:

Wie erkennt das System das es sich hierbei um die cmd.exe commands handelt?

Als beispiel: "Dir"

Würde im CMD das aktuelle Verzeichniss anzeigen,
muss ich das ganze so auch eintragen, dass es auf den Befehl "Dir" per
Code:
system("dir");
alles anzeigt, oder gibt es da einen anderen weg?

Sonst müsste ich das ja mit allen Commands machen..

Lg

@Jacky danke, klappt.

Nur habe ich dann die normale Console, wie vorher auch..
Titel & Farbe ist da, was fehlt: @echo off & cls.

per
Code:
system("@echo off"); & system("cls");
scheints nicht zu klappen.

PS: Außerdem habe ich dann nicht den gewünschten Effekt, die Konsole mit C++ zu "Klonen" bzw. den Effekt mit C++ zu erreichen.
The Steven is offline  
Old 12/19/2011, 22:10   #5


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,909
Received Thanks: 25,409
Meinst du im Grunde, dass du genau die Konsole hast, wie sie auch erscheint, wenn du cmd.exe ausführst (nur halt in anderen Farben etc.), sprich sie bleibt nach der Eingabe offen und man kann Befehle eingeben? Soll auch das aktuelle Verzeichnis angezeigt werden? (wenn cd nicht verwendet wird, ist es beim CMD ja C:\Windows\system32\)
MrSm!th is offline  
Old 12/19/2011, 22:14   #6
 
The Steven's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 415
Received Thanks: 67
Genau richtig,
nur das ganze hätte ich gerne selbst geschrieben in C++,
das versuche ich quasi grad:

Aufbauen der Console(Color, Title, Echo, Cls)
& Anschliessend soll eine Eingabe erlaubt sein, welche auf die cmd.exe Commands zugreifft.
(Ich habs per cin bereits versucht, das ist aber nicht das was ich brauche, eine Eingabe an sich ist ja nicht das Problem, sondern dass es die Commands der CMD.exe erkennt.)
Beispiel:




Das als C++ Konsole.
The Steven is offline  
Old 12/20/2011, 14:23   #7
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
könntest es so machen:

Code:
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	/*
	hier farbe
	titel
	etc.
	*/
	
	while(1)
	{
		string cmd = "";
		cin >> cmd;
		system(cmd.c_str());
	}
	
	return 0;
}
jacky919 is offline  
Thanks
1 User
Old 12/20/2011, 18:43   #8
 
The Steven's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 415
Received Thanks: 67
Wunderbar, klappt bis auf dass der tchar Header fehlte, aber ein bischen eigen Werk sollte ja dabei sein!


folgendes habe ich noch addiert damit die Fehler korrigiert waren:
Code:
#include <string>
#include <tchar.h>
Nun klappt alles wie ich es wollte, ich bedanke mich bei allen für die Hilfe und vorallem bei Jacky für die Idee mit dem Console In >> Cmd!

Lg
The Steven is offline  
Old 12/20/2011, 18:49   #9


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,909
Received Thanks: 25,409
Hätte auch gereicht, das Programm auf MultiByte Zeichensatz umzustellen bzw. wstring zu nutzen.

edit:

nein halt, wieso tchar.h? o.O Der hat doch gar nix damit zu tun.
Allerhöchstens windows.h, der enthält doch system().
MrSm!th is offline  
Old 12/20/2011, 19:17   #10
 
xNopex's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 827
Received Thanks: 471
Code:
while(1)
Ih. Warte ich geh mal schnell mich übergeben.


Quote:
Allerhöchstens windows.h, der enthält doch system().
Ist sogar Teil des C-Standards, weswegen es genügen sollte "cstdlib" zu inkludieren.
xNopex is offline  
Thanks
1 User
Old 12/20/2011, 19:31   #11
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
system() ist doch Mitglied vom std namespace.

Ausserdem komisch, dass du noch mehr inkludieren mustest...
Bei mir hat bei MinGW iostream gereicht.
jacky919 is offline  
Old 12/20/2011, 19:44   #12
 
xNopex's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 827
Received Thanks: 471
Quote:
system() ist doch Mitglied vom std namespace.
Leider ist das falsch.
xNopex is offline  
Old 12/20/2011, 20:04   #13
 
The Steven's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 415
Received Thanks: 67
Hm, stimmt mit windows + string funktionierts.

Hab jetzt das erreicht was ich wollte.

@ Smith, definiere "umstellen" ?

Danke & Lg
The Steven is offline  
Old 12/20/2011, 20:16   #14
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
Quote:
Originally Posted by xNopex View Post
Leider ist das falsch.
Auf der Seite steht es doch oder irre ich mich?
jacky919 is offline  
Old 12/20/2011, 20:26   #15
 
xNopex's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 827
Received Thanks: 471
Meine Referenz sagte was anderes. Und ich habe mal rumprobiert: Es geht beides Ich ziehe meine dreiste Behauptung zurück.
xNopex is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[RELEASE] Console Commands for Lame Console Look
12/07/2011 - CO2 PServer Guides & Releases - 12 Replies
Well, to avoid any further useless posts on this subject... here are a ton of console based commands that will control the game from the server console. I will not explain what each does, it should be pretty easy to figure out, and I don't intend to answer stupid questions. If its a good question, I will answer it. public static void DoStuff() { bool flag = true; Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; ...
[Request]Dekaron HeavensGate vach,aggro,speed,wall,gm console
06/19/2009 - Dekaron Private Server - 3 Replies
Hi , any can create or post here some hacks(vach hack,non aggro,wall hack,gm console,spawn monsters no gm hack!,speed) for Dekaron HG on all maps , including hacks for new maps ? :handsdown:----:handsdown:
[Request] GM console?
07/18/2008 - Perfect World - 2 Replies
I've been looking on this site, and it says something about a GM console for pw, well I think X-UG had it but their forum isn't available so does anyone have the file and would kindly put it on this thread so I may try it out? I don't care if it's client sided, or if it doesn't work, I want it for experimental reasons, so thank you to whoever uploads it on elitepvpers.
[REQUEST] Hacking Client Guide - admin console
06/09/2008 - Perfect World - 2 Replies
I have seen some topics with claims that they have an admin / debug console. I would like to know how to do this for myself. I have read that it doesnt work but i dont care as i just want it for the fact of having it. I hope someone can help. I was hoping for a guide just like this one. Thanks in advance.



All times are GMT +1. The time now is 15:44.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.