2,640
社区成员
发帖
与我相关
我的任务
分享
CallWindowProcA(
WNDPROC lpPrevWndFunc,
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam)
int Hotkey_Bind=VK_LSHIFT;
if(GetAsyncKeyState(Hotkey_Bind)&0x8000)
{
SetCursorPos(Mx, My);
}
LRESULT CALLBACK LowLevelkeyboardProc(
int nCode,
WPARAM wParam, // message identifier
LRESULT lParam //keyboard
)
{
if (g_hWnd/*程序窗口句柄*/!=NULL&&nCode==HC_ACTION)
{
::SendMessage(g_hWnd,WM_MYMSG,wParam,lParam);
if (wParam==0x10)
{
CallWindowProcA(ShiftDown,g_hWnd,NULL,NULL,NULL);
/*问题就出在自己想写一个ShiftDown函数,文化不够,一直写不出来*/
}
}
return CallNextHookEx(hhkkeyboard/*SetWindowsHookEx返回*/,nCode,wParam,lParam);
}
if (shiftkey==1)
{
AfxMessageBox(_T("成功了"));
}
HWND g_hDlg,g_hGame;
DWORD g_threadId;
HHOOK g_Hook = NULL;
HINSTANCE g_hInstance = NULL;
LRESULT CALLBACK MyKeyProc(
int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
DWORD stay=GetKeyState(VK_HOME);
if (stay==0)
{
TCHAR Buf[20];
wsprintf(Buf,"%x",stay);
MessageBox(0,Buf,"",0);
if (IsWindowVisible(g_hDlg))
{
ShowWindow(g_hDlg,SW_HIDE);
}
else
{
ShowWindow(g_hDlg,SW_SHOW);
}
}
//
return 1;
}
//
void SetHook()
{ //HWND hGame=FindWindow("Afx:00400000:b:00010003:01900011:00000000",NULL);
g_hGame=FindWindow(0,"Blood_war");
if(g_hGame != 0)
{
g_threadId=GetWindowThreadProcessId(g_hGame,NULL);
g_Hook=SetWindowsHookEx(13,(HOOKPROC)MyKeyProc,g_hInstance,g_threadId);
}
}
WNDPROC g_OldProc;
LRESULT CALLBACK NewProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
CPoint pt;
switch(message)
{
case WM_ACTIVATE:
ShowCursor(FALSE);
break;
case WM_DESTROY:
ShowCursor(TRUE);
break;
case WM_MOUSEMOVE:
pt.x = (int) LOWORD(lParam);
pt.y = (int) HIWORD(lParam);
afxDump << pt << "\n";
break;
}
return CallWindowProc(g_OldProc, hwnd, message, wParam, lParam);
}
CallWindowProc
The CallWindowProc function passes message information to the specified window procedure.
LRESULT CallWindowProc(
WNDPROC lpPrevWndFunc, // pointer to previous procedure
HWND hWnd, // handle to window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
Parameters
lpPrevWndFunc
Pointer to the previous window procedure.
If this value is obtained by calling the GetWindowLong function with the nIndex parameter set to GWL_WNDPROC or DWL_DLGPROC, it is actually either the address of a window or dialog box procedure, or a handle representing that address.
hWnd
Handle to the window procedure to receive the message.
Msg
Specifies the message.
wParam
Specifies additional message-specific information. The contents of this parameter depend on the value of the Msg parameter.
lParam
Specifies additional message-specific information. The contents of this parameter depend on the value of the Msg parameter.
Return Values
The return value specifies the result of the message processing and depends on the message sent.
Remarks
Use the CallWindowProc function for window subclassing. Usually, all windows with the same class share one window procedure. A subclass is a window or set of windows with the same class whose messages are intercepted and processed by another window procedure (or procedures) before being passed to the window procedure of the class.
The SetWindowLong function creates the subclass by changing the window procedure associated with a particular window, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.
If STRICT is defined, the lpPrevWndFunc parameter has the data typeWNDPROC. The WNDPROC type is declared as follows:
LRESULT (CALLBACK* WNDPROC) (HWND, UINT, WPARAM, LPARAM);
If STRICT is not defined, the lpPrevWndFunc parameter has the data typeFARPROC. The FARPROC type is declared as follows:
int (FAR WINAPI * FARPROC) ()
In C, the FARPROC declaration indicates a callback function that has an unspecified parameter list. In C++, however, the empty parameter list in the declaration indicates that a function has no parameters. This subtle distinction can break careless code. Following is one way to handle this situation:
#ifdef STRICT
WNDPROC MyWindowProcedure
#else
FARPROC MyWindowProcedure
#endif
...
lResult = CallWindowProc(MyWindowProcedure, ...) ;
For further information about functions declared with empty argument lists, refer to The C++ Programming Language, Second Edition, by Bjarne Stroustrup.
Windows NT: The CallWindowProc function handles Unicode-to-ANSI conversion. You cannot take advantage of this conversion if you call the window procedure directly.
LRESULT CALLBACK LowLevelKeyboardProc(
int nCode, // hook code
WPARAM wParam, // message identifier
LPARAM lParam // pointer to structure with message data
);
Parameters
nCode
Specifies a code the hook procedure uses to determine how to process the message. This parameter can be one of the following values: Value Meaning
HC_ACTION The wParam and lParam parameters contain information about a keyboard message.
If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx.
wParam
Specifies the identifier of the keyboard message. This parameter can be one of the following messages:WM_KEYDOWN,WM_KEYUP,WM_SYSKEYDOWN, orWM_SYSKEYUP.
lParam
Pointer to the KBDLLHOOKSTRUCT structure.