關於 VB.NET 好像是 VB 2005 的前身,這我也搞不太清楚
總之大家都習慣把 VB 分為兩階段,一個是 古老的 VB6 另外一個就是 VB.NET
至於該稱呼 VB.NET 還是 2005, 2008, 2010 這我就不知道
昨天又試了很多次,終於找到如何讓 WebBrowser 中的圖片被點下去時
VB 中可以一起被觸發
先要用這兩行來讓 程序被觸發時,可以一起觸發自己設定的函數
不過這次作的更新器模擬只有用到 Navigating 被觸發的時候
複製程式
        AddHandler wb_back.Navigating, AddressOf local_event_wb_back_nav
        AddHandler wb_back.Document.Click, AddressOf local_event_wb_back_click
 然後在函數內可以用 wb_back.Document.GetElementById(Name) 來取得特定 ID 的物件
wb_back.Document.GetElementById(Name).GetAttribute(Attr) 則可以取得 屬性,例如 Checkbox 勾了沒
wb_back.Document.InvokeScript(Name, Obj) 則可以觸發 網頁中的 JavaScript,也能取得特定函數的值
wb_back.Document.ActiveElement.Name  則可以取得目前物件的名稱
有了以上方法,我就寫了第二版的 模擬CSO更新器
底下的程式碼在 Form1 (frm_main)
Form1 :複製程式
Public Class frm_main
    '---------- Local structures ----------
    Structure struc_prg
        Dim pack As Collection
        Dim curInd As Long
        Dim accum_total, accum_max As Long
        Dim cur_val, cur_max As Long
        Dim total_val, total_max As Long
    End Structure
    '---------- Local variables ----------
    'Files & Folders
    Dim dataDir As String = System.IO.Directory.GetCurrentDirectory & "\HTML\"
    'Status
    Dim stat_check_obj_ind As Integer
    Dim stat_wb_complete As Integer
    'Progress
    Dim prg As struc_prg
    '---------- Local objects ----------
    Dim WithEvents wb_back As New WebBrowser
    Private Sub frm_main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i, i2 As Integer
        '----- Variables -----
        'Status
        stat_wb_complete = 0
        'Size : Pack (@@@ Test @@@)
        prg.pack = New Collection
        Dim arrPack(,) = {{"Server Info", 100, "伺服器訊息"}, {"Map", 3000, "地圖檔"}, {"Amxx", 888, "插件平台"}, {"Plugin", 1999, "插件"}}
        For i = 0 To arrPack.GetUpperBound(0)
            For i2 = 0 To arrPack.GetUpperBound(1)
                prg.pack.Add(arrPack(i, i2))
            Next
        Next
        For i = 1 To prg.pack.Count / 3
            prg.accum_max += prg.pack.Item(i * 3 - 1)
        Next
        prg.curInd = 0
        '----- Form -----
        'Size
        Me.Size = New Size(704, 466)
        'Style
        Me.FormBorderStyle = 0
        Me.BackColor = Color.White
        '----- Sub -----
        'Build objects
        local_build_obj()
    End Sub
    Private Sub timer_check_obj_stat_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_check_obj_stat.Tick
        Dim flag As Boolean
        Select Case stat_check_obj_ind
            Case 1 'Web browser(Back)
                If wb_back.ReadyState = WebBrowserReadyState.Complete Then
                    flag = True
                    wb_back.Visible = True
                    stat_wb_complete = 1
                    local_new_pack() 'Test @@@
                End If
        End Select
        If flag Then timer_check_obj_stat.Enabled = False
    End Sub
    Private Sub timer_simul_prg_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_simul_prg.Tick
        'Test @@@
        Dim objArr(1) As Object
        Randomize()
        prg.cur_val += (Fix(50 * Rnd()) + 30)
        If prg.cur_val >= prg.pack.Item(prg.curInd * 3 - 1) Then
            prg.accum_total += prg.pack.Item(prg.curInd * 3 - 1)
            timer_simul_prg.Enabled = False
            local_new_pack()
            Exit Sub
        End If
        Randomize()
        timer_simul_prg.Interval = IIf(Fix(10 * Rnd()) = 0, 500, Fix(50 * Rnd()) + 1)
        'Set current progress
        objArr(0) = CObj(prg.cur_val) 'Value
        objArr(1) = CObj(prg.cur_max) 'Max
        local_wb_callScript("SetCurrentProgress", objArr)
        'Status
        objArr(0) = CObj(prg.pack.Item(prg.curInd * 3 - 2) & " 安裝中...(" & prg.cur_val & "/" & prg.cur_max & ")") 'Value
        local_wb_callScript("SetStatusText", objArr)
    End Sub
    Private Sub local_build_obj()
        Dim arrList As New List(Of Control)
        Dim arrSize As New List(Of Size)
        Dim arrPoint As New List(Of Point)
        Dim i As Integer
        arrList.Add(wb_back)
        arrSize.Add(New Size(688, 430))
        arrPoint.Add(New Point(0, 0))
        '--- Web browser ---
        For i = 0 To arrList.Count - 1
            arrList(i).Visible = False
            arrList(i).Parent = Me
            arrList(i).Size = arrSize(i)
            arrList(i).Location = arrPoint(i)
            wb_back.ScrollBarsEnabled = False
            'wb_back.ScriptErrorsSuppressed = True
        Next i
        'Write files
        Dim tempPath As String = dataDir & "133.html"
        My.Computer.FileSystem.WriteAllText(tempPath, My.Resources._133, False)
        'Navigate URL
        wb_back.Navigate("file://" & tempPath)
        local_new_objcheck(1)
        'Add handler
        AddHandler wb_back.Navigating, AddressOf local_event_wb_back_nav
        AddHandler wb_back.Document.Click, AddressOf local_event_wb_back_click
    End Sub
    Private Sub local_new_objcheck(ByRef ind As Integer)
        stat_check_obj_ind = ind
        timer_check_obj_stat.Enabled = True
    End Sub
    Private Sub local_event_wb_back_nav()
        If stat_wb_complete = 0 Then Exit Sub
        Select Case wb_back.Document.ActiveElement.Id
            Case "startGame"
                If wb_back.Document.GetElementById("agreement").GetAttribute("checked") = True Then
                    If wb_back.Document.InvokeScript("get_CanStart") = 1 Then
                        MsgBox("Game started.", MsgBoxStyle.Information, "Test")
                        End
                    End If
                End If
            Case "exitGame"
                If wb_back.Document.InvokeScript("get_CanStart") = 0 Then
                    If MsgBox("更新作業進行中.請問要結束嗎?", MsgBoxStyle.Exclamation + MsgBoxStyle.OkCancel, "CSOLauncher(Simulation)") = MsgBoxResult.Ok Then
                        End
                    End If
                Else
                    End
                End If
            Case "closeGame"
                If wb_back.Document.InvokeScript("get_CanStart") = 0 Then
                    If MsgBox("更新作業進行中.請問要結束嗎?", MsgBoxStyle.Exclamation + MsgBoxStyle.OkCancel, "CSOLauncher(Simulation)") = MsgBoxResult.Ok Then
                        End
                    End If
                Else
                    End
                End If
        End Select
    End Sub
    Private Sub local_event_wb_back_click()
        Select Case wb_back.Document.ActiveElement.Name
            Case ""
            Case "agreement"
        End Select
    End Sub
    Private Sub local_renew_finishprg()
        local_wb_callScript("OnAllDone", Nothing)
    End Sub
    Private Sub local_wb_callScript(ByRef s As String, ByRef objArr As Object)
        wb_back.Document.InvokeScript(s, objArr)
    End Sub
    Private Sub local_new_pack() 'Test @@@
        If prg.curInd = prg.pack.Count / 3 Then local_renew_finishprg() : Exit Sub
        Dim ObjArr(1) As Object
        prg.curInd += 1
        'Status
        ObjArr(0) = CObj("正在安裝" & prg.pack.Item(prg.curInd * 3) & "...")
        local_wb_callScript("SetStatusText", ObjArr)
        prg.cur_val = 0
        prg.cur_max = prg.pack.Item(prg.curInd * 3 - 1)
        'Reset total progress
        ObjArr(0) = CObj(prg.accum_total)
        ObjArr(1) = CObj(prg.accum_max)
        local_wb_callScript("SetTotalProgress", ObjArr)
        'Reset current progress
        ObjArr(0) = CObj(0)
        ObjArr(1) = CObj(prg.cur_max)
        local_wb_callScript("SetCurrentProgress", ObjArr)
        timer_simul_prg.Enabled = True
    End Sub
End Class
 必須加入 
Timer : timer_check_obj_stat (Interval = 100, Enabled=0) , timer_simul_prg (Interval = 1000, Enabled=0)
必須加入 
Resource : _133 (Files)
必須在程式執行資料夾放上 HTML資料夾(可以從底下的附件中找到)
Resource : _133 如下,其中被我修改了一點點
Resource : _133 :複製程式
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;" />
<title>Counter-Strike Online</title>
<style>
body {
  background-color : gray;
    margin : 0;
    padding : 0;
    font:12px Tahoma,Dotum,絡遺,Gulim,Verdana,sans-serif,serif;
}
.FrameBody {background-color: transparent}
img {border:0;}
#Wrapper01 {position:relative;width:688px;height:430px;background:url(bg01.jpg) no-repeat;}
#Wrapper02 {position:relative;width:688px;height:430px;background:url(bg02.jpg) no-repeat;}
  #NoticeFrame {position:absolute; left:8; top:185; width:671px; height:236px; z-index:3}
    #Install {position:absolute;top:145px;left:8px;width:671px;height:44px;}
        #BarTotalDiv {width:671px;height:6px;margin:0 0 0 0px;}
        #BarNowDiv {width:671px;height:6px;margin:5px 0 0 0px;}
        #InstallTxt {margin:6px 0 0 0;color:#FFFFFF;}
        #InstallTxt #InstallTxtPer {font-weight:bold;color:#C2B49A;float:right}
        
    .BtClose {position:absolute; left:673; top:6; width:13px; height:14px; z-index:3} 
    .BtClose a {width:13;height:14px;text-indent:-9000px;display:block;}
    #Wrapper01 .BtClose {background:url(close_n.jpg) no-repeat;}
    #Wrapper02 .BtClose {background:url(close_n.jpg) no-repeat;}
    
    .BtGamestart {position:absolute; left:419px; top:115; width:154px; height:28px; z-index:1} 
    .BtGamestart a {width:154px;height:28px;text-indent:-9000px;display:block;}
    .BtGamestart a:hover {width:154px;height:28px;text-indent:-9000px;display:block;}
    .BtGamestart_d {position:absolute; left:419px; top:115; width:154px; height:28px; z-index:1} 
    .BtGamestart_d a {width:154px;height:28px;text-indent:-9000px;display:block;}
    .BtGamestart_d a:hover {width:154px;height:28px;text-indent:-9000px;display:block;}
    #Wrapper01 .BtGamestart_d {background:url(start_d.jpg) no-repeat;}
    #Wrapper02 .BtGamestart_d {background:url(start_d.jpg) no-repeat;}
    
    #Wrapper01 .BtGamestart {background:url(start_n.jpg) no-repeat;}
    #Wrapper02 .BtGamestart {background:url(start_n.jpg) no-repeat;}
    #Wrapper01 .BtGamestart a:hover{background:url(start_o.jpg) no-repeat;}
    #Wrapper02 .BtGamestart a:hover{background:url(start_o.jpg) no-repeat;}
    
    .BtExit {position:absolute; left:585; top:115; width:93px; height:28px; z-index:2} 
    .BtExit a {width:93px;height:28px;text-indent:-9000px;display:block;}
    .BtExit a:hover {width:93;height:28;text-indent:-9000px;display:block;}
    #Wrapper01 .BtExit {background:url(exit_n.jpg) no-repeat;}
    #Wrapper02 .BtExit {background:url(exit_o.jpg) no-repeat;}
    .UserInfo{position:absolute;left:427px;top:63px;color:#c9f3ff;font:14px;} 
</style>
<script language="javascript">
<!--
var CanStart;
function SetNoticeUrl(url)
{
    document.getElementById("NoticeFrame").src = url;
    //alert(NoticeFrame.src);
}
function _onGameStart()
{
    
}
function get_CanStart()
{
    return CanStart
}
function _null() {}
function OnAllDone()
{
    var e = document.getElementById("startGame");
    if(agreement.checked)
    {
       e.parentElement.className = "BtGamestart";
       e.onclick = _onGameStart;
    }
    CanStart=1
    SetCurrentProgress(1, 1);
    SetTotalProgress(1, 1);
    lblStatus.innerText = "";
    InstallTxtPer.innerText = "更新完成,請點選開始遊戲按扭";
    //external.FlashWindow();
}
function checkAgreement()
{
   if(agreement.checked)
   {
      var barTotal = document.getElementById("barTotal");
      if(barTotal.width == 671)
      {
         var sb = document.getElementById("startGame");
         sb.parentElement.className = "BtGamestart";
         sb.onclick = _onGameStart;
      } 
   }
   else
   {
      var e = document.getElementById("startGame");
      e.parentElement.className = "BtGamestart_d";
      e.onclick = _null;      
   }
}
function SetTotalProgress(cur, total)
{
    //lblTotal.innerText = cur.toString() + "/" + total.toString();
    var lblTotal = document.getElementById("InstallTxtPer");
    if (lblTotal != null)
    {
        lblTotal.innerText = "進度 " + Math.round((cur/total * 100.0)) + "%";
    }
    var barTotal = document.getElementById("barTotal");
    if (barTotal != null)
    {
        barTotal.width = (cur/total) * barTotal.parentElement.offsetWidth;
    }
}
function SetCurrentProgress(cur, total)
{
    barCurrent.width = cur/total * barCurrent.parentElement.offsetWidth;
}
var g_output = "";
function Output(s)
{
    g_output += s + "<br>";
}
function SetStatusText(name)
{g_output
    //lblCurrent.innerText = name + " (" + cur + "/" + total + ")";
    lblStatus.innerText = name;
    //barCurrent.width = 0;
}
// -->
</script>
</head>
<body oncontextmenu="return false" onselectstart="return false;">
<script language="javascript">
<!--
var tag = '<div id="{0}">'
document.write(tag.replace('{0}', Math.random() < 0.5 ? 'Wrapper01' : 'Wrapper02'));
//-->
</script>
    <div id="Install">
        <div id="BarTotalDiv"><img id="barTotal" src="bar_total.gif" width="0%" height="6"></div>
        <div id="BarNowDiv"><img id="barCurrent" src="bar_now.gif" width="0%" height="6"></div>
        <div id="InstallTxt"><span id="InstallTxtPer">進度 0%</span><span id="lblStatus">Now Downloading...</span></div>
    </div>
    
    <span class="BtClose"><a href="javascript:_null()" id="closeGame">Close</a></span>
    <span class="BtGamestart_d"><a href="javascript:_null()" id="startGame">Start</a></span>
    <span class="BtExit"><a href="javascript:_null()" id="exitGame">Exit</a></span>
    <span class="UserInfo"><a href="http://tw.beanfun.com/cso/support_06.aspx" target="_blank">[遊戲服務合約書]</a></span>
    <span style="position:absolute;right:30px;top:63px;color:#ffffff;font:14px;"><input name="agreement" type="checkbox" value="0" onClick="checkAgreement()">我已閱讀並同意</span>
    <span style="position:absolute;right:30px;top:83px;color:#b4b4b4;">我已閱讀並同意遊戲服務合約書</span>
    
    <iframe src="http://tw.beanfun.com/cso/www/game_login.aspx" id="NoticeFrame" frameborder="0" width="100%" height="100%"  marginwidth="0" marginheight="0" scrolling="no" allowtransparency="true"></iframe>
    
</body>
</html>
 
可以下載看看,我已經把 進度列 等全部模擬完成
接下來你只要去修改 操控進度列的函數(在程式中),就能輕易達到更新的效果
不過這全拜 CSO 更新器是以 "HTML" 方式來執行所賜,所以在程式中,其實只用了一個 WebBrowser 而已
那些 Image 全部都是在 WebBrowser 裡面,因此位置、大小、觸發程序 都已經被 HTML碼設定好了
VB程式中只需要 攔截觸發,呼叫函數,還有判斷函數的值就行了,那些進度列的樣式都已經被設定好了,真方便
現在已經幾乎與 CSO 更新器一模一樣,只差進度列更新時不太一樣 
  
 CSOLauncher_Simulation 程式下載: