Usually, there are a lot of things that happen:
When we run some programs, we find that the button is grayed out, such as buying a copyright or entering a serial number to gain access. A button is not allowed to click.
In fact, all of these things are other people or companies use some programming language to invoke Windows functions, implemented. So if we can also invoke The functions of windows, then we can execute some buttons or functions behind something.
Your own MFC can not be used for the time being, but try this.
Bring up this interface and see a set of gray Settings button. We can try to invoke this later function.
/* How do I pull it out? "In a Win7 environment "
Open Control Panel
Click the mouse. */
Then use the vs tool in the Spy + + x64.
Go to the Find window.
Stall this to the gray button on the mouse just now. You can get a handle.
The handle "in my understanding, is a word, how to explain, that is, others say one thing, you have to go down to say the words next, and then finish what you want to say." Inside the program, execution here, there is a handle that allows us to speak, and we start with that, and as we go down, we tend to get the results we want. "
So get the handle after it. We can create a new project.
#include <windows.h>int main () { SendMessage (0x001607e6, Wm_lbuttondown,0 ,0);
SendMessage (0x001607e6, Wm_lbuttonup,0,0); return 0 ;}
Enter the handle you just entered in the first argument of the HWND.
guess the second parameter is windowmanager_leftbuttondown, which is the window Manager left button point.
then the left-click button bounces up.
A message is sent to a function that was just unable to execute. The previous citation said that this is called the Windows Underlying some functions, if the button can be clicked, then the mouse click, Button Press, when the need to register, or need a serial number when we did not, we can not click. But when we send him a message, the problem is solved.
If you can compile it, you can see a result:
If the compilation does not pass:
5 F:\c++codeindev\c++\forceclick.cpp [Error] Invalid conversion from ' int. ' to ' HWND ' [-fpermissive]
Will report such a mistake.
Invalid conversions from int to HWND.
Inside the handle we get a 001607E6, which is a decimal number that identifies a unit in which the button is specified. Each rebuild will be different. The description is each time the window is created to allocate memory. We're going to put 0x001607e6 in here to Identify this is a memory address. But that's not enough, what is this memory unit essentially, exactly? He is an HWND type of thing.
This involves coercion of type conversions.
Is that we can go to the memory to get one and get a space. For example , int A, this a does not give initialization, its result does not want Java inside to give a 0, but The original content is what is what, and then assign value, and then the original contents covered, is such a situation. If there is something in this, then we can export this thing in any form. for example, int like double, for example, we can export it as any type.
To cite such an example:
#include <stdio.h>Int main () { 10.2; 10.2/2; Printf ("%f\n", f); Printf ("%d\b", f);}
The operating result is:
So it can be found that the number of numbers in memory is always there, but depends on how we output. So general-purpose just 001607E6 This address inside of the thing, is always there, if you take out in int form, it is such a heap of numbers, the compiler will report an int is not an hwnd type of thing, then we go to fetch content when it becomes the HWND type, and then to the program, it can be passed.
So the code after the change is:
int Main () {SendMessage (HWND)0x001607e6, Wm_lbuttondown,0,0); // 5 f:\c++codeindev\c++\forceclick.cpp [Error] Invalid conversion from ' int. ' to ' HWND ' [-fpermissive] SendMessage (HWND)0x001607e6, Wm_lbuttonup,0,0); return 0 ; }
So that it can be executed.
The same:
We can also do some small bad things:
In fact, it is not so magical, is called the Windows underlying functions,windows itself using the function called the place settexta("OK") Then we modify it and it executes our function.
So it turned out this way.
Force click with C language