-8

I have posted here entier code cuz myb I made bad struct or put some functions on wrong place . But It doesnt make sens for me why I am getting Error on LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) ,and it doesnt make sens to put ; after it. If someone have time to check code and give me advice how to fix this or realize this on easier way ,I will be very thankful.

error

  int main()
    {
        int togler;
        int g;
        HHOOK MouseHook;
        HHOOK hhkLowLevelKybd;
        bool SupressMouseHook = false;
        bool click = false;
        LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
        {
            BOOL eatMouseStroke2 = false;
            if (!SupressMouseHook) {
                BOOL eatMouseStroke = false;
                if (togler == 1) {
                    if (wParam == WM_LBUTTONDOWN) {
                        click = true;
                    }
                    else if (wParam == WM_LBUTTONUP) {
                        click = false;
                    }
                }
                return(eatMouseStroke ? 1 : CallNextHookEx(NULL, nCode, wParam, lParam));
            }
            else {
                BOOL eatMouseStroke = false;
                return(eatMouseStroke ? 1 : CallNextHookEx(NULL, nCode, wParam, lParam));
            }
            return(eatMouseStroke2 ? 1 : CallNextHookEx(NULL, nCode, wParam, lParam));
        }
        MouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, GetModuleHandle(NULL), 0);
        CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)clicker, NULL, NULL, NULL);

    }
  • 1
    There is waaaaaaaaaaaaaaaaaaaaayy too much code here, please reduce this to a [mcve] to allow people a chance to answer – Tas Aug 08 '18 at 11:17
  • Please provide a [mcve], ie remove code in tiny steps until the error is gone, then go one step back to have the minimal code that reproduces the error (eg you dont need the blank lines ;) – 463035818_is_not_an_ai Aug 08 '18 at 11:18
  • you are right but,as I already said it wont give me error if I just put LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) without this entier code. – Novak Jovanovic Aug 08 '18 at 11:20
  • @user463035818 on blank lines there was more code – Novak Jovanovic Aug 08 '18 at 11:21
  • btw less code means less errors, good example is : `bool toggle = false; if (toggle = false)` ... – 463035818_is_not_an_ai Aug 08 '18 at 11:21
  • then why didnt you remove the blanks ? – 463035818_is_not_an_ai Aug 08 '18 at 11:22
  • It's good that you've reduced the code a bit. However, you seem to have removed the necessary `#include` lines needed to compile! Add back those that are needed (but not the monster set from your original program). – Toby Speight Aug 08 '18 at 13:34
  • @TobySpeight thanks but I have already repaired, can I somehow close a post or mark it as finished? – Novak Jovanovic Aug 08 '18 at 16:02
  • 1
    Now you have an accepted answer, it's probably best left - if you do make an edit, be sure to check that it doesn't invalidate the answer. I recommend that you have a good read of [mcve] to see what's expected before you next ask a question - that will help you get the answers you need. – Toby Speight Aug 09 '18 at 07:04
  • BTW accepting an answer (as you have done) is the correct way to "mark it as finished". So you've already done the right thing there. :-) – Toby Speight Aug 09 '18 at 07:08

1 Answers1

3

You should move MouseHookProc definition outside of main. C++ does not allow function definitions inside of other functions.

Among other things, (LPTHREAD_START_ROUTINE)clicker is also wrong, there is no need to perform cast here, instead clicker function must have correct signature, void down(); is actually a function declaration, not invocation.

user7860670
  • 35,849
  • 4
  • 58
  • 84
  • 1
    @NovakJovanovic I guess you should check some [C++ tutorials first](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list?s=1|525.4322) to get a solid understand of function declaration and invocation first so you won't struggle at every step. – user7860670 Aug 08 '18 at 11:27
  • thanks for help just fixed my problem ,most of the code I was doing in late hours soo didnt rly realize what I am doing. – Novak Jovanovic Aug 08 '18 at 11:37