![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2005
Posts: 19
Rep Power: 0
![]() |
Get Focus from a Console App?
Anybody know how I can get the focus from a console application?
I've tried geting the HWND and using SetFocus but that appears not to work. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jun 2005
Posts: 86
Rep Power: 4
![]() |
You want the console window that your app is running under to get the focus? If so, here's what you do (the first 5 instructions are per a Microsoft KB article from a long time ago):
1. Use GetConsoleTitle() to get the current title of the Console Window 2. Use SetConsoleTitle() to set the title of the current window to something unique. 3. Sleep(50) milliseconds for the title to update 4. Use FindWindow() to get the Window handle by the new title name 5. Restore the original title with SetConsoleTitle(). 6. Bring the console window to the foreground with SetForegroundWindow() and pass the window handle for the console window to it. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Aug 2005
Posts: 19
Rep Power: 0
![]() |
Thanks, I'd got all of that apart from I was using SetFocus instead of SetForeGroundWindow.
Quick Easy answer I like that thanks. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|