本文整理汇总了C#中mshtml类的典型用法代码示例。如果您正苦于以下问题:C# mshtml类的具体用法?C# mshtml怎么用?C# mshtml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
mshtml类属于命名空间,在下文中一共展示了mshtml类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ToHNode
static HObject ToHNode(mshtml.IHTMLDOMNode node)
{
if (node == null)
return null;
//dynamic x = element;
//Console.WriteLine(MetaTech.Library.ReflectionExtension.ReflectionHelper._P<object>(element.DomElement, "textContent"));
//var span = element.DomElement as mshtml.IHTMLDOMNode;
switch (node.nodeType)
{
case 3:
return new HText(node.nodeValue);
case 1:
{
var element = node as mshtml.IHTMLElement;
var childs = node.childNodes as System.Collections.IEnumerable;
return new HElement(element.tagName,
ToHAttribute("id", element.id),
ToHAttribute("class", element.className),
ToHAttribute("src", element.getAttribute("src")),
//ToHAttribute("style", element.getAttribute("style")),
childs != null ? childs.OfType<mshtml.IHTMLDOMNode>().Select(child => ToHNode(child)) : null
);
}
default:
return null;
}
////Console.WriteLine(x.textContent);
////mshtml.HTMLTextAreaElement
//return new HElement(element.TagName,
// ToHAttribute("id", element.Id),
// ToHAttribute("name", element.Name),
// ToHAttribute("class", element.GetAttribute("class")),
// ToHAttribute("style", element.Style),
// element.Children.OfType<HtmlElement>().Select(e => ToHElement(e)),
// ToHAttribute("type", element.DomElement._f(_=>_.GetType().FullName))
//);
}
开发者ID:DrReiz,项目名称:DrReiz.Robo-Gamer,代码行数:40,代码来源:WebBotForm.cs
示例2: Bind
public override void Bind(mshtml.HTMLDocument dom, string rawContent)
{
Clean();
SessionDocument = new HtmlNodeHierarchy(rawContent.AsHtmlDocument().DocumentNode);
String domDocStr = ("" + (dom as dynamic).documentElement.OuterHtml + "");
DomDocument = new HtmlNodeHierarchy(domDocStr.AsHtmlDocument().DocumentNode);
}
开发者ID:ikutsin,项目名称:BinaryAnalysis.Core,代码行数:7,代码来源:StatePageHtmlDomInformationVm.cs
示例3: Bind
public void Bind(mshtml.HTMLDocument dom)
{
Clean();
var sess = Enumerable.First<FiddlerSessionHolder>(FiddlerHelper.GetSessionsStack());
//TODO: diff
SessionDocument = sess.BrowsingResponse.ResponseContent.AsFixedXML();
String domDocStr = ("" + (dom as dynamic).documentElement.OuterHtml + "");
DomDocument = domDocStr.AsFixedXML();
}
开发者ID:ikutsin,项目名称:BinaryAnalysis.Core,代码行数:9,代码来源:FiddlerPageFixedXmlnformationVm.cs
示例4: Bind
public override void Bind(mshtml.HTMLDocument dom, string content)
{
Clean();
var sess = Enumerable.First<FiddlerSessionHolder>(FiddlerHelper.GetSessionsStack());
//TODO: diff
SessionDocument = new HtmlNodeHierarchy(sess.BrowsingResponse.ResponseContent.AsHtmlDocument().DocumentNode);
String domDocStr = ("" + (dom as dynamic).documentElement.OuterHtml + "");
DomDocument = new HtmlNodeHierarchy(domDocStr.AsHtmlDocument().DocumentNode);
}
开发者ID:ikutsin,项目名称:BinaryAnalysis.Core,代码行数:10,代码来源:FiddlerPageHtmlDomInformationVm.cs
示例5: WaitForPageReady
public static void WaitForPageReady(mshtml.IHTMLDocument2 document, int secondWait = 30)
{
for (int i = 0; i < secondWait; i++)
{
if (document != null && document.readyState.Equals("complete"))
{
break;
}
System.Console.WriteLine("READY:" + document == null ? "null" : document.readyState);
System.Threading.Thread.Sleep(1000);
}
}
开发者ID:huangchaosuper,项目名称:watf,代码行数:12,代码来源:Common.cs
示例6: getNode
private static string getNode(mshtml.IHTMLElement node)
{
string nodeExpr = node.tagName;
if (nodeExpr == null) // Eg. node = #text
return null;
if (node.id != "" && node.id != null)
{
nodeExpr += "[@id='" + node.id + "']";
// We don't really need to go back up to //HTML, since IDs are supposed
// to be unique, so they are a good starting point.
return "/" + nodeExpr;
}
// Find rank of node among its type in the parent
int rank = 1;
mshtml.IHTMLDOMNode nodeDom = node as mshtml.IHTMLDOMNode;
mshtml.IHTMLDOMNode psDom = nodeDom.previousSibling;
mshtml.IHTMLElement ps = psDom as mshtml.IHTMLElement;
while (ps != null)
{
if (ps.tagName == node.tagName)
{
rank++;
}
psDom = psDom.previousSibling;
ps = psDom as mshtml.IHTMLElement;
}
if (rank > 1)
{
nodeExpr += "[" + rank + "]";
}
else
{ // First node of its kind at this level. Are there any others?
mshtml.IHTMLDOMNode nsDom = nodeDom.nextSibling;
mshtml.IHTMLElement ns = nsDom as mshtml.IHTMLElement;
while (ns != null)
{
if (ns.tagName == node.tagName)
{ // Yes, mark it as being the first one
nodeExpr += "[1]";
break;
}
nsDom = nsDom.nextSibling;
ns = nsDom as mshtml.IHTMLElement;
}
}
return nodeExpr;
}
开发者ID:mradosta,项目名称:thousandpass,代码行数:48,代码来源:XPath.cs
示例7: MouseMoveEventHandler
private void MouseMoveEventHandler(mshtml.IHTMLEventObj e)
{
string preBlock = current_select_block;
current_select_block = _webBrowser.InvokeScript("getSelectBlockName") as string;
if (preBlock != current_select_block && current_select_block != " ")
{
ctrVM.functionMV.contain.Children.Clear();
_tabControls.TabContols.SelectedIndex = 1;
ctrVM.functionMV.initModel(current_select_block);
//3D객체에 string 전송
AddMouseMoveEvnet();
}
}
开发者ID:KimDongWan,项目名称:Miseng,代码行数:16,代码来源:ScriptView.xaml.cs
示例8: CheckMousePoint
public static void CheckMousePoint(IntPtr hwnd, ref Point fakeMousePoint, mshtml.IHTMLDocument2 doc)
{
int clientWidth = 0;
int clientHeight = 0;
int scrollWidth = 0;
int scrollHeight = 0;
Random random = new Random();
if (GetWindowWidthAndHeight(hwnd, doc, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight) != null)
{
if (((fakeMousePoint.X <= 0) || (fakeMousePoint.X >= clientWidth)) && (clientWidth > 8))
{
fakeMousePoint.X = random.Next(4, clientWidth - 8);
}
if (((fakeMousePoint.Y <= 0) || (fakeMousePoint.Y >= clientHeight)) && (clientHeight > 8))
{
fakeMousePoint.Y = random.Next(4, clientHeight - 8);
}
}
}
开发者ID:purplecow,项目名称:AutoBroswer,代码行数:19,代码来源:HtmlUtil.cs
示例9: getXPath
public static string getXPath(mshtml.IHTMLElement element)
{
if (element == null)
return "";
mshtml.IHTMLElement currentNode = element;
ArrayList path = new ArrayList();
while (currentNode != null)
{
string pe = getNode(currentNode);
if (pe != null)
{
path.Add(pe);
//if (pe.IndexOf("@id") != -1)
// break; // Found an ID, no need to go upper, absolute path is OK
}
currentNode = currentNode.parentElement;
}
path.Reverse();
return join(path, "/");
}
开发者ID:mradosta,项目名称:thousandpass,代码行数:21,代码来源:XPath.cs
示例10: ClickCheckedRect
public static bool ClickCheckedRect(IntPtr hwnd, mshtml.IHTMLDocument2 doc, string itemName, string tagStr, string indexStr, ref bool isClick, ref Point fakeMousePoint, ClickEvent clickEvent)
{
mshtml.IHTMLElement elem = GetCheckedElement(doc, itemName, tagStr, indexStr);
bool flag = false;
if (elem != null)
{
flag = true;
Rectangle elementRect = GetElementRect(doc.body, elem);
isClick = false;
if ((elementRect.Width > 0) && (elementRect.Height > 0))
{
Random random = new Random();
int num = random.Next(elementRect.Width);
int num2 = random.Next(elementRect.Height);
SetMousePoint(hwnd, ref fakeMousePoint, elementRect.X + num, elementRect.Y + num2, doc);
isClick = isClickElement(hwnd, doc, elem, elementRect.X + num, elementRect.Y + num2, clickEvent);
}
}
if (elem != null)
{
Marshal.ReleaseComObject(elem);
}
return flag;
}
开发者ID:purplecow,项目名称:AutoBroswer,代码行数:24,代码来源:HtmlUtil.cs
示例11: HtmlControl
public HtmlControl(WATF.Core.Page.IPage page, mshtml.IHTMLElement elem)
{
this.m_Page = page;
this.m_HtmlElement = elem;
}
开发者ID:huangchaosuper,项目名称:watf,代码行数:5,代码来源:HtmlControl.cs
示例12: Range
internal Range(mshtml.IHTMLTxtRange range)
{
msHtmlTxRange = range;
}
开发者ID:TomRom27,项目名称:LectioDivina,代码行数:4,代码来源:HtmlDocument.cs
示例13: RemoveBIS
private void RemoveBIS(mshtml.IHTMLElement element)
{
if (element.tagName == "B")
{
mshtml.IHTMLElement elem1 = element.parentElement;
if (elem1.tagName == "I")
{
mshtml.IHTMLElement elem2 = elem1.parentElement;
if (elem2.tagName == "SPAN" && elem2.getAttribute("id", 2).ToString() == "advanced_search")
{
elem2.outerHTML = this.targetTerm;
}
Marshal.ReleaseComObject(elem2);
}
Marshal.ReleaseComObject(elem1);
}
}
开发者ID:grefly,项目名称:Buy4,代码行数:17,代码来源:IEModule.cs
示例14: RemoveS
private void RemoveS(mshtml.IHTMLElement element)
{
if (element.tagName == "SPAN" && element.getAttribute("id", 2).ToString() == "advanced_search")
{
element.outerHTML = this.targetTerm;
}
}
开发者ID:grefly,项目名称:Buy4,代码行数:7,代码来源:IEModule.cs
示例15: RemoveHTML
private void RemoveHTML(GlobalSettings settings,mshtml.IHTMLTxtRange range)
{
mshtml.IHTMLElement element = range.parentElement();
if (settings.IsHightlightNonVisible)
{
if (settings.IsBold)
{
if (settings.IsItalic)
{
RemoveBIS(element);
}
else
{
RemoveBS(element);
}
}
else
{
if (settings.IsItalic)
{
RemoveIS(element);
}
else
{
RemoveS(element);
}
}
}
else
{
if (element.offsetTop > Const.NotFound && element.offsetLeft > Const.NotFound && element.offsetHeight > Const.Ok && element.offsetWidth > Const.Ok)
{
if (settings.IsBold)
{
if (settings.IsItalic)
{
RemoveBIS(element);
}
else
{
RemoveBS(element);
}
}
else
{
if (settings.IsItalic)
{
RemoveIS(element);
}
else
{
RemoveS(element);
}
}
}
}
Marshal.ReleaseComObject(element);
}
开发者ID:grefly,项目名称:Buy4,代码行数:58,代码来源:IEModule.cs
示例16: iEvent_onclick
bool iEvent_onclick(mshtml.IHTMLEventObj pEvtObj)
{
if (currentEl != null)
currentEl.style.backgroundColor = "#ffffff";
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)webBrowser1.Document;
mshtml.IHTMLWindow2 win = doc.parentWindow;
richTextBox1.Document.Blocks.Clear();
currentEl = [email protected];
richTextBox1.AppendText([email protected]);
foreach (IHTMLElement el in [email protected])
{
if(el.tagName == [email protected])
el.style.backgroundColor = "#F0FF06";
foreach (IHTMLElement e in el.all)
{
if (e.tagName == [email protected])
el.style.backgroundColor = "#F0FF06";
}
}
[email protected] = "#F0FF06";
return false;
}
开发者ID:kantone,项目名称:intelliscraper,代码行数:26,代码来源:MainWindow.xaml.cs
示例17: MoveMouseToBottom
private void MoveMouseToBottom(IntPtr hwnd, mshtml.IHTMLDocument2 doc)
{
if ((this._curTenDayBrowser.Document.GetElementsByTagName("HTML").Count > 0) && (!HtmlUtil.ScrollToBottom(hwnd, doc, this._curTenDayBrowser.Document.GetElementsByTagName("HTML")[0], this._fakeMousePoint, this.GetLoadPercent(), this.FindTimeOut()) || !this._isDocCompleted))
{
this._scrollTime = this._now;
}
this.SetFakeScroll();
}
开发者ID:purplecow,项目名称:AutoBroswer,代码行数:8,代码来源:IEItem.cs
示例18: GetDeepClickLinkInfo
private bool GetDeepClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, string keyword)
{
bool flag = false;
if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
{
IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
int clientWidth = 0;
int clientHeight = 0;
int scrollWidth = 0;
int scrollHeight = 0;
mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
mshtml.IHTMLElementCollection links = doc2.links;
ArrayList list = new ArrayList();
if (string.IsNullOrEmpty(keyword))
{
keyword = "";
}
Regex regex = new Regex(keyword + @"(\w)?");
foreach (mshtml.IHTMLElement element2 in links)
{
if ((((element2.getAttribute("href", 0) != null) && (element2.getAttribute("target", 0) != null)) && element2.getAttribute("target", 0).ToString().ToLower().Equals("_blank")) && (string.IsNullOrEmpty(keyword) || regex.IsMatch(element2.getAttribute("href", 0).ToString())))
{
Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
{
list.Add(element2);
}
}
}
if (list.Count > 0)
{
Random random = new Random();
int num5 = random.Next(list.Count);
random = null;
mshtml.IHTMLElement ele = list[num5] as mshtml.IHTMLElement;
if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
{
this._randomClickLink = ele.outerText;
this._randomClickLinkTag = ElementTag.outerText;
}
else
{
this._randomClickLinkTag = ElementTag.href;
this._randomClickLink = ele.getAttribute("href", 0).ToString();
}
this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
this._status = IEStatus.IEStatus_MoveToDest;
this._beforeWaitTime = this._now;
list = null;
random = null;
return flag;
}
if (doc2 != null)
{
this.MoveMouseToBottom(windowHwnd, doc2);
if (this.MoveTimeOut() && this.FindTimeOut())
{
parent.ShowTip2("不存在 " + keyword);
this._loop = false;
flag = true;
}
}
return flag;
}
if (this.FindTimeOut())
{
flag = true;
}
return flag;
}
开发者ID:purplecow,项目名称:AutoBroswer,代码行数:70,代码来源:IEItem.cs
示例19: KeyUpHandler
public KeyUpHandler(mshtml.IHTMLDocument2 doc)
: base(doc)
{
}
开发者ID:novalis78,项目名称:Pali-Text-Reader,代码行数:4,代码来源:KeyUpHandler.cs
示例20: DrawCaptureBox
private void DrawCaptureBox(IntPtr fromHandle, mshtml.IHTMLElement ele)
{
if (ele == null)
{
WindowUtil.RedrawWindow(fromHandle, null, IntPtr.Zero, 0x85);
}
else
{
mshtml.IHTMLDocument2 iEWindowDocument = HtmlUtil.GetIEWindowDocument(fromHandle);
Rectangle elementRect = HtmlUtil.GetElementRect(iEWindowDocument.body, ele);
elementRect.Inflate(1, 1);
if (this._CaptureRect != elementRect)
{
WindowUtil.RedrawWindow(fromHandle, null, IntPtr.Zero, 0x85);
this._CaptureRect = elementRect;
}
else
{
Graphics.FromHwnd(fromHandle).DrawRectangle(new Pen(Color.Blue, 3f), elementRect);
}
Marshal.ReleaseComObject(iEWindowDocument);
}
}
开发者ID:purplecow,项目名称:AutoBroswer,代码行数:23,代码来源:ManageForm.cs
注:本文中的mshtml类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论