C# 调用win api获取chrome浏览器中地址
//FindWindow 查找窗口
//FindWindowEx查找子窗口
//EnumWindows列举屏幕上的所有顶层窗口,如果回调函数成功则返回非零,失败则返回零
//GetWindowText返回窗口的标题
一、首先要先导入要使用到的win api
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern int EnumWindows(EnumWindowsProc hWnd, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpText, int nCount);
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam);
private const int WM_GETTEXT = 0x00D;
private static string _url;
//定义委托
delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
static void Main(string[] args)
{
string url = GetWindowText();
Console.WriteLine(url);
Console.ReadKey();
}
public static string GetWindowText()
{
IntPtr chrom = IntPtr.Zero;
EnumWindowsProc enwdproc = new EnumWindowsProc(FindChrom);
if (EnumWindows(enwdproc, IntPtr.Zero) >= )
return _url;
else
return null;
}
//回调函数
static bool FindChrom(IntPtr hWnd, IntPtr lParam)
{
var sb = new StringBuilder();
GetWindowText(hWnd, sb, sb.Capacity);
if (sb.ToString() != String.Empty)
{
if (hWnd != IntPtr.Zero)
{
IntPtr tb = FindWindowEx(hWnd, new IntPtr(), "Chrome_OmniboxView", ""); //Chrome_OmniboxView是通过Spy++获得的
StringBuilder strbld = new StringBuilder();
SendMessage(tb, WM_GETTEXT, , strbld);
_url = strbld.ToString();
}
return false;
}
//回调函数有返回值
return true;
}
C# 调用win api获取chrome浏览器中地址的更多相关文章
- 在Chrome浏览器中保存的密码有多安全?
本文由 伯乐在线 - 黄利民 翻译.未经许可,禁止转载!英文出处:howtogeek.欢迎加入翻译组. [2013-08-09 更新]:最近又开始讨论“Chrome浏览器明文保存密码这个话题了,国外一 ...
- 【js】IE、FF、Chrome浏览器中的JS差异介绍
如何判断浏览器类型 转:http://www.cnblogs.com/carekee/articles/1854674.html 1.通过浏览器特有的对象 如ie 的ActiveXObject ff ...
- 渗透技巧——导出Chrome浏览器中保存的密码
0x00 前言 在后渗透阶段,获得权限后需要搜集目标系统的信息.信息越全面,越有助于进一步的渗透.对于Windows系统,用户浏览器往往包含有价值的信息. 在之前的文章<本地密码查看工具LaZa ...
- 导出Chrome浏览器中保存的密码
title: 导出Chrome浏览器中保存的密码 date: 2018-02-11 17:54:51 tags: --- 导出Chrome浏览器中保存的密码 先知看到的,挺有意思,记录一下 不同浏览器 ...
- Google Chrome浏览器中如何使用命令
Google Chrome浏览器中如何使用命令 | 浏览:2974 | 更新:2014-02-23 23:12 | 标签:chrome 1 2 3 分步阅读 Google Chrome浏览器有很多的特 ...
- 调用ZoomEye API获取信息
最近在提高自己编程能力,拿一些实用的小工具练下.该脚本为python语言,主要涉及模块urllib,json,os模块. 功能:调用ZoomEye API获取信息 import urllib.requ ...
- 去掉chrome浏览器中input获得焦点时的带颜色边框呢
可以设置表单控件的outline属性为none值, 来去掉Chrome浏览器中输入框以及其它表单控件获得焦点时的带颜色边框. css代码如下: input{outline:none}
- [转]chrome浏览器中 F12 功能的简单介绍
本文转自:https://www.cnblogs.com/zhuzhubaoya/p/9758648.html chrome浏览器中 F12 功能的简单介绍 由于F12是前端开发人员的利器,所以我自己 ...
- 查看 chrome 浏览器中的 Headers
查看 chrome 浏览器中的 Headers, Response 信息:
随机推荐
- Action方法调用
一.Action访问路径 Action的访问路径是由struts.xml文件中配置的Action所在包的命名空间,Action的名字和常struts.action.extension共同决定的 例如: ...
- Ubuntu SVN服务器的搭建与配置(转)
Ubuntu SVN服务器的搭建与配置 一. 安装 sudo apt-get install subversion sudo apt-get install libapache2-sv ...
- eclipse中根据方法找到其实现类
面向接口编程中,程序全是面向接口变成调用,在维护别人写的系统的时候怎么样快速定位当前根据接口调用的方法是哪个实体类实现的: Ctrl + T/f4(光标放在需要查看的方法上,然后按Ctrl+T或者F4 ...
- Mysql root密码忘记的解决办法
Windows 版本: 1.打开安装目录下的my.ini 找到 [mysqld] 在下面加入 skip-grant-tables 2. 重启mysql服务 3.打开命令行 依次输入 USE mysql ...
- Memcached集群:Magent缓存代理使用
小结: 先启动memcached 然后启动magent memcached -d -p 11211 -u memcached -m 64 -c 5120 memcached -d -p 11212 - ...
- jsp页面定义的map
<script type="text/javascript">function Map(){ this.elements = new Array(); //删除MAP所 ...
- java项目的部署
1.将tomocat解压到服务器上 2.放项目war包. 3.war包解压. 4.修改端口配置. 1.<Server port="8024" shutdown="S ...
- Using Fast Weights to Attend to the Recent Past
Ba, Jimmy, et al. "Using Fast Weights to Attend to the Recent Past." Advances In Neural In ...
- MemoryStream类读写内存
和FileStream一样,MemoryStream和BufferedStream都派生自基类Stream,因此它们有很多共同的属性和方法,但是每一个类都有自己独特的用法.这两个类都是实现对内存进行数 ...
- C#反射Assembly 详细说明,有项目例子
1.对C#反射机制的理解2.概念理解后,必须找到方法去完成,给出管理的主要语法3.最终给出实用的例子,反射出来dll中的方法 反射是一个程序集发现及运行的过程,通过反射可以得到*.exe或*.dll等 ...