鱼C论坛

 找回密码
 立即注册
查看: 2902|回复: 3

delphi如何模拟点击网页按钮

[复制链接]
发表于 2014-7-19 10:18:11 | 显示全部楼层 |阅读模式
40鱼币
本帖最后由 iaistudy 于 2014-7-19 10:26 编辑

问题描述:单位的网上学习任务,要统计学习时间的,每隔10分钟点击下小窗口中的“更新学习时间按钮”,(此时小窗口最小化)。然后再点击网页消息框中的确定,最后再点击最大化更新学习时间那个小窗口。
初步计划在delphi中WebBrowser控件实现,浏览器弄好了,接下来点击“更新学习时间按钮” 按钮这一步实现不了。希望大家指点指点。

<html xmlns="http://www.w3.org/1999/xhtml">
<head >
    <title>2014全员远程培训</title>

    <script type="text/javascript" language="javascript">
            var StrPath = location.href
            if (StrPath.substring(0,4).toUpperCase()=="HTTP"){
            document.domain='leekyoo.cn';
        }
    </script>
    <script type="text/javascript" src="http://static.hainan.leekyoo.cn/fxl/js/floatWin.js"></script>
    <script type="text/javascript" src="http://static.hainan.leekyoo.cn/fxl/js/StudyfrmNew.js"></script>
    <script type="text/javascript" src="http://static.hainan.leekyoo.cn/fxl/js/pingbi.js"></script>

</head>

<body>
    <div id="bg" style="z-index:1;position:absolute;left:0px;top:0px;width:100%;height:100%;background-color:#FFFFFF;filter:Alpha(opacity=80);visibility:hidden;">
        <input type="hidden" id="isView" value="0"/></div>
       <div id="divDrag" style="z-index:100;position:absolute; left:0px;top:0px;width:100%;height:100%;background-color:#FFFFFF; filter:Alpha(opacity=1);visibility:hidden;"> </div>
    <iframe id="courseFrame" frameborder="0" scrolling="yes" src="http://course.leekyoo.cn/zxts001a/index.htm" width="100%" height="100%" style="z-index:1;"></iframe>

    <div style="z-index:999;position:absolute;top:0;left:0;width:600px;height:20px;border:4px solid #336699;" id="msgtip" >
        <div style="background-color:slategray;width:100%;height:20px;color:white;" title="按住鼠标左键拖动窗口"  id="msgTitle">
            <span style="width:80px;padding-left:3px;font-size:12px">更新学习时间</span>
            <span id="btn" style="width:12px;border-width:0px;color:white;font-family:webdings;cursor:hand;" title="最小化"><img src="zuixiao.jpg" alt="" style="vertical-align: bottom; border:0px;"/></span>
        </div>
        <div id="msg" style="height:115px;width:100%;">
        <iframe id="timeFrame" frameborder="0" scrolling="No" width="100%" height="115px" src="RecordTimeNew.aspx?bookid=86&StudyPlanBookID=53"></iframe>
        </div>
    </div>
</body>

</html>





想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-7-19 10:21:27 | 显示全部楼层
下面是js代码:

var hover='orange',normal='slategray',normalbordercolor='#336699',strTop='',strLeft='';

window.onload =window.onscroll = scrollMsgTip;

var moveable=false;
var x0=0,y0=0,x1=0,y1=0;
//开始拖动;
function startDrag(obj)
{
if(event.button==1)
{
   $("divDrag").style.visibility = "visible";
  
  //锁定标题栏;
  obj.setCapture();
  //定义对象;
  var win =  $("msgtip");
  //记录鼠标和层位置;
  x0 = event.clientX;
  y0 = event.clientY;
  x1 = parseInt(win.style.left);
  y1 = parseInt(win.style.top);
  //记录颜色;
  //normal = obj.style.backgroundColor;
  //改变风格;
  obj.style.backgroundColor = hover;
  win.style.borderColor = hover;
//  win.style.left = x1 ;
//  win.style.top  = y1 ;
  moveable = true;
  
  event.srcElement.setCapture();
}
}

//拖动;
function drag(obj)
{
if(moveable)
{
    //小窗口宽度 高度
    var winwidth=600,winheight=141;
    var msg = $("msg");
    var flg = msg.style.display=="none";
    if(flg)
    {
        winwidth=300,winheight=25;
    }
   
    obj.setCapture();
   var win = $("msgtip");
   var bg = $("bg");
   var x=x1 + event.clientX - x0;
   var y=y1 + event.clientY - y0;
   var l=document.body.scrollWidth;
   var h=document.body.scrollHeight;
  
   if(x<0){x=0;}
   if(x+winwidth>l){x=l-winwidth;} //小窗口宽度为600

   if(y<0){y=0;}
   if(y+winheight>h){y=h-winheight;}

   win.style.left =x;// x1 + event.clientX - x0;
   win.style.top  =y;// y1 + event.clientY - y0;
}
}

//停止拖动;
function stopDrag(obj)
{
if(moveable)
{
  $("divDrag").style.visibility = "hidden";
  var win = $("msgtip");
  var msg = $("msg");
  win.style.borderColor     = normalbordercolor;
  obj.style.backgroundColor = normal;
  msg.style.color           = normal;
  obj.releaseCapture();
  moveable = false;
  event.srcElement.releaseCapture();
}
}

    function min(obj)
    {
         var win = $("msgtip");
         var tit = $("msgTitle");
         var msg = $("msg");
         var flg = msg.style.display=="none";
         if(flg)
         {
              win.style.height  = parseInt(msg.style.height) + parseInt(tit.style.height);
              win.style.width = "600px";
              msg.style.display = "block";
              obj.innerHTML = "<img src=\"zuixiao.jpg\" style=\"vertical-align: bottom; border:0px;\"/>";//"0";
              $("btn").title = "最小化";
              
              if(strLeft!="" && strTop!="")
              {
                win.style.left = strLeft;
                win.style.top  = strTop;
              }
              else
              {
                scrollTip();
              }
         }
         else
         {
              closeDiv();
         }
    }

    function closeDiv()
    {
        var strisview=$("isView").value;
        if(strisview=="1")
        {
            timeFrame.window.document.getElementById("glowtext").innerHTML="请更新学习时间!";
            //timeFrame.window.startglowing();
            return;
        }
         var win = $("msgtip");
         var tit = $("msgTitle");
         var msg = $("msg");
          win.style.height  = parseInt(tit.style.height);
          win.style.width = "300px";
          $("btn").innerHTML = "<img src=\"zuida.jpg\" style=\"vertical-align: bottom; border:0px;\"/>";//"2";
          $("btn").title = "最大化";
          msg.style.display = "none";
          $("bg").style.visibility = "hidden";
          strLeft=win.style.left;
          strTop=win.style.top;
          scroll();
    }
   
    var tScaler;  //计时器
    //随机展开DIV
    function Time()
    {
        var win = $("msgtip");
        var tit = $("msgTitle");
        var msg = $("msg");
        //var num = Math.round(Math.random()*10) + 10;//Math.floor(Math.random()*0) + 1 //产生一个 10-20之间的随机数
        
        //tScaler = setTimeout("Time()",num * 60 * 1000);//根据随机数分钟数显示 IFrame ,在 IFrame 中提交时间
        if(!msg) return;
        win.style.height  = parseInt(msg.style.height) + parseInt(tit.style.height);
        win.style.width = "600px";
        msg.style.display = "block";
        $("btn").innerHTML = "<img src=\"zuixiao.jpg\" style=\"vertical-align: bottom; border:0px;\"/>";//"0";
        $("bg").style.visibility = "visible";
        scrollCenter();
        
        $("isView").value="1";
        
        //学习计时停止
        timeFrame.window.stopTimer();
        
        stopScaler();
        //窗口置前
        self.focus();
        window.onblur=function (){self.focus();}
    }
   
   
    function stopScaler(){
        //alert('stopScaler');
            clearTimeout(tScaler);
    }
   
    function statScaler(){
        var num = Math.round(Math.random()*9) + 11;//Math.floor(Math.random()*0) + 1;//产生一个 10-20之间的随机数
        //alert(num);
        tScaler = setTimeout("Time()",num * 60 * 1000);//根据随机数分钟数显示 IFrame ,在 IFrame 中提交时间//
        
        $("isView").value="0";
        window.onblur=function (){}
    }
   
    g_blnCheckUnload = true;
    window.onbeforeunload = function() {
    if(g_blnCheckUnload)
    {
                return '点"确定"结束学习,本次学习时间不会累计。点"取消"可继续学习。';
    }
}


function cg()
{
    timeFrame.window.stopTimer();
   
    min($("btn"));
    alert('更新学习时间成功!');
    timeFrame.window.DoConverseCallTimer();
    stopScaler();
    statScaler();
}


function isView0()
{
    $("isView").value="0";
}


function setPrompt(itype)
{
    if(itype=="0")
    {
        timeFrame.window.document.getElementById("glowtext").innerHTML="更新学习时间中请等待...";
    }
    else
    {
       timeFrame.window.document.getElementById("glowtext").innerHTML="";
    }
   

}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2014-11-23 18:53:54 | 显示全部楼层
表示不懂delphi,帮忙顶一下!!!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2015-8-5 14:51:09 | 显示全部楼层
好多
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-26 10:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表