| View previous topic :: View next topic |
| Author |
Message |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Wed Dec 03, 2008 12:14 am Post subject: [help] error C2448: 'GetAsyncKeyState' : |
|
|
error C2448: 'GetAsyncKeyState' : function-style initializer appears to be a function definition
I r searched all on the interwebs and can't find the problem..
GetAsyncKeyState(VK_F4){
bExit = true;
}
GetAsyncKeyState(VK_F5){
bExit = false;
}
_________________
| qwerty147 wrote: |
| ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Dec 03, 2008 12:52 am Post subject: |
|
|
You're using it like you're defining a function, just like the error says.
You forget the if statement. You're not checking the return at all, just simply calling it.
|
|
| Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Wed Dec 03, 2008 1:59 am Post subject: |
|
|
Are people just trolling this section now? It is getting ridiculous.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Dec 03, 2008 5:46 am Post subject: |
|
|
At least he gave him an answer and wasn't just like YOU NOOB LEARN TO USE IF
anyways. You know your problem now.
_________________
|
|
| Back to top |
|
 |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Wed Dec 03, 2008 10:37 am Post subject: |
|
|
I did use IF, but then I get diff errors...
1>.\lolkeyz.cpp(31) : error C2059: syntax error : 'if'
1>.\lolkeyz.cpp(31) : error C2143: syntax error : missing ';' before '{'
1>.\lolkeyz.cpp(31) : error C2447: '{' : missing function header (old-style formal list?)
1>.\lolkeyz.cpp(35) : error C2059: syntax error : 'if'
1>.\lolkeyz.cpp(35) : error C2143: syntax error : missing ';' before '{'
1>.\lolkeyz.cpp(35) : error C2447: '{' : missing function header (old-style formal list?)
if(GetAsyncKeyState(VK_F5)){
bExit = true;
keyDown();
}
if(GetAsyncKeyState(VK_F4)){
bExit = false;
keyUp();
}
and if i do
if(GetAsyncKeyState(VK_F5))
bExit = true
keyDown();
if(GetAsyncKeyState(VK_F4))
bExit = false
keyUp();
1>.\lolkeyz.cpp(31) : error C2059: syntax error : 'if'
1>.\lolkeyz.cpp(34) : error C2059: syntax error : 'if'
_________________
| qwerty147 wrote: |
| ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Dec 03, 2008 10:42 am Post subject: |
|
|
| Code: | if(GetAsyncKeyState(VK_F5) < 0){
bExit = true;
keyDown();
}
if(GetAsyncKeyState(VK_F4) < 0){
bExit = false;
keyUp();
} |
|
|
| Back to top |
|
 |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Wed Dec 03, 2008 12:30 pm Post subject: |
|
|
ehh, that gives
| Code: | 1>.\lolkeyz.cpp(31) : error C2059: syntax error : 'if'
1>.\lolkeyz.cpp(31) : error C2143: syntax error : missing ';' before '{'
1>.\lolkeyz.cpp(31) : error C2447: '{' : missing function header (old-style formal list?)
1>.\lolkeyz.cpp(35) : error C2059: syntax error : 'if'
1>.\lolkeyz.cpp(35) : error C2143: syntax error : missing ';' before '{'
1>.\lolkeyz.cpp(35) : error C2447: '{' : missing function header (old-style formal list?) |
| Code: |
// lolkeyz.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
#include <windows.h>
BOOL bExit = false;
using namespace lolkeyz;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
void keyDown(){
while(bExit){
keybd_event(VK_SPACE, 0, 0, 0);
}
}
void keyUp(){
while(!bExit){
keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0);
}
}
if(GetAsyncKeyState(VK_F5) < 0){
bExit = true;
keyDown();
}
if(GetAsyncKeyState(VK_F4) < 0){
bExit = false;
keyUp();
}
|
_________________
| qwerty147 wrote: |
| ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Dec 03, 2008 12:33 pm Post subject: |
|
|
Learn the syntax instead of asking us to fix your code... your conditions aren't even in any code block.
And don't use managed C++, it sucks, better use C++, or if you prefer .NET then C#, but not C++.NET.
|
|
| Back to top |
|
 |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Wed Dec 03, 2008 12:35 pm Post subject: |
|
|
Well, I put it in void GetKeys(); and now I get linker errors.
1>main.obj : error LNK2028: unresolved token (0A00000A) "extern "C" short __stdcall GetAsyncKeyState(int)" (?GetAsyncKeyState@@$$J14YGFH@Z) referenced in function "void __clrcall CheckKey(void)" (?CheckKey@@$$FYMXXZ)
1>main.obj : error LNK2028: unresolved token (0A00000B) "extern "C" void __stdcall keybd_event(unsigned char,unsigned char,unsigned long,unsigned long)" (?keybd_event@@$$J216YGXEEKK@Z) referenced in function "void __clrcall keyDown(void)" (?keyDown@@$$FYMXXZ)
1>main.obj : error LNK2019: unresolved external symbol "extern "C" void __stdcall keybd_event(unsigned char,unsigned char,unsigned long,unsigned long)" (?keybd_event@@$$J216YGXEEKK@Z) referenced in function "void __clrcall keyDown(void)" (?keyDown@@$$FYMXXZ)
1>main.obj : error LNK2019: unresolved external symbol "extern "C" short __stdcall GetAsyncKeyState(int)" (?GetAsyncKeyState@@$$J14YGFH@Z) referenced in function "void __clrcall CheckKey(void)" (?CheckKey@@$$FYMXXZ)
_________________
| qwerty147 wrote: |
| ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Wed Dec 03, 2008 2:03 pm Post subject: |
|
|
Link to user32.lib in project settings or add #pragma comment(lib, "user32.lib") to the top of your source code.. and stop using c++.net
|
|
| Back to top |
|
 |
kb3z0n Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 542
|
Posted: Wed Dec 03, 2008 2:39 pm Post subject: |
|
|
if(GetAsnycKeyState(VK_F5))
{
bExit = true;
}
if(GetAsyncKeyState(VK_F4))
{
bExit = false;
}
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Dec 03, 2008 3:49 pm Post subject: |
|
|
1. Don't use managed C++, there's no support for it. Use native C++, or C#.
2. You just have your shit laying around, it's not within any code block...
3. Go do some reading, and learn the damn basics already.
|
|
| Back to top |
|
 |
|