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 ...
随机推荐
- CATransition 实践
时间差不够,导致闪屏 CATransition *animation = [CATransition animation]; animation.delegate = self; animation. ...
- nginx 代理ssh
events { worker_connections 1024; } stream { #stream模块,就跟http模块一样 upstream ssh { server 127.0.0.1:22 ...
- .NetCore中EFCore for MySql整理(二)
一.简介 EF Core for MySql的官方版本MySql.Data.EntityFrameworkCore 目前正是版已经可用当前版本v6.10,对于以前的预览版参考:http://www.c ...
- 如何使用LaTeX让自己不乱?
虽然说LaTeX声称排版容易,只关注内容,可是混合着源代码的结构很难让我只关注内容,最后看得眼睛疼,找什么都找不到. 匿名用户 30 人赞同 立即想到的几个建议: 选择有折叠功能 (folding) ...
- cross validation笔记
preface:做实验少不了交叉验证,平时常用from sklearn.cross_validation import train_test_split,用train_test_split()函数将数 ...
- Ember.js 1.0 RC6 发布,JavaScript 框架
Ember.js 1.0 发布了第 6 个 RC 版本,下载地址:https://github.com/emberjs/ember.js/tree/v1.0.0-rc.6 该版本包含众多的改进记录,详 ...
- 洛谷 P1123 取数游戏
题目描述 一个N×M的由非负整数构成的数字矩阵,你需要在其中取出若干个数字,使得取出的任意两个数字不相邻(若一个数字在另外一个数字相邻8个格子中的一个即认为这两个数字相邻),求取出数字和最大是多少. ...
- eclipse 创建聚合maven项目
本人不想花太多时间去排版,所以这里排版假设不好看,请多多包涵! 一直都在用maven,可是却基本没有自己创建过maven项目,今天也试着创建一个. 1.打开eclipse.然后new,other,然后 ...
- Servlet 生命周期、工作原理(转)
原文链接:Servlet 生命周期.工作原理 Servlet 生命周期:Servlet 加载--->实例化--->服务--->销毁. init():在Servlet的生命周期中,仅执 ...
- RxJava【过滤】操作符 filter distinct throttle take skip first MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...