c#源代码如何控制IE播放或暂停Flash播放器? [英] How do c# Source code Control Play or pause of flash player for IE?
本文介绍了c#源代码如何控制IE播放或暂停Flash播放器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
c#源码如何控制IE播放或暂停播放?
非常感谢。!
解决方案
I已经实现了控制IE浏览器,只是无法控制和检测或暂停,即IE播放的Flash播放器
公共部分类Form1:表格
{
public Form1()
{
InitializeComponent();
}
private SHDocVw.InternetExplorer getWindowObject(String ieWindowName)
{
if(ieWindowName == String.Empty || ieWindowName.Equals())
{
返回null;
}
SHDocVw.InternetExplorer v_ie = null;
/ *
获得所有即进程。因为windows下资源窗口使用即内核,所以不光是我们通常指的web浏览器,它还包括你打开的电脑这样的窗口
* /
SHDocVw.ShellWindows sws = new SHDocVw.ShellWindows();
/ *遍历即进程* /
foreach(sws中的SHDocVw.InternetExplorer iew)
{
//MessageBox.Show(iw.LocationName);
$
/ *
*将获取到的窗口,将其句柄返回即可。
* /
//MessageBox.Show(go.LocationURL);
if(iew.LocationURL .Contains(ieWindowName))
{
//MessageBox.Show(iw.LocationName);
// HtmlDocument doc = iw.get (HtmlDocument)iw.Document;
//MessageBox.Show(doc.DomDocument.ToString());
//mshtml.HTMLDocument doc =(mshtml.HTMLDocument)iw.Document;
//MessageBox.Show((HTMLInputTextElement)doc.getElementById(\"t1) )。值);
// ihtmldocument2接口。可以查看msdn6。做法有点类似于js对页面htmlelement操作了。
//((HTMLInputTextElement)doc.getElementById(\"t1\")).value = textSetStr.Text;
v_ie = iew;
}
}
返回v_ie;
} < br $>
////////////显示或隐藏//////////////////// ////////////////////////////////////////////////// //////////////////////
private void isShowOrHiddenIEInput(String ieWindowName,String ieInputName,String isShow)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if(iw!= null)
{
mshtml.HTMLDocument doc =(mshtml.HTMLDocument)iw.Document;
if(isShow.Equals(true))
{
((HTMLInputTextElement)doc.getEl ementById(ieInputName))。style.display =block;
}
else
{
( (HTMLInputTextElement)doc.getElementById(ieInputName))。style.display =none;
}
}
}
private void button3_Click(object sender,EventArgs e)
{
isShowOrHiddenIEInput(this.textUrl.Text,this.textIEInputID .Text,true);
}
private void button4_Click(object sender,EventArgs e)
{
isShowOrHiddenIEInput(this.textUrl.Text,this.textIEInputID.Text,false);
}
////////////////禁用或启用按钮////////////////////////// ////////////////////////////////////////////////// ////////////////////////
private void isEnableOrDis ableIEInput(String ieWindowName,String ieInputName,String isable)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if(iw! = null)
{
mshtml.HTMLDocument doc =(mshtml.HTMLDocument)iw.Document;
if(isable.Equals(enable) ))
{
((HTMLInputTextElement)doc.getElementById(ieInputName))。disabled = false;
}
其他
{
((HTMLInputTextElement)doc.getElementById(ieInputName))。disabled = true;
}
}
}
private void button5_Click(object sender,EventArgs e)
{
isEnableOrDisableIEInput(this.textUrl.Text,this.textEnableIEinput.Text,disable);
}
private void button6_Click(object sender,EventArgs e)
{
isEnableOrDisableIEInput(this.textUrl.Text,this.textEnableIEinput.Text,enable);
}
//给IE浏览器中的文本框赋值>
private void txtIEInput(String ieWindowName,String ietxtInputName,String txt)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if(iw!= null)
{
mshtml.HTMLDocument doc =(mshtml.HTMLDocument)iw.Document;
( (HTMLInputTextElement)doc.getElementById(ietxtInputName))。value = txt;
}
}
private void button7_Click(object sender,EventArgs e )
{
txtIEInput(this.textUrl.Text,this.textBox3.Text,this.textBox2.Text); < br $>
}
//获取IE浏览器的body内容
private string getbodytxt(String ieWindowName)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if(iw!= null)
{
mshtml.HTMLDocument doc =(mshtml.HTMLDocument)iw.Document;
string html = doc.documentElement.innerHTML;
mshtml.HTMLBody body =(mshtml.HTMLBody)doc.body;
return body.innerHTML.ToString();
}
返回0;
}
private void button1_Click(object sender,EventArgs e)
{
this.richTextBox1.Text = getbodytxt(this.textUrl.Text);
}
//获取IE浏览器html内容
私有string gethtmltxt(String ieWindowName)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if(iw!= null)
{
mshtml.HTMLDocument doc =(mshtml.HTMLDocument)iw.Document;
string html = doc.documentElement.innerHTML;
返回html;
}
返回0;
}
private void button8_Click(object sender,EventArgs e)
{
this.richTextBox2.Text = gethtmltxt(this.textUrl.Text);
}
//点击提交按钮方法
public void SearchbtnInbaidu(String ieWindowName,string btntxt)
{
//mshtml.HTMLInputElementClass输入;
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName );
if(iw!= null)
{
mshtml.HTMLDocument doc =(mshtml.HTMLDocument)iw.Document;
((HTMLInputTextElement)doc.getElementById(btntxt))。click();
}
}
private void button9_Click(object sender,EventArgs e)
{
SearchbtnInbaidu(this.textUrl.Text,this .textBox4.Text);
}
}
How do c# Source code Control Play or pause of flash player for IE?
Thank you very much.!
解决方案
I have implemented the control IE browser, just can't control and detect or pause ie flash player for IE play
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private SHDocVw.InternetExplorer getWindowObject(String ieWindowName)
{
if (ieWindowName == String.Empty || ieWindowName.Equals(""))
{
return null;
}
SHDocVw.InternetExplorer v_ie = null;
/*
获得所有ie进程。因为windows下资源窗口使用ie内核,所以不光是我们通常指的web浏览器,它还包括你打开我的电脑这样的窗口
*/
SHDocVw.ShellWindows sws = new SHDocVw.ShellWindows();
/*遍历ie进程*/
foreach (SHDocVw.InternetExplorer iew in sws)
{
//MessageBox.Show(iw.LocationName);
/*
* 将获取到的窗口URL和输入的要控制的部分URl比较,如果包含,则说明此窗口是需要被控制的,将其句柄返回即可。
*/
//MessageBox.Show(iew.LocationURL);
if (iew.LocationURL.Contains(ieWindowName))
{
//MessageBox.Show(iw.LocationName);
//HtmlDocument doc = iw.get (HtmlDocument)iw.Document;
//MessageBox.Show(doc.DomDocument.ToString());
//mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
//MessageBox.Show(((HTMLInputTextElement)doc.getElementById("t1")).value);
//ihtmldocument2接口.可以查看msdn6. 做法有点类似于js对页面htmlelement操作了。
//((HTMLInputTextElement)doc.getElementById("t1")).value = textSetStr.Text;
v_ie = iew;
}
}
return v_ie;
}
////////////显示或隐藏////////////////////////////////////////////////////////////////////////////////////////////
private void isShowOrHiddenIEInput(String ieWindowName, String ieInputName, String isShow)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if (iw != null)
{
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
if (isShow.Equals("true"))
{
((HTMLInputTextElement)doc.getElementById(ieInputName)).style.display = "block";
}
else
{
((HTMLInputTextElement)doc.getElementById(ieInputName)).style.display = "none";
}
}
}
private void button3_Click(object sender, EventArgs e)
{
isShowOrHiddenIEInput(this.textUrl.Text, this.textIEInputID.Text, "true");
}
private void button4_Click(object sender, EventArgs e)
{
isShowOrHiddenIEInput(this.textUrl.Text, this.textIEInputID.Text, "false");
}
////////////////禁用或启用按钮////////////////////////////////////////////////////////////////////////////////////////////////////
private void isEnableOrDisableIEInput(String ieWindowName, String ieInputName, String isable)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if (iw != null)
{
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
if (isable.Equals("enable"))
{
((HTMLInputTextElement)doc.getElementById(ieInputName)).disabled = false;
}
else
{
((HTMLInputTextElement)doc.getElementById(ieInputName)).disabled = true;
}
}
}
private void button5_Click(object sender, EventArgs e)
{
isEnableOrDisableIEInput(this.textUrl.Text, this.textEnableIEinput.Text, "disable");
}
private void button6_Click(object sender, EventArgs e)
{
isEnableOrDisableIEInput(this.textUrl.Text, this.textEnableIEinput.Text, "enable");
}
//给IE浏览器中的文本框赋值
private void txtIEInput(String ieWindowName, String ietxtInputName, String txt)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if (iw != null)
{
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
((HTMLInputTextElement)doc.getElementById(ietxtInputName)).value = txt;
}
}
private void button7_Click(object sender, EventArgs e)
{
txtIEInput(this.textUrl.Text, this.textBox3.Text, this.textBox2.Text);
}
//获取IE浏览器的body内容
private string getbodytxt(String ieWindowName)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if (iw != null)
{
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
string html = doc.documentElement.innerHTML;
mshtml.HTMLBody body = (mshtml.HTMLBody)doc.body;
return body.innerHTML.ToString();
}
return "0";
}
private void button1_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = getbodytxt(this.textUrl.Text);
}
//获取IE浏览器html内容
private string gethtmltxt(String ieWindowName)
{
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if (iw != null)
{
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
string html = doc.documentElement.innerHTML;
return html;
}
return "0";
}
private void button8_Click(object sender, EventArgs e)
{
this.richTextBox2.Text = gethtmltxt(this.textUrl.Text);
}
//点击提交按钮方法
public void SearchbtnInbaidu(String ieWindowName,string btntxt)
{
//mshtml.HTMLInputElementClass input;
SHDocVw.InternetExplorer iw = getWindowObject(ieWindowName);
if (iw != null)
{
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)iw.Document;
((HTMLInputTextElement)doc.getElementById(btntxt)).click();
}
}
private void button9_Click(object sender, EventArgs e)
{
SearchbtnInbaidu(this.textUrl.Text,this.textBox4.Text);
}
}
这篇关于c#源代码如何控制IE播放或暂停Flash播放器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文