C# 通过SendMessage获取浏览器地址栏的地址
1:通过SPY++获得地址栏的层次结构,然后一层一层获得

2:代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices; namespace ConsoleApplication4
{
class Program
{
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll")]
static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam); const int WM_GETTEXT = 0x000D; //获得文本消息的16进制表示 static void Main(string[] args)
{ //chrome.exe IEXPLORE.EXE System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://127.0.0.1:7001/console/login/LoginForm.jsp"); System.Threading.Thread.Sleep(); //获得IE窗口句柄
IntPtr hWnd = FindWindow("IEFrame", null); System.Console.WriteLine("hWnd:" + hWnd); IntPtr child = FindWindowEx(hWnd, IntPtr.Zero, "WorkerW", null);
child = FindWindowEx(child, IntPtr.Zero, "ReBarWindow32", null);
child = FindWindowEx(child, IntPtr.Zero, "Address Band Root", null);
child = FindWindowEx(child, IntPtr.Zero, "Edit", null); //通过SPY++获得地址栏的层次结构,然后一层一层获得 if (child != null)
{
StringBuilder buffer = new StringBuilder();
int num = SendMessage(child, WM_GETTEXT, , buffer); System.Console.WriteLine("num:" + num); string strUrl = buffer.ToString(); System.Console.WriteLine("URL:" + strUrl);
} Console.ReadLine();
} }
}
3:运行结果

C# 通过SendMessage获取浏览器地址栏的地址的更多相关文章
- JS获取浏览器地址栏的多个参数值的任意值
getParamValue("id"); //http://localhost:2426/TransactionNotes.aspx?id=100 //返回值是100: // 根据 ...
- vue获取浏览器地址栏参数(?及/)路由+非路由实现方式
1.? 参数 浏览器参数形式:http://javam4.com/m4detail?id=1322914793170014208 1.1.路由取参方式 this.$route.query.id 前端跳 ...
- 使用js获取浏览器地址栏里的参数
用JS获取地址栏参数的方法(超级简单) 方法一:采用正则表达式获取地址栏参数:( 强烈推荐,既实用又方便!) function GetQueryString(name) { var reg = new ...
- JS获取浏览器地址栏的多参数值的任意值
常用的几个方法就不讲了,这里我用的是两个方法组 使用方法是: getParamValue("id"); http://localhost:2426/TransactionNotes ...
- js获取浏览器地址栏传递的参数
function getQueryString(key){ var href=window.location.href; var reg = new RegExp(key +"=([^&am ...
- 通过sohu获取浏览器端IP地址
接口:http://pv.sohu.com/cityjson?ie=utf-8
- js获取浏览器上一访问页面URL地址,document.referrer方法
如题,可用document.referrer方法获取上一页面的url 但是也有不可使用的情况 直接在浏览器地址栏中输入地址: 使用location.reload()刷新(location.href或者 ...
- 把post请求的地址粘贴到浏览器地址栏敲回车报错405[Method Not Allowed]
为什么把post请求的地址粘贴到浏览器地址栏敲回车会报405?原因:在浏览器地址栏敲回车,浏览器默认是以get方式发送请求,而你的请求是post,这样当然会报405了: 405:方法不允许,不支持ge ...
- js获取当前浏览器地址栏的链接,然后在链接后面加参数
比如访问www.baidu.com,url显示成www.baidu.com/?form <script type="text/javascript"> if(locat ...
随机推荐
- JSTL标签用法:<c:choose><c:forEach><c:if><c:when><c:set>
JSP 标准标记库( Standard Tag Library , JSTL) 是一组以标准化格式实现许多通用的 Web 站点功能的定制标记. JSP 技术的优势之一在于其定制标记库工具.除了核心 J ...
- 【CentOS】centos如何修改你的主机名
转载地址:https://www.linuxidc.com/Linux/2014-11/109238.htm ============================================= ...
- 深入理解Java并发之synchronized实现原理
深入理解Java类型信息(Class对象)与反射机制 深入理解Java枚举类型(enum) 深入理解Java注解类型(@Annotation) 深入理解Java类加载器(ClassLoader) 深入 ...
- Android动画学习笔记大集合
其实动画这个东西我已经了解过很长一段时间了,但是一直没系统的整理过.关于android中的各种动画虽然都会用,但总怕自己会慢慢遗忘.这回看了几篇动画分析的文章,自己也学到了一些东西,在此就梳理一下. ...
- Eclipse给安卓应用签名
- Java泛型之类型擦除
类型擦除 学过C++模板的,在使用Java泛型的时候,会感觉到有点不疑问,例如:(1)无法定义一个泛型数组.无法调用泛型参数对象中对应的方法(当然,通过extends关键字是可以做到,只是比较麻烦): ...
- Cannot find snapshot in models/VGGNet/VOC0712/SSD_300x300
错误描述: 执行 python examples/ssd/ssd_pascal.py 报错: Cannot find snapshot in models/VGGNet/VOC0712/SSD_300 ...
- No identifier specified for entity: springboot-jpa报错No identifier specified for entity
说明:此次学习使用了springboot框架,jpa注解映射实体类 1,No identifier specified for entity: com.tf.model.User 看到此错误第一反应百 ...
- gamma函数及相关其分布
神奇的gamma函数(上) 神奇的gamma函数(下) gamma函数的定义及重要性质 \[\Gamma(x)=\int_0^{\infty}t^{x-1}e^{-t}dt\] \[\Gamma(x+ ...
- C++ 内置宏定义 与 预编译指令
内置宏和预编译指令, 在代码调试.单元测试.跨平台代码中经常会用到.这里记录一下. 1. 内置宏 (文件名,当前行号,当前日期,当前时间,当前执行方法名) __FILE____LINE____DATE ...