Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 6th, 2006, 7:01 AM   #1
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,120
Rep Power: 5 lectricpharaoh will become famous soon enough
undeclared identifiers- ack!

Okay, so I have a segment of code which looks something like this:
INPUT inputEvents[4];

inputEvents[0].type = INPUT_KEYBOARD;
inputEvents[1].type = INPUT_KEYBOARD;
inputEvents[2].type = INPUT_KEYBOARD;
inputEvents[3].type = INPUT_KEYBOARD;
inputEvents[0].ki.wVk = VK_CONTROL;
inputEvents[0].ki.dwFlags = 0;
inputEvents[1].ki.wVk = VK_ESCAPE;
inputEvents[1].ki.dwFlags = 0;
inputEvents[2].ki.wVk = VK_ESCAPE;
inputEvents[2].ki.dwFlags = KEYEVENTF_KEYUP;
inputEvents[3].ki.wVk = VK_CONTROL;
inputEvents[3].ki.dwFlags = KEYEVENTF_KEYUP;
I am wanting to use the SendInput function to simulate keyboard input. For the snippet above, I am attempting to create four keyboard events representing a press of the control key, press of the escape key, release of the escape key, and release of the control key, in that order. As this is just a test, alternate suggestions of how to open the start menu aren't what I'm looking for; when the program is complete, I intend it to be able to accept mouse (stylus) and keyboard events on my PocketPC, and relay them wirelessly to a program running on a Windows desktop, which will simulate them through the SendInput() function, essentially acting as a remote control for my PC.

Anyways, on to my problem. Both my locally-installed MSDN library and msdn.microsoft.com tell me that INPUT, INPUT_KEYBOARD, and SendInput() are declared in winuser.h, and for me to simply include windows.h. However, whenever I try to compile the code, I receive errors about them being undeclared identifiers. I've looked at winuser.h, and the definition is there; why then can't the compiler see it? I receive the same undefined identifiers using VS.NET 2003 and DevC++, and I have tried both explicitly including the winuser.h header, and letting it be implicitly included through windows.h.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Aug 6th, 2006, 7:19 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,254
Rep Power: 5 grumpy will become famous soon enough
The most common reason is that some macro is not defined. Have you set up your application as a windows application or as a console application? If you are building as a console application, there will be various #ifdef .... #endif blocks that might mean the compiler doesn't see some identifiers in the header files.
grumpy is offline   Reply With Quote
Old Aug 6th, 2006, 7:37 AM   #3
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,120
Rep Power: 5 lectricpharaoh will become famous soon enough
I don't believe that's the problem, as with both compilers, I said 'Windows application' when initially creating the project. I'm utterly stumped on this one, but I have a sneaking suspicion that when I do get it worked out, I'll feel like a complete moron.

In other words: your solution's too subtle. I'm probably overlooking something much more obvious.

[edit] I got it figured out. It wasn't the console/'regular' app #define. It was the version; sticking in #define _WIN32_WINNT 0x0500 before #include "windows.h" fixed it.

Now I can progress to the interesting parts of my program. I guess it's time for learning sockets programming with my patented 'trial by fire' approach at learning. [/edit]
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick

Last edited by lectricpharaoh; Aug 6th, 2006 at 8:03 AM.
lectricpharaoh is offline   Reply With Quote
Old Aug 6th, 2006, 8:48 AM   #4
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,254
Rep Power: 5 grumpy will become famous soon enough
Quote:
Originally Posted by lectricpharaoh
I got it figured out. It wasn't the console/'regular' app #define. It was the version; sticking in #define _WIN32_WINNT 0x0500 before #include "windows.h" fixed it.
Yep. A macro not defined, as I said. The most common way of having some macro undefined is to create a console application, but I wasn't suggesting it as the only cause. _WIN32_WINNT is required to have a value of 0x0500 is targetting (IIRC) windows 2000 or later. If you've been tweaking compiler or project settings, you've probably tweaked something related to what operating system you're targeting, or something related to standard compliance (eg targeting a windows application requires turning off some compliance with the C++ standard. Depending on compiler, turning standard compliance on turns off #defines like _WIN32_WINNT).
grumpy is offline   Reply With Quote
Old Aug 6th, 2006, 5:45 PM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,120
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by grumpy
Yep. A macro not defined, as I said. The most common way of having some macro undefined is to create a console application, but I wasn't suggesting it as the only cause. _WIN32_WINNT is required to have a value of 0x0500 is targetting (IIRC) windows 2000 or later. If you've been tweaking compiler or project settings, you've probably tweaked something related to what operating system you're targeting, or something related to standard compliance (eg targeting a windows application requires turning off some compliance with the C++ standard. Depending on compiler, turning standard compliance on turns off #defines like _WIN32_WINNT).
Yeah, I initially discounted it because I hadn't changed any settings from the defaults in place (I'd simply created an empty project in both DevC++ and VS.NET). Also, the MSDN docs said it worked in Win98 and up, and implied it might work in Win95 as well, and like you, I was under the impression a version code of 5.00+ was Win2K and up, so I'm still puzzled why I'd need to define this symbol.

Ahh well. I've gotta get back to coding, and trying to understand the vagaries of the MS development people is an exercise in futility.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
undeclared identifier... Kilo C++ 10 May 22nd, 2006 6:57 PM
error C2065: 'unit_counter2' : undeclared identifier Ade C++ 6 May 15th, 2006 8:11 AM
libraries matko C 1 Jan 22nd, 2006 3:12 PM
Undeclared Identifier 'Dini' Gc671 Delphi 3 Jan 4th, 2006 5:24 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC