I am using VS2008, OS win vista. i am in the process of coding an application that would tab automatically (this is just an example, not the code i am intending to do).

So basically, what i expect is to write a C++ code that could press the 'tab' button twice from the code it it self. Can someone point me the correct google search terms or a tutorial to get familiar with these.

Thank you

6 Years
Discussion Span
Last Post by Fbody

What do you mean by "press the 'tab' button twice"?

If you want to use a tab to push console output to the right a few lines, use the '\t' escape character.

#include <iostream>

using namespace std;

int main() {
  cout << "\t\tThis output is tabbed over..." << endl;
  cout << "This output is not..." << endl;
  return 0;

If you're trying to move through a GUI with the TAB, I'm afraid I can't help you.

Edited by Fbody: Small code glitch


No you got me wrong. For example. when we click the 'tab' button on the keyboard, it sets focus to the next tab index, right ?? so what i need to do is to enter these tabs from the code instead of using the keyboard to set focus to the next tab index.

hope i made it clear.


So you're trying to move around a GUI. As I mentioned before, I can't help you with that one... I don't do GUIs.

I know there is a way to set the default focus. Is that what you are trying to do is automatically set the focus? I believe you have to set the "tabstop" (or whatever the proper property name is) to 0 to make that the default focus. But that's all I can offer you.

Edited by Fbody: n/a


I know there is a series of constants that can be used to identify the keys on the keyboard, you'll probably have to use one of those.

Try searching for "Windows Keyboard Codes" and similar. Then, if there is a way to send (rather than receive) the constant/code for a key, send the appropriate one for TAB.

Edited by Fbody: n/a

This article has been dead for over six months. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.