我正试图挂钩第三方应用程序,以便我可以绘制到它的屏幕.在屏幕上绘图是容易的,我需要它没有帮助,但我似乎有使用问题SetWindowsHookEx来处理WH_GETMESSAGE.我无法弄清楚最后两个参数传递的内容.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowDrawer
{
public partial class Form1 : Form
{
private delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
static IntPtr hHook;
IntPtr windowHandle;
uint processHandle;
HookProc PaintHookProcedure;
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern System.IntPtr FindWindowByCaption(int ZeroOnly, string lpWindowName);
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetWindowsHookEx", SetLastError = true)]
static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hMod, uint …Run Code Online (Sandbox Code Playgroud) 如果我有一个控制台应用程序,其句柄设置如此;
HWND hWnd = GetConsoleWindow();
Run Code Online (Sandbox Code Playgroud)
那我该如何为窗口设置一个新的wndProc呢?
我试过用
SetWindowLong(hWnd, GWL_WNDPROC, (LONG)conProc);
Run Code Online (Sandbox Code Playgroud)
将conProc定义为
LRESULT CALLBACK conProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_NCHITTEST:
return HTCAPTION;
}
return DefWindowProc(hWnd, msg, wParam, lParam );
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用,并说"错误代码:5 - 访问被拒绝" GetLastError()
我知道修改这样的控制台应用程序非常困难,因为它是一个csrss.exe应用程序,但我仍然想尝试..谢谢.
我想利用机器学习来模拟用户的意图,并可能使常用任务自动化.为此,我希望能够访问有关用户操作和机器状态的信息.为此,我目前认为访问Windows消息流可能是前进的方向.
我想尽可能多地获取信息,将信息过滤到我想留给机器学习工具的相关信息.
这将如何实现?(最好在C#中).
请假设我知道如何管理和使用这些大量数据.
任何帮助将不胜感激.