///////two symbols middle copy from the Internet//////////
To be introduced at the beginning the namespace
Using System. The Runtime. InteropServices;
Gets the current window handle: GetForegroundWindow ()
[DllImport (" user32. DLL, "CharSet=CharSet. Auto, ExactSpelling=true)]
Public static extern IntPtr GetForegroundWindow ();
The return value type is IntPtr that for the current gains focus window handle
Method of use: IntPtr myPtr=GetForegroundWindow ();
/////////////////
According to the above methods, the I found an error, as shown in figure
What is how to write?
I wrote is today with the wizard button a window procedure, operation form in the game window screen, see the F7 key, automatically get the game window handle, automatic button and then the background, and in the evening want to use c # to achieve this function, retrieve the user key, found that the c # how to realize and get the window handle, and then to the background behind the key, also want to, give advice or comments
CodePudding user response:
To encapsulate a hook to catch shortcut keys, and then with a c + + Sendmessage, keystroke messages sent,