<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wie funktioniert die TAB-Vervollständigung bei cmd.exe ???]]></title><description><![CDATA[<p>Hallo, ich habe eine Konsolenanwendung geschrieben mit der man in Verzeichnise wechseln kann, wie z.B. <em>cd c:\test</em></p>
<p>Hier der Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;tchar.h&gt;
#include &lt;sstream&gt;
#include &lt;vector&gt;
#include &lt;Shlwapi.h&gt;

using namespace std;

#pragma comment(lib, &quot;Shlwapi.lib&quot;)

string ApplicationDirectory();

//***Global***
string Pfad = ApplicationDirectory();

string ApplicationDirectory()
{
	TCHAR szPathName[_MAX_PATH];
	::GetModuleFileName(NULL, szPathName, _MAX_PATH);
	LPTSTR pszFileName = _tcsrchr(szPathName, '\\') + 1;
	*pszFileName = '\0'; 

	return szPathName;
}

int checkDir(string str)
{
	if (PathIsDirectory(str.c_str()))
		return 1;
	else
		return 0;
}

//Ausgabe Prompt
void prompt()
{	
	//cout &lt;&lt; Pfad &lt;&lt; &quot;&gt;&gt;&quot;;
	char ps[100];
	GetCurrentDirectory(90, ps);
	cout &lt;&lt; endl &lt;&lt; ps &lt;&lt; &quot;&gt;&quot;;
}

int main()
{
	string str;
	do
	{
		//Setzt den aktuellen Pfad
		SetCurrentDirectory(Pfad.c_str());
		prompt();

		getline(cin, str);	

		istringstream cmdline (str);
		string input;
		vector&lt;string&gt; params;

		string tmp;
		while (cmdline &gt;&gt; tmp) 
		{
			params.push_back (tmp);
		}

		if(params.size() &gt;= 2)
		{
			if(params[0] == &quot;cd&quot;)
			{				
				//Pfad = params[1];
				if(checkDir(params[1]) == 1)
				{
					Pfad = params[1];
				}
				else
					cout &lt;&lt; &quot;Verzeichnis '&quot; &lt;&lt; params[1] &lt;&lt; &quot;' nicht gefunden&quot; &lt;&lt; endl &lt;&lt; endl;

			}
		}
		if(params.size() &gt;= 1)
		{
			if(params[0] == &quot;exit&quot;)
				return 0;
			if(params[0] == &quot;dir&quot;)
				system(&quot;dir&quot;);
		}

	}while(1);
	return 0;
}
</code></pre>
<p>Jeder oder einige von euch kennen wenn man in <strong>cmd</strong> ein Verzeichnis nicht ganz eingibt und dann Tab drückt, werden alle mit dem angefangen Verzeichnis oder Dateien ausgegeben, so kann man schneller in Verzeichnise wechseln.</p>
<p>Jetzt wollte ich fragen wie funktioniert die TAB-Vervollständigung in cmd, wie wurde sie implementiert, ist es möglich sowas zu realisieren????</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/185104/wie-funktioniert-die-tab-vervollständigung-bei-cmd-exe</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 17:08:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/185104.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Jun 2007 20:29:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Thu, 21 Jun 2007 20:29:25 GMT]]></title><description><![CDATA[<p>Hallo, ich habe eine Konsolenanwendung geschrieben mit der man in Verzeichnise wechseln kann, wie z.B. <em>cd c:\test</em></p>
<p>Hier der Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;tchar.h&gt;
#include &lt;sstream&gt;
#include &lt;vector&gt;
#include &lt;Shlwapi.h&gt;

using namespace std;

#pragma comment(lib, &quot;Shlwapi.lib&quot;)

string ApplicationDirectory();

//***Global***
string Pfad = ApplicationDirectory();

string ApplicationDirectory()
{
	TCHAR szPathName[_MAX_PATH];
	::GetModuleFileName(NULL, szPathName, _MAX_PATH);
	LPTSTR pszFileName = _tcsrchr(szPathName, '\\') + 1;
	*pszFileName = '\0'; 

	return szPathName;
}

int checkDir(string str)
{
	if (PathIsDirectory(str.c_str()))
		return 1;
	else
		return 0;
}

//Ausgabe Prompt
void prompt()
{	
	//cout &lt;&lt; Pfad &lt;&lt; &quot;&gt;&gt;&quot;;
	char ps[100];
	GetCurrentDirectory(90, ps);
	cout &lt;&lt; endl &lt;&lt; ps &lt;&lt; &quot;&gt;&quot;;
}

int main()
{
	string str;
	do
	{
		//Setzt den aktuellen Pfad
		SetCurrentDirectory(Pfad.c_str());
		prompt();

		getline(cin, str);	

		istringstream cmdline (str);
		string input;
		vector&lt;string&gt; params;

		string tmp;
		while (cmdline &gt;&gt; tmp) 
		{
			params.push_back (tmp);
		}

		if(params.size() &gt;= 2)
		{
			if(params[0] == &quot;cd&quot;)
			{				
				//Pfad = params[1];
				if(checkDir(params[1]) == 1)
				{
					Pfad = params[1];
				}
				else
					cout &lt;&lt; &quot;Verzeichnis '&quot; &lt;&lt; params[1] &lt;&lt; &quot;' nicht gefunden&quot; &lt;&lt; endl &lt;&lt; endl;

			}
		}
		if(params.size() &gt;= 1)
		{
			if(params[0] == &quot;exit&quot;)
				return 0;
			if(params[0] == &quot;dir&quot;)
				system(&quot;dir&quot;);
		}

	}while(1);
	return 0;
}
</code></pre>
<p>Jeder oder einige von euch kennen wenn man in <strong>cmd</strong> ein Verzeichnis nicht ganz eingibt und dann Tab drückt, werden alle mit dem angefangen Verzeichnis oder Dateien ausgegeben, so kann man schneller in Verzeichnise wechseln.</p>
<p>Jetzt wollte ich fragen wie funktioniert die TAB-Vervollständigung in cmd, wie wurde sie implementiert, ist es möglich sowas zu realisieren????</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1311038</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1311038</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Thu, 21 Jun 2007 20:29:25 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Fri, 22 Jun 2007 00:19:30 GMT]]></title><description><![CDATA[<p>Naja, damit du möglichst schnell das Ergebnis bekommst, solltest du alle Verzeichnisse vorher in einen Baum speichern und dann ist das ein einfacher string vergleich und der string der passt wird ausgewählt. Sollte relative leicht zu implementieren st. Ansonsten kannst du dir ja irgendeine Shell ankucken wie die es dort gemacht haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1311102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1311102</guid><dc:creator><![CDATA[mosta]]></dc:creator><pubDate>Fri, 22 Jun 2007 00:19:30 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Sun, 24 Jun 2007 10:03:15 GMT]]></title><description><![CDATA[<p>Mit den normalen Eingabe Funktionen wie getline() kann sowas doch nicht klappen, es muss ja ganze Zeit gewartet werden das vielleicht die TAB Taste gedrückt wird, erst dann soll die Eingegebene Zeile Vervollständigt werden.</p>
<p>Wie sieht der Aufbau so einer Funktion aus???</p>
<p>Bitte um Hilfe!!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1312634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1312634</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Sun, 24 Jun 2007 10:03:15 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Sun, 24 Jun 2007 12:34:01 GMT]]></title><description><![CDATA[<p>Mit SetConsoleMode den Line-Input Modus abstellen und dann ReadConsole(Input).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1312701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1312701</guid><dc:creator><![CDATA[...........]]></dc:creator><pubDate>Sun, 24 Jun 2007 12:34:01 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Sun, 24 Jun 2007 19:30:26 GMT]]></title><description><![CDATA[<p>So habe folgenden Code zusammengebastelt:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

VOID ErrorExit(LPSTR);
VOID KeyEventProc(KEY_EVENT_RECORD); 

int main(VOID) 
{		
	cout &lt;&lt; &quot;Eingabe:&gt;&quot;;

    HANDLE hStdin; 
    DWORD cNumRead, fdwMode, fdwSaveOldMode, i; 
    INPUT_RECORD irInBuf[128]; 
    int counter=0;

    // Get the standard input handle. 

    hStdin = GetStdHandle(STD_INPUT_HANDLE); 
    if (hStdin == INVALID_HANDLE_VALUE) 
        ErrorExit(TEXT(&quot;GetStdHandle&quot;)); 

    // Save the current input mode, to be restored on exit. 

    if (! GetConsoleMode(hStdin, &amp;fdwSaveOldMode) ) 
        ErrorExit(TEXT(&quot;GetConsoleMode&quot;)); 

    // Enable the window and mouse input events. 

    fdwMode = ENABLE_WINDOW_INPUT; 
    if (! SetConsoleMode(hStdin, fdwMode) ) 
        ErrorExit(TEXT(&quot;SetConsoleMode&quot;)); 

    // Loop to read and handle the input events. 

    while (counter++ &lt;= 100) 
    { 
        // Wait for the events. 

        if (! ReadConsoleInput( 
                hStdin,      // input buffer handle 
                irInBuf,     // buffer to read into 
                128,         // size of read buffer 
                &amp;cNumRead) ) // number of records read 
            ErrorExit(TEXT(&quot;ReadConsoleInput&quot;)); 

        // Dispatch the events to the appropriate handler. 

        for (i = 0; i &lt; cNumRead; i++) 
        {
            switch(irInBuf.EventType) 
            { 
                case KEY_EVENT: // keyboard input 
                    KeyEventProc(irInBuf[i].Event.KeyEvent); 
                    break;             
            } 
        }
    } 

    return 0; 
}

VOID ErrorExit (LPSTR lpszMessage) 
{ 
    fprintf(stderr, &quot;%s\n&quot;, lpszMessage); 
    ExitProcess(0); 
}

VOID KeyEventProc(KEY_EVENT_RECORD ker)
{
	//Wartet auf TAB Taste
	if(ker.wVirtualKeyCode == VK_TAB)
	{	
		if(ker.bKeyDown)
			cout &lt;&lt; &quot;#TAB EVENT PRESSED#&quot;;
		else 
			cout &lt;&lt; &quot;#TAB EVENT RELEASED#&quot;;			
	}

	//Normale Eingabe
	else
	{
		//hier kommt die normale eingabe
		cout &lt;&lt; &quot;#Ausgabe#&quot; &lt;&lt; endl;
	}    
}
</code></pre>
<ul>
<li></li>
</ul>
<p>Das Programm wartet auf bestimmte Key Events, in der Funktion [i]KeyEventProc()* wird geprüft ob die TAB Taste gedrückt wird.<br />
Wenn ich nun einmal TAB drücke, wird einmal die PRESSED und die RELEASED funktion ausegeben, obwohl ich nur einmal gedrückt habe, bei anderen Eingaben wird auch die Ausgabe zweimal ausgegeben, wo liegt der Fehler??</p>
<p>Jetzt kommt die große Frage, wenn ich nicht die TAB Taste drücke, dann sollen erstmal die Eingaben ausgegeben werden wie bei getline(), wie macht man das???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1312973</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1312973</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Sun, 24 Jun 2007 19:30:26 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Mon, 25 Jun 2007 10:41:03 GMT]]></title><description><![CDATA[<p>Habe die Funktion erweitert:</p>
<pre><code class="language-cpp">VOID KeyEventProc(KEY_EVENT_RECORD ker)
{
	//Wartet auf TAB Taste
	if(ker.wVirtualKeyCode == VK_TAB)
	{	
		if(ker.bKeyDown)
			cout &lt;&lt; &quot;#TAB EVENT PRESSED#&quot;;
		else 
			cout &lt;&lt; &quot;#TAB EVENT RELEASED#&quot;;			
	}

	//Wartet auf Enter Taste
	if(ker.wVirtualKeyCode == VK_RETURN)
	{		
		cout &lt;&lt; &quot;NEWLINE&quot; &lt;&lt; endl;
		cout &lt;&lt; &quot;INPUT: &quot; &lt;&lt; input &lt;&lt; endl;
		//Input löschen
		input.clear();
	}

	//Normale String Eingabe
	else
	{
		input += ker.uChar.AsciiChar;		
	}
}
</code></pre>
<ol>
<li>
<p>Wenn ich etwas eingebe dann sehe ich sie nicht in der Console, wie kann ich die Eingaben sichtbar machen?</p>
</li>
<li>
<p>Wieso wird jedes eingegeben Zeichen doppelt gespeichert, wegen dem PRESSSED und RELEASED????</p>
</li>
</ol>
<p>Bitte um Hilfe!!!!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1313227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313227</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Mon, 25 Jun 2007 10:41:03 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Mon, 25 Jun 2007 17:19:45 GMT]]></title><description><![CDATA[<p>Habe noch einiges verändert, das mit den doppelten Zeichen habe ich beseitigt:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

//Eingabe String
string input = &quot;&quot;;

VOID ErrorExit (LPSTR lpszMessage) 
{ 
    fprintf(stderr, &quot;%s\n&quot;, lpszMessage); 
    ExitProcess(0); 
}

//VOID KeyEventProc(KEY_EVENT_RECORD ker, HANDLE  hStdin, DWORD fdwSaveOldMode)
VOID KeyEventProc(KEY_EVENT_RECORD ker)
{
	//Wartet auf TAB Taste
	if(ker.wVirtualKeyCode == VK_TAB)
	{	
		if(ker.bKeyDown)
			cout &lt;&lt; &quot;#TAB EVENT PRESSED#&quot;;
		else 
			cout &lt;&lt; &quot;#TAB EVENT RELEASED#&quot;;			
	}

	//Wartet auf Enter Taste
	else if(ker.wVirtualKeyCode == VK_RETURN)
	{		
		cout &lt;&lt; &quot;NEWLINE&quot; &lt;&lt; endl;
		cout &lt;&lt; input &lt;&lt; endl;
		//Input löschen
		input.clear();
	}

	if(ker.wVirtualKeyCode == VK_BACK)
	{	
		cout &lt;&lt; &quot;löschen&quot; &lt;&lt; endl;
	}	

	//Normale String Eingabe
	else
	{
		//Alte Einstellungen wiederherstellen
		//SetConsoleMode(hStdin, fdwSaveOldMode);

		if(ker.bKeyDown){}
		else
		{
			cout &lt;&lt; &quot;Zeichen: &quot; &lt;&lt; ker.uChar.AsciiChar &lt;&lt; endl;
			input += ker.uChar.AsciiChar;		
		}		
	}	
}

int ReadKeyInput()
{
	HANDLE hStdin; 
    DWORD cNumRead, fdwMode, fdwSaveOldMode, i; 
    INPUT_RECORD irInBuf[128]; 
    int counter=0;

    // Get the standard input handle. 

    hStdin = GetStdHandle(STD_INPUT_HANDLE); 
    if (hStdin == INVALID_HANDLE_VALUE) 
        ErrorExit(TEXT(&quot;GetStdHandle&quot;)); 

    // Save the current input mode, to be restored on exit. 

    if (! GetConsoleMode(hStdin, &amp;fdwSaveOldMode) ) 
        ErrorExit(TEXT(&quot;GetConsoleMode&quot;)); 

    // Enable the window and mouse input events. 

    fdwMode = ENABLE_WINDOW_INPUT; 
    if (! SetConsoleMode(hStdin, fdwMode) ) 
        ErrorExit(TEXT(&quot;SetConsoleMode&quot;)); 

    // Loop to read and handle the input events.  

	while (counter++ &lt;= 100) 
	//while(1)
    {

        // Wait for the events. 
		//if(!ReadConsole(hStdin, irInBuf, 128, &amp;cNumRead, NULL))
		//	ErrorExit(TEXT(&quot;ReadConsole&quot;)); 

        if (! ReadConsoleInput( 
                hStdin,      // input buffer handle 
                irInBuf,     // buffer to read into 
                128,         // size of read buffer 
                &amp;cNumRead) ) // number of records read 
            ErrorExit(TEXT(&quot;ReadConsoleInput&quot;)); 

        // Dispatch the events to the appropriate handler. 

        for (i = 0; i &lt; cNumRead; i++) 
        {
            switch(irInBuf[i].EventType) 
            { 
                case KEY_EVENT: // keyboard input 
                    //KeyEventProc(irInBuf[i].Event.KeyEvent, hStdin, fdwSaveOldMode); 
					KeyEventProc(irInBuf[i].Event.KeyEvent); 
                    break;             
            } 
        }
    } 	 
    return 0; 
}

int main(VOID) 
{	
	ReadKeyInput();   

	return 0;
}
</code></pre>
<p>Ist es überhaupt möglich mit der ReadConsoleInput() Funktion die Eingaben auch auszugeben, denn bei MSDN steht das nur die ReadConsole() Funktion das kann, bitte seht selbst vielleicht hab ich es nicht verstanden: <a href="http://msdn2.microsoft.com/en-us/library/ms686033.aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms686033.aspx</a></p>
<blockquote>
<p>ENABLE_ECHO_INPUT - Characters read by the ReadFile or ReadConsole function are written to the active screen buffer as they are read. This mode can be used only if the ENABLE_LINE_INPUT mode is also enabled.</p>
</blockquote>
<p>Also irgendwie glaube ich in</p>
<pre><code class="language-cpp">cmd.exe
</code></pre>
<p>steckt eine andere funktionsweise, bitte gibt mir weitere Verbesserungsvorschläge/Tipps sonst komme ich nicht weiter <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1313546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1313546</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Mon, 25 Jun 2007 17:19:45 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert die TAB-Vervollständigung bei cmd.exe ??? on Fri, 29 Jun 2007 20:50:28 GMT]]></title><description><![CDATA[<p>Ich frage jetzt ein letztes mal, kann man die TAB Funktion mit der WinAPI realisieren oder wie hat es Microsoft geschafft ????????????????</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1315310</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1315310</guid><dc:creator><![CDATA[kernel64]]></dc:creator><pubDate>Fri, 29 Jun 2007 20:50:28 GMT</pubDate></item></channel></rss>