c# API 获取外部程序combobox 句柄

c# API 获取外部程序combobox 句柄,第1张

using System;

using SystemCollectionsGeneric;

using SystemText;

using SystemRuntimeInteropServices;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

string winClass = "AutoHotkeyGUI"; //窗口类名

string winTitle = "aabb"; //窗口标题

IntPtr dlghWnd= FindWindow(winClass,winTitle);

IntPtr cbohWnd=FindWindowEx(dlghWnd,0,"ComboBox",null);

if (dlghWnd ==(IntPtr) 0)

{

ConsoleWriteLine("目标窗口不存在");

}

ConsoleWriteLine("combobox句柄为:0x{0}",cbohWndToString("X"));

ConsoleReadKey(true);

}

[DllImport("user32")]

private static extern IntPtr FindWindow(string wClass, string title);

[DllImport("user32")]

private static extern IntPtr FindWindowEx(IntPtr dlghWnd,

uint order, string cClass, string title);

}

}

看msdn吧。可以调用GetPhysicalMonitorsFromHMONITOR函数或者GetPhysicalMonitorsFromIDirect3DDevice9函数得到窗口句柄

首先 找到 找到外部程序的主窗口的句柄 然后再查找其子窗口

父窗口用findwindow就可以 子窗口要指定要查找窗口的class

windows 中每一个窗口都有一个类的

比如记事本的文本框 类名叫edit VB的textbox 类名叫ThunderRT6TextBox

等等

以上就是关于c# API 获取外部程序combobox 句柄全部的内容,包括:c# API 获取外部程序combobox 句柄、如何在windows API应用程序中获取一个MFC对话框的句柄 诸大神请帮忙、VB用API获取外部程序文本框句柄等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存