这功能如何实现?
我想用c#写个程序,当用户在网页上的文本框上点击右键时,能将该文本框的内容提取出来! --------------------编程问答-------------------- TextBox.Select();然后再放到黏贴板 --------------------编程问答-------------------- 楼上说的是什么意思? --------------------编程问答-------------------- 这个也许对你有用--------------------编程问答-------------------- 响应事件 onmousedown
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=gb2312">
<html>
<head>
<title>Page 1</title>
</head>
<STYLE type=text/css>A:link {
TEXT-DECORATION: none
}
A:visited {
TEXT-DECORATION: none
}
A:active {
TEXT-DECORATION: none
}
A:hover {
TEXT-DECORATION: underline overline
}
BODY {
COLOR: #000000; FONT-SIZE: 9pt
}
TH {
FONT-SIZE: 9pt
}
TD {
FONT-SIZE: 9pt
}
DIV {
FONT-SIZE: 9pt
}
</STYLE>
<STYLE type=text/css>BODY {
scrollbar-face-color: #C0C0C0; 轴面颜色: #FFFFFF; 箭头颜色: #C0C0C0; 轴面左边角颜色: #000000; 左立体边颜色: #808080; 轴面右边角颜色: #FFFFFF; 右立体边颜色: #E0E0E0; 轴轨道颜色:
}
</STYLE>
<!--滚动条颜色-->
<STYLE>.skin0 {
BACKGROUND-COLOR: menu; BORDER-BOTTOM: black 2px solid; BORDER-LEFT: black 2px solid; BORDER-RIGHT: black 2px solid; BORDER-TOP: black 2px solid; CURSOR: default; FONT-FAMILY: Verdana; LINE-HEIGHT: 20px; POSITION: absolute; TEXT-ALIGN: left; VISIBILITY: hidden; WIDTH: 200px
}
.skin1 {
BACKGROUND-COLOR: menu; BORDER-BOTTOM: buttonhighlight 2px outset; BORDER-LEFT: buttonhighlight 2px outset; BORDER-RIGHT: buttonhighlight 2px outset; BORDER-TOP: buttonhighlight 2px outset; CURSOR: default; FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 10pt; POSITION: absolute;z-index:9; TEXT-ALIGN: left; VISIBILITY: hidden; WIDTH: 120px
}
.menuitems {
FONT-SIZE: 9pt; PADDING-LEFT: 15px; PADDING-RIGHT: 10px
}
</STYLE>
<SCRIPT language=JavaScript1.2>
var menuskin = "skin1"; // skin0, or skin1
var display_url = 0; // Show URLs in status bar?
var selInputOb = null;
function showmenuie5() {
selInputOb = event.srcElement;
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = "visible";
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url)
window.status = event.srcElement.url;
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null)
window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
else
window.location = event.srcElement.url;
}
}
</SCRIPT>
<!--End user's custom HTML/Script!-->
<body bgcolor="#ffffff" onload="PageLoaded()" onunload="PageUnloaded()">
<!--User's custom HTML/Script!-->
<DIV class=skin0 id=ie5menu onclick=jumptoie5();
onmouseout=lowlightie5() onmouseover=highlightie5()>
<DIV class=menuitems url="javascript:history.back();">返回</DIV>
<HR>
<div class=menuitems url="javascript:selInputOb.value='我需要的';void(0);">输入数据</div>
<DIV class=menuitems url="javascript:history.go(1);">下一页</DIV>
</div>
<form onsubmit="OnWebFormSubmit()">
<input
type="text"
name="EditBox0"
ID="EditBox0"
tabindex="1"
accesskey=""
style=" "
>
<input
type="text"
name="EditBox1"
ID="EditBox1"
tabindex="1"
accesskey=""
style=" "
>
<SCRIPT language=JavaScript1.2>
if (document.all && window.print) {
ie5menu.className = menuskin;
document.forms[0].EditBox0.oncontextmenu = showmenuie5;
document.forms[0].EditBox1.oncontextmenu = showmenuie5;
document.body.onclick = hidemenuie5;
}
</SCRIPT>
</form>
</body>
</html>
本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/2833.htm
判断是鼠标右键
if(event.button == 2)
找事件源
event.srcelement
其他就是你的程序逻辑了 --------------------编程问答-------------------- 楼上的正解! --------------------编程问答--------------------
--------------------编程问答-------------------- 谢谢大家,网页并不是我的网页,我想从别人的网页的文本框上,通过鼠标右键获取其文本框内容。如钩子程序等,而不想大家说的那样网页是我的。我想用c#钩子程序获取别人网页上的文本框内容。 --------------------编程问答-------------------- 不是用js程序,而是用winform程序 --------------------编程问答--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function MouseDown(obj)
{
var sp = document.getElementById("span1");
if(event.button==2)
{
sp.innerText = obj.value;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table width="100%" cellpadding="2" cellspacing="2" border="1">
<tr>
<td>
<input type="text" id="text1" value="文本右键会出现在下面的SPAN中" onmousedown="MouseDown(this);" /></td>
</tr>
<tr>
<td>
<span id="span1"></span>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<body>--------------------编程问答--------------------
<script type="text/javascript">
function rightClick(){
if(window.event.button==2)alert(aa.value);
}
document.onmousedown = rightClick;
</script>
<input type="text" id="aa" onclick="document.onmousedown()">
</body>
那等高手吧. --------------------编程问答-------------------- 试试这个吧
经过VS2005运行通过
private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Clipboard.SetDataObject(textBox1 .Text .Trim ());
IDataObject idata = Clipboard.GetDataObject();
if(idata.GetDataPresent (DataFormats.Text))
textBox2.Text = (string)idata.GetData(DataFormats.Text);
}
}
private void FormRightClick_Load(object sender, EventArgs e)
{
textBox1.Text = "lingxizhixia";
}
补充:.NET技术 , C#