BlockInput not working

Hi guys does anyone know why blockinput function isn't working?

It says error BlockInput was not declared in this scope



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


#include <iostream>
#include <windows.h>

using namespace std;

int main()
{

   FreeConsole();

   while(1){
   BlockInput(true);
   }


}

Maybe because BlockInput was not declared in that scope. Do you know what that means?

Is there any function in the iostream library named BlockInput?

Is there any function declared in Windows.h or any file included by Windows.h that declares a function named BlockInput?

If neither of the above are true you'll get a BlockInput was not declared in this scope message.
to be honest no I'm not 100% sure what it means,what is it?

and yeah I think it's a function in the windows.h library i just a tutorial on youtube with someone using it and he just included the window.h header file and it worked just fine for him
According to the documentation, it should be in the header <Winuser.h>
Though Mingw seems to have it in <Winable.h>

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646290%28v=vs.85%29.aspx

By the way, it's not a good idea to have a while loop such as you have, it will probably consume excessive CPU resources.

Here's an example, it blocks, sleeps for 5 seconds, then unblocks again.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <windows.h>
#include <winuser.h>
#include <winable.h>

int main()
{
    std::cout << "Start\n";

    BlockInput(true);

    Sleep(5000);    
    
    BlockInput(false);
    
    std::cout << "Done\n";

}

that's even better man thanks,how do you know or find out if a function belongs to a certain header?

Thanks
how do you know or find out if a function belongs to a certain header?

First place to look is the reference documentation - standard C and C++ functions are detailed on this site. For Windows functions, consult the Microsoft documentation.

However - a second way, when all else fails is to do a search of all the header files in your compiler's include directory(s).
Last edited on
thanks Chervil just one question how do you actually do a search of the header files in your compiler's directorys
On Windows, you could try the windows file search function - though this can be unreliable.

Other systems, use grep.
https://en.wikipedia.org/wiki/Grep

Also on Windows, you might consider http://www.wingrep.com/

When searching, a search of all files *.* and all directories would be a last resort when completely lost. Warning - this can take a very long time to complete. Ideally specify the directory(s) and file types (such as *.h or *.hpp) and it should run much more quickly.
Last edited on
thanks guys
Topic archived. No new replies allowed.