按键精灵8,获取句柄有些只有窗口类名,没有窗口标题,该怎么办

按键精灵8,获取句柄有些只有窗口类名,没有窗口标题,该怎么办,第1张

你是想模拟按键么

首先要获得窗口句柄 用下面的函数应该能找到:

FindWindow根据类名\窗口标题寻找窗口

遍历顶层窗口EnumWindows

遍历窗口回调函数EnumWindowProc

遍历父窗口的所有子窗口EnumChildWindows

返回父窗口Point处的子窗口ChildWindowFromPoint

ChildWindowFromPointEx多一个参数UINT来忽略不可见无效透明的子窗口

获取与指定窗口具有莫种关系的窗口GetWindow

获取父窗口的子窗口中Z序最大的子窗口GetTopWindow

获取指定窗口相同层次Z序差1的窗口GetNextWindow

获取桌面窗口句柄GetDesktopWindow

用SendMessage函数不需要窗口标题的,只要句柄

LRESULT SendMessage(

HWND hWnd, // handle of destination window

UINT Msg, // message to send

WPARAM wParam, // first message parameter

LPARAM lParam // second message parameter

);

或者用keybd_event函数,要先用SetForegroundWindow函数把目标窗口设置成前台窗口

VOID keybd_event(

BYTE bVk, // virtual-key code

BYTE bScan, // hardware scan code

DWORD dwFlags, // flags specifying various function options

DWORD dwExtraInfo // additional data associated with keystroke

);

补充:

第一个:我进入某个游戏,用CE查到内存地址后,退出游戏,再查内存地址,两个内存地址是不一样的,有什么办法可以让每次的内存地址都一样?或者说下别的解决方法?

不让每次的内存地址都一样应该是做不到的,游戏每次运行由系统分配内存,哪能让你控制啊。

第二个:我想让鼠标在内存数值到某一个数值时,鼠标移动到某点进行鼠标 *** 作,该怎么写源代码?

定义一个指针变量p,类型根据你需要的数值而定

p=该内存地址

if(p==该数值)

{

//mousemove

}

一个网上的例子

c# 获取鼠标处窗口句柄,程序嵌入桌面

using System;

using SystemCollectionsGeneric;

using SystemComponentModel;

using SystemData;

using SystemDrawing;

using SystemText;

using SystemWindowsForms;

using SystemRuntimeInteropServices;

namespace WindowsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

[DllImport("user32dll", EntryPoint = "FindWindow")]

public static extern int FindWindow(

string lpClassName,

string lpWindowName

);

[DllImport("user32dll", EntryPoint = "GetWindow")]//获取窗体句柄,hwnd为源窗口句柄

/wCmd指定结果窗口与源窗口的关系,它们建立在下述常数基础上:

GW_CHILD

寻找源窗口的第一个子窗口

GW_HWNDFIRST

为一个源子窗口寻找第一个兄弟(同级)窗口,或寻找第一个顶级窗口

GW_HWNDLAST

为一个源子窗口寻找最后一个兄弟(同级)窗口,或寻找最后一个顶级窗口

GW_HWNDNEXT

为源窗口寻找下一个兄弟窗口

GW_HWNDPREV

为源窗口寻找前一个兄弟窗口

GW_OWNER

寻找窗口的所有者

/

public static extern int GetWindow(

int hwnd,

int wCmd

);

[DllImport("user32dll", EntryPoint = "SetParent")]//设置父窗体

public static extern int SetParent(

int hWndChild,

int hWndNewParent

);

[DllImport("user32dll", EntryPoint = "GetCursorPos")]//获取鼠标坐标

public static extern int GetCursorPos(

ref POINTAPI lpPoint

);

[StructLayout(LayoutKindSequential)]//定义与API相兼容结构体,实际上是一种内存转换

public struct POINTAPI

{

public int X;

public int Y;

}

[DllImport("user32dll", EntryPoint = "WindowFromPoint")]//指定坐标处窗体句柄

public static extern int WindowFromPoint(

int xPoint,

int yPoint

);

private void timer1_Tick(object sender, EventArgs e)

{

POINTAPI point = new POINTAPI();//必须用与之相兼容的结构体,类也可以

GetCursorPos(ref point);//获取当前鼠标坐标

int hwnd = WindowFromPoint(pointX, pointY);//获取指定坐标处窗口的句柄

thislabel1Text =pointXToString() + ":" + pointYToString() + "-" + hwndToString();//显示效果,此时窗口已经嵌入桌面了

}

const int GW_CHILD = 5;//定义窗体关系

private void Form1_Load(object sender, EventArgs e)

{

int hDesktop = FindWindow("Progman", null);//获取系统句柄

hDesktop = GetWindow(hDesktop, GW_CHILD);//获取其子窗口句柄,就是桌面的句柄

SetParent((int)thisHandle, hDesktop);//设置父窗体,第一个为要被设置的窗口,第二个参数为指定其父窗口句柄

}

}

}

个人建议,百度搜素“精易模块”,说明下我不是打广告的。。这个模块确实好用。添加该模块以后,使用该命令:窗口_枚举子窗口(父窗口句柄,存放子窗口句柄的数组)

解释:父窗口句柄在本例中,就是你说的QQ窗口的句柄,至于存放子窗口句柄的数组,就是一个数组变量,例如,QQ子窗口

以下为完整代码:(15233为假定QQ窗口句柄)

版本

2

子程序

_按钮1_被单击

局部变量

QQ子窗口,

整数型,

,

"0"

窗口_枚举子窗口

(15233,

QQ子窗口)

GetParentFrame函数可以得到父窗口框架,比如子窗口是A,则AGetParentFrame()就OK了。

具体参看MSDN。

Call this member function to retrieve the parent frame window//调用该函数返回父窗口框架。

以上就是关于按键精灵8,获取句柄有些只有窗口类名,没有窗口标题,该怎么办全部的内容,包括:按键精灵8,获取句柄有些只有窗口类名,没有窗口标题,该怎么办、C#怎样获得窗口句柄、易语言取句柄等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/10171978.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-06
下一篇2023-05-06

发表评论

登录后才能评论

评论列表(0条)

    保存