expected unqualified-id before ')' token

I managed to get rid of all errors I've had with this except for one.

In line 42 error: expected unqualified-id before ')' token. I don't really program anything in any language so I'm pretty helpless when it comes to errors I never heard of. I Googled this one and found a bunch of other people with this error but I didn't manage to fix it. Any help is greatly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <ctime>
#include <windows.h>
#include <stdio.h>

POINT Center, CurPos;
bool FirstTime=true;
int SendKeyPress(unsigned short KeyCode, bool IsDown);

int main()
{
    printf("Mouse4 to set strafe center point");
    while(true)
    {
        if(GetAsyncKeyState(0x05) & (1 << 15))
        {
            if(FirstTime)
            {
                GetCursorPos(&Center);
                FirstTime=false;
                printf("Strafebot activated\nHold Mouse4 to strafe\n");
                MessageBox(NULL, "Center Position Set", "Strafe Bot", MB_OK);
            }
            GetCursorPos(&CurPos);
            if(CurPos.x > Center.x)
            {
                SendKeyPress(0x20, true);
                Sleep(1);
                SendKeyPress(0x20, false);
            }
            else if(CurPos.x < Center.x)
            {
                SendKeyPress(0x1e, true);
                Sleep(1);
                SendKeyPress(0x1e, false);
            }
        }
    }
    return 0;
}

struct SendKeyPress() // this is where the error is
{
    INPUT InputData;
    InputData.type                  = INPUT_KEYBOARD;
    InputData.ki.wScan              = KeyCode;
    InputData.ki.time               = time(NULL);
    InputData.ki.dwExtraInfo        = 0;
    if(KeyDown) {
        InputData.ki.dwFlags = KEYEVENTF_SCANCODE;
    }
    else {
        InputData.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
    }

    return SendInput(1, &InputData, sizeof(InputData));
}


If you could quickly look over it and maybe let me know what culd be improved that would be nice as well.

Thanks in advance!
Last edited on
On line 8 you have:
int SendKeyPress(unsigned short KeyCode, bool IsDown);
but on line 42 you have:
struct SendKeyPress()

I feel like you were intending SendKeyPress to be a function, not a struct.
Topic archived. No new replies allowed.