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 ...
随机推荐
- mount.nfs: access denied by server while mounting <SERVER IP>:<SERVER PATH>
root@hipchat:~# mount -t nfs 192.168.10.220:/hipchat/share /home/share/nfs mount.nfs: access denied ...
- 【多线程】java多线程实现生产者消费者模式
思考问题: 1.为什么用wait()+notify()实现生产者消费者模式? wait()方法可以暂停线程,并释放对象锁 notify()方法可以唤醒需要该对象锁的其他线程,并在执行完后续步骤,到了s ...
- android加密DESede/CBC/PKCS5Padding
from://http://my.oschina.net/u/269082/blog/56163 工作中需要和HPH对接,接口一些敏感信息,讨论后用3DES加密,由于我做的android邮件客户端是依 ...
- BootStrap中的button使用
原文地址:http://www.phloxblog.in/bootstrap-buttons/#.U5xYso2fclm 站点中事件的触发往往依赖于button或者超链接.因此,button能够觉得是 ...
- Swift - 添加纯净的Alamofire
Swift - 添加纯净的Alamofire 如果你有代码洁癖,不能容忍任何多余的东西,请继续往下看. . 下载Alamofire (https://github.com/Alamofire/Ala ...
- 副总统第一至三季/全集Veep迅雷下载
本季第一.二.三季 Veep Season 1 (2012-2014)看点:<副总统>讲述了Selina Meyer从一名参议员成为副总统后,开始面对成堆的突发状况,很快,她便认识到,成为 ...
- Android 代码实现应用强制装到手机内存
在Froyo(android 2.2,API Level:8)中引入了android:installLocation.通过设置该属性可以使得开发者以及用户决定程序的安装位置. android:inst ...
- 5G与TCP/IP
众所周知,4G LTE全面IP化,上层传输走的是TCP/IP协议(如下图). ▲LTE用户面协议构架 但是,我们熟悉的这个构架并没有发挥出移动网络的全部潜力,甚至阻碍了未来网络的发展. 1 TCP/ ...
- sys.stdout.flush()以及subprocess的用处
sys.stdout.flush()立即把stdout缓存内容输出. subprocess与shell进行交互,执行shell命令等. 执行shell命令集合: subprocess.check_ou ...
- Locks Set by Different SQL Statements in InnoDB
A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scan ...