Desktop Focus

Hi I'm new to C++ and I'm trying to make a simple program that buffers text and presses the windows button for me whenever I finish typing "on the desktop".

I think I can handle everything here except for detecting whether or not the desktop window is the window that is in focus.

I found this: http://www.daniweb.com/forums/thread272512.html
but I couldn't find the file that the methods he used come from.

I then found this: http://msdn.microsoft.com/en-us/library/ms633512(VS.85).aspx
But when I tried to compile this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "stdafx.h"
#include "Winuser.h"
#include <iostream>

using namespace std;


int main()
{		
		int y;
		cin>>y;

		return 0;
}


I got:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
1>  ConsoleApp.cpp
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(46): error C2146: syntax error : missing ';' before identifier 'HDWP'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(46): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(46): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(47): error C2146: syntax error : missing ';' before identifier 'MENUTEMPLATEA'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(54): error C2146: syntax error : missing ';' before identifier 'LPMENUTEMPLATEA'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(54): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(54): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(62): error C2065: 'CALLBACK' : undeclared identifier
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(62): error C2065: 'WNDPROC' : undeclared identifier
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(62): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(62): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Help would be much appreciated, I really want to start doing some practical programming in C++ and move away from Java :p.
You shouldn't be including Winuser.h

Typically if you need windows stuff, you include <Windows.h>.

Also, cin stands for "console in", so it only accepts input from the console, not the desktop.
Last edited on
Wow thanks that part is working now : ).
The console in thing was just to stop the program from automatically terminating.
Last edited on
Topic archived. No new replies allowed.