Advertisement
Drivium

AoBTool_Raw

Jun 19th, 2017
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 24.28 KB | None | 0 0
  1.     <html style="background: #5A5A5A">
  2.     <head>
  3.     <title>AoBTool™</title>
  4.     <!--Styles defined for doc (start)-->
  5.     <style type="text/css">
  6.         body {
  7.             filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=White, EndColorStr=#acacac);
  8.             font-family:Verdana;
  9.             font-size: 12px;
  10.             color: #5e5e5e;
  11.             background-color: -ms-linear-gradient(top, #2F2727, #1a82f7);
  12.             text-align: center;
  13.             border-collapse: collapse;
  14.             }
  15.         fieldset {
  16.             padding: 10px;
  17.             }
  18.         #seldd {
  19.             width: 100px;
  20.                 }
  21.         button {
  22.          filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=White, EndColorStr=#acacac);
  23.          font-family:Verdana;
  24.          font-size: 14px;
  25.          height: 30px;
  26.          width: 150px;
  27.          font-weight: bold;
  28.             }
  29.         td {
  30.             border-width: 0px;
  31.             padding: 4px;
  32.             border-style: solid;
  33.             border-color: black;
  34.             }
  35.         .tableNorm {
  36.             filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=white, EndColorStr=#acacac);
  37.             border-collapse: collapse;
  38.             border-width: thin;
  39.             border-color: black;
  40.             border-style: groove;
  41.             font-size: 10px;
  42.             font-weight: color;
  43.             color: black;
  44.             }
  45.         .info1 {  
  46.             text-align: center;
  47.             font-size: 8pt;
  48.             font-weight: color;
  49.             color: black;
  50.             }
  51.         .tabs {
  52.             border-collapse: collapse;
  53.             color: black;
  54.             cursor: pointer;
  55.             cursor: hand;
  56.             font-family: arial;
  57.             font-size: 9pt;
  58.             font-weight: bold;
  59.             margin-top: 4px;
  60.             padding: 2px 4px 0px 4px;
  61.             position: relative;
  62.             text-align: center;
  63.             text-decoration: none;
  64.             z-index: 1;
  65.             }
  66.         .tabsNotSelected {
  67.             background-color: grey;
  68.             border: solid 1px black;
  69.             }
  70.         .tabsSelected {
  71.             filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#FFFFFF, EndColorStr=#aaacae;
  72.             border-color: black black white black;
  73.             border-style: solid solid solid solid;
  74.             border-width: 1px 1px 1px 1px;
  75.             }
  76.  
  77.     </style>
  78.     <!--Styles defined for doc (end)-->
  79.     <!--Scripts to control app window size, position, and behavior (start)-->
  80.     <script language="VBScript">
  81.     Function Window_OnLoad()
  82.     aob_spn_aobcountArea.style.display = "block"
  83.     aob_spn_RunArea.style.display = "none"
  84.     aob_spn_DataArea.style.display = "none"
  85.     aob_spn_WCArea.style.display = "none"
  86.     call ResizeWindow()
  87.     end function
  88.     '========================
  89.     Function ResizeWindow()
  90.     hght = document.body.clientHeight
  91.                 Do While abs(document.body.clientHeight - document.body.scrollHeight) >= 10
  92.                 If document.body.clientHeight < document.body.scrollHeight then
  93.                 hght = hght + 13
  94.                 else
  95.                 hght = hght - 13
  96.                 end if
  97.                 window.resizeTo 700,hght
  98.                 call Refresh()
  99.                 Loop
  100.     End Function
  101.     '========================
  102.                 window.resizeTo 750,200
  103.                 screenWidth = Document.ParentWindow.Screen.AvailWidth
  104.                 screenHeight = Document.ParentWindow.Screen.AvailHeight
  105.                 posLeft = (screenWidth - 750) / 2
  106.                 posTop = (screenHeight - 600) / 2    
  107.                 'move to centerscreen
  108.                 window.moveTo posLeft, posTop
  109.     </script>
  110.     <!--Scripts to control app window size, position, and behavior (end)-->
  111.     <!--Features of app window (start)-->
  112.     <HTA:APPLICATION ID="AoBTool"
  113.                 APPLICATIONNAME="AoBTool"
  114.                 version="ver.2017.7.7"
  115.                 BORDER="thin"
  116.                 BORDERSTYLE="raised"
  117.                 CAPTION="yes"
  118.                 CONTEXTMENU="yes"
  119.                 ICON="#"
  120.                 INNERBORDER="no"
  121.                 MAXIMIZEBUTTON="no"
  122.                 MINIMIZEBUTTON="yes"
  123.                 NAVIGABLE="no"
  124.                 SCROLL="no"
  125.                 SCROLLFLAT="no"
  126.                 SELECTION="no"
  127.                 SHOWINTASKBAR="yes"
  128.                 SINGLEINSTANCE="yes"
  129.                 SYSMENU="yes"
  130.                 WINDOWSTATE="normal">
  131.     </head>
  132.     <!--Features of app window (end)-->
  133.     <!--Script to control tab behavior (start)-->
  134.     <script language="VBscript">
  135.     Dim iPanelCount
  136.     iPanelCount = 3
  137.  
  138.     Private Sub Panel(tab)
  139.  
  140.     For i = 1 To iPanelCount
  141.         If i = tab Then
  142.             document.getElementById("tab" & i).className = "tabs tabsSelected"
  143.             document.getElementById("panel" & i).style.display = "block"
  144.         Else
  145.             document.getElementById("tab" & i).className = "tabs tabsNotSelected"
  146.             document.getElementById("panel" & i).style.display = "none"
  147.         end if
  148.     Next
  149.  
  150.     call ResizeWindow()
  151.  
  152.     End Sub
  153.     </script>
  154.     <!--Script to control tab behavior (end)-->
  155.  
  156.     <body>
  157.     <table class="tableNorm" id="mainTable" align="center" border="0" cellpadding="0" cellspacing="0" width="650">
  158.         <tr>
  159.             <td colspan="1">
  160.             <span class="tabs tabsSelected" id="tab1" onclick="panel(1)">AoBTool™</span>
  161.             <span class="tabs tabsNotSelected" id="tab2" onclick="panel(2)">OffsetTool</span>
  162.             <span class="tabs tabsNotSelected" id="tab3" onclick="panel(3)">About</span>
  163.  
  164.     <!--Code for each tab (buttons, text boxes, etc)-->
  165.     <div class="panel" id="panel1" style="display:block">
  166.         <H3><b><font color="darkred">AoB</font>Tool™</b></H3>
  167.         <span style="display:none;" id="aob_spn_aobcountArea">
  168.         <center><H4>How many AoB's would you like to compare?</H4>
  169.         <select name="seldd" id="seldd" onchange="aobBox()">
  170.             <option value="1">Select</option>
  171.             <option value="2">2</option>
  172.             <option value="3">3</option>
  173.             <option value="4">4</option>
  174.             <option value="5">5</option>
  175.         </select>
  176.         <br>
  177.         <br>                
  178.         </center>
  179.         </span>
  180.         <span style="display:none;" id="aob_spn_wldCharArea"><center><H4>Wildcard: <input type="text" title="Note: This will be the only allowable wildcard." name="wldChar" id="wldChar" maxlength="1" value="?" size="1" style="text-align:center;"/></H4></center></span>
  181.         <span style="display:none;" id="aob_spn_WCArea"></span>
  182.         <span style="display:none;" id="aob_spn_DataArea"></span>
  183.         <span style="display:none;" id="aob_spn_RunArea"><br><center><button type="button" id="aob_run_btn" onClick="fixSpaces()">Compare!</button></center></span>
  184.         <span style="display:none;" id="aob_spn_ResetArea"><br><center><button type="button" id="aob_reset_btn" onClick="aobreset()">Reset</button></center></span>
  185.     </div>
  186.  
  187.     <div class="panel" id="panel2" style="display:none">
  188.         <H3><b><font color="darkred">Offset</font>Tool</b></H3>
  189.         <center><span style="display:inline-block; width: 580;">
  190.             <table>
  191.                 <tr>
  192.                     <td>
  193.                         <center><label>Start Address</label></center>
  194.                     </td>
  195.                     <td>
  196.                         <label></label>
  197.                     </td>
  198.                     <td>
  199.                         <center><label>Offset</label></center>
  200.                     </td>
  201.                     <td>
  202.                         <center><label>New Address</label></center>
  203.                     </td>
  204.                 </tr>
  205.                 <tr>
  206.                     <td>
  207.                         <input type="text" name="ofst_strt" id="ofst_strt" maxlength="15" size="16"/>
  208.                     </td>
  209.                     <td>
  210.                         <select name="selArth" id="selArth">
  211.                         <option value="Select">Select</option>
  212.                         <option value="+">+</option>
  213.                         <option value="-">-</option>
  214.                         </select>
  215.                     </td>
  216.                     <td>
  217.                         <input type="text" name="ofst_end" id="ofst_end" maxlength="15" size="16"/>
  218.                     </td>
  219.                     <td>
  220.                         <input readonly style="text-align: center;" type="text" name="ofst" id="ofst" maxlength="20" size="20"/>
  221.                     </td>
  222.                 </tr>
  223.             </table>
  224.         </span></center>
  225.         <br><center><button type="button" id="ofst_run_btn" onClick="localhexcalc()">Run</button></center>
  226.         <center><span style="display:none;" id="ofst_WebMsgArea"></span></center>
  227.         <center><span style="display:none;" id="ofst_LocMsgArea"></span></center>
  228.     </div>
  229.  
  230.     <div class="panel" id="panel3" style="display:none">
  231.         <H4><b>Origin Story</b></H4>
  232.         <span style="display:inline-block; width: 580;">
  233.             <p><font class="info1">This tool is intended for use with <a href="http://www.cheatengine.org/" style="color:blue;text-decoration:none">Cheat Engine</a>'s array of bytes scanner.<br><br>Developed by <b><a href="http://forum.cheatengine.org/profile.php?mode=viewprofile&u=348916" style="color:blue;text-decoration:none">Drivium</a></b><br><a href="https://discordapp.com/" style="color:blue;text-decoration:none">Discord</a>: Drivium#2488<br><br>
  234.             Inspired by the original VBScript tool created by:<b><a href="http://forum.cheatengine.org/profile.php?mode=viewprofile&u=338952" style="color:blue;text-decoration:none" alt="AikonCWD's Profile""><img src="http://i.imgur.com/f6rnuaV.gif" alt="AikonCWD's Profile" width="20" height="20" border="0" style="vertical-align: middle;"/>AikonCWD<img src="http://i.imgur.com/f6rnuaV.gif" alt="AikonCWD's Profile" width="20" height="20" border="0" style="vertical-align: middle;"/></a></b><br>Found here: <a href="http://forum.cheatengine.org/viewtopic.php?t=572933" style="color:blue;text-decoration:none">[TOOL] AoB Pattern Generator (coded in VBS, OpenSource)</a><br><br>
  235.             <a href="https://drive.google.com/open?id=0B7UqN53jp_4cMEEzT1h1N0ozdVU" style="color:blue;text-decoration:none">AoBTool™</a> shared in the following forums: <a href="http://forum.cheatengine.org/viewtopic.php?t=604665"><img src="http://i34.tinypic.com/33etueb.jpg" alt="Cheat Engine Forums" width="50" height="50" border="0" style="vertical-align: middle;"/></a><a href="https://www.reddit.com/r/cheatengine/comments/6e8s81/release_aob_tool_for_comparing_and_adding/"><img src="https://assets.ifttt.com/images/channels/1352860597/icons/on_color_large.png" alt="/r/cheatengine" width="50" height="50" border="0" style="vertical-align: middle;"/></a><a href="http://fearlessrevolution.com/viewtopic.php?f=8&t=2790" style="color:blue;text-decoration:none">Fearless Revolution</a></font></p>
  236.         </span>
  237.     </div>
  238.  
  239.             </td>
  240.         </tr>
  241.     </table>
  242.     </body>
  243.     </html>
  244.  
  245.     <script language="VBScript">
  246.     'Set Global Variables
  247.     Dim newW
  248.     Dim wldChar
  249.     Dim T
  250.  
  251.     </script>
  252.  
  253.     <!--Begin scripts for 1st tab -->
  254.     <script language="VBScript">
  255.     Sub aob_Convert(T)
  256.  
  257.     'Original script created by AikonCWD.  Modified by Drivium.
  258.  
  259.     wldChar = document.getElementByID("wldChar").value
  260.  
  261.     AoB = Split(T, vbcrlf)
  262.  
  263.     F = ""
  264.     X = 0
  265.     For i = 1 To Len(AoB(0))
  266.         For u = 1 To UBound(AoB)
  267.             If Mid(AoB(u), i, 1) <> Mid(AoB(0), i, 1) Then
  268.                 F = F & "?"
  269.                 X = 1
  270.                 Exit For
  271.             End If
  272.         Next
  273.         If X <> 1 Then F = F & Mid(AoB(0), i, 1)
  274.             X = 0
  275.     Next
  276.  
  277.     Set re = new regexp
  278.     oldF = F
  279.     re.Pattern = "([\?]\w)|(\w[\?])"
  280.     re.Global = True
  281.     newF = re.Replace(oldF, "??")
  282.     newWC = replace(newF, "?", wldChar)
  283.     newW = len(newWC) - len(replace(newWC, wldChar, ""))
  284.  
  285.     '=====================================================================
  286.     'Fix spaces in AoB result
  287.  
  288.         newString = lcase(replace(newWC," ",""))
  289.  
  290.         Set r = New RegExp
  291.         r.Global = True
  292.         r.Pattern = "(.{2})"
  293.  
  294.         document.getElementById("aobresult").value = trim(r.Replace(newString, "$1 "))
  295.  
  296.     '=====================================================================
  297.  
  298.     call showWildcardStat()
  299.  
  300.     document.ParentWindow.ClipboardData.SetData "text", newWC
  301.  
  302.     Alert "Result Copied to Clipboard!"
  303.  
  304.     end sub
  305.     </script>
  306.  
  307.     <!--'============================================================================================================-->
  308.     <!-- Subs and Functions (start)-->
  309.     <script language="VBScript">
  310.     'Triggers screen updates in an HTA...
  311.     Sub Refresh
  312.     With CreateObject("WScript.Shell")  
  313.         .run "%comspec% /c echo something & exit", 0, true  
  314.     End With  
  315.     End Sub
  316.     '===================================
  317.     Function showWildcardStat()
  318.  
  319.     if document.getElementById("aobresult").value = "" then
  320.         aob_spn_WCArea.style.display = "none"
  321.     else
  322.         aob_spn_WCArea.style.display = "block"
  323.         aob_spn_wldCharArea.style.display = "none"
  324.         aob_spn_WCArea.InnerHTML = "<br><center><H4><b>Bytes Replaced: " & round(newW/2,0) & "</b></H4></center>"
  325.         aob_spn_RunArea.style.display = "none"
  326.         aob_spn_ResetArea.style.display = "block"
  327.         call ResizeWindow()
  328.     end if
  329.  
  330.     end function
  331.     '============================
  332.     Function aobBox()
  333.  
  334.     aob_spn_wldCharArea.style.display = "block"
  335.  
  336.     if document.getElementById("seldd").value = "1" then
  337.  
  338.         exit function
  339.  
  340.     else
  341.  
  342.         boxsize = document.getElementById("seldd").value
  343.  
  344.     end if
  345.  
  346.     aobBoxStart =   "<fieldset>" & _
  347.                     "<Legend>ver.2017.7.7</legend>" & vbcrlf
  348.  
  349.         for i = 1 to document.getElementById("seldd").value                          
  350.  
  351.             box =   box & "<b>AoB " & i & "</b>" & _
  352.                             "<table width='100%'>" & _
  353.                                 "<tr>" & _
  354.                                     "<td><textarea style='width:100%' name='aob" & i & "' rows=" & 12/boxsize & " id='aobtextbox" & i & "' onkeyup='btnDisplay()'></textarea></td>" & _
  355.                                 "</tr>" & _
  356.                             "</table>" & vbcrlf
  357.  
  358.         next
  359.  
  360.     aobBoxEnd = "<b>Result</b>" & _
  361.                 "<table width='100%'>" & _
  362.                     "<tr>" & _
  363.                         "<td><textarea readonly style='width:100%' name='result' rows=5 id='aobresult'></textarea></td>" & _
  364.                     "</tr>" & _
  365.                 "</table>" & _
  366.                 "</fieldset>"
  367.  
  368.     aob_spn_ResetArea.style.display = "block"
  369.     aob_spn_aobcountArea.style.display = "none"
  370.     aob_spn_DataArea.style.display = "block"
  371.     aob_spn_DataArea.InnerHTML = aobBoxStart & box & aobBoxEnd
  372.  
  373.     call ResizeWindow()
  374.  
  375.     end function
  376.     '============================
  377.     Function aobreset()
  378.  
  379.     for i = 1 to document.getElementById("seldd").value
  380.         if not document.getElementById("aobtextbox" & i) is nothing then
  381.             document.getElementById("aobtextbox" & i).value = ""
  382.         end if
  383.  
  384.     next      
  385.  
  386.         document.getElementById("aobresult").value = ""
  387.         document.getElementByID("wldChar").value = "?"
  388.         aob_spn_wldCharArea.style.display = "none"
  389.         aob_spn_RunArea.style.display = "none"
  390.         aob_spn_WCArea.style.display = "none"
  391.         aob_spn_ResetArea.style.display = "none"
  392.         aob_spn_DataArea.style.display = "none"
  393.         aob_spn_aobcountArea.style.display = "block"
  394.         document.getElementById("seldd").value = "1"
  395.         call ResizeWindow()
  396.  
  397.     end function
  398.     '============================
  399.     Function btnDisplay()
  400.  
  401.     nullCount = 0
  402.  
  403.     for i = 1 to document.getElementById("seldd").value
  404.         if document.getElementById("aobtextbox" & i).value = "" then
  405.             nullCount = nullCount + 1
  406.         end if
  407.     next
  408.  
  409.     if nullCount = 0 then
  410.         aob_spn_RunArea.style.display = "block"
  411.         aob_spn_ResetArea.style.display = "none"
  412.         call ResizeWindow()
  413.  
  414.     else
  415.  
  416.         document.getElementById("aobresult").value = ""
  417.         aob_spn_RunArea.style.display = "none"
  418.         aob_spn_ResetArea.style.display = "block"
  419.         call ResizeWindow()
  420.     end if
  421.  
  422.     end function
  423.     '============================
  424.     Function fixSpaces()
  425.  
  426.     for ii = 1 to document.getElementById("seldd").value
  427.  
  428.         newString = lcase(replace(document.getElementById("aobtextbox" & ii).value," ",""))
  429.  
  430.         Set r = New RegExp
  431.         r.Global = True
  432.         r.Pattern = "(.{2})"
  433.  
  434.         'document.getElementById("aobtextbox" & ii).value = trim(r.Replace(newString, "$1 "))
  435.  
  436.         remLineBrks = replace(newString,vbcrlf,"")
  437.         remSpaces = trim(r.Replace(remLineBrks, "$1 "))
  438.    
  439.         document.getElementById("aobtextbox" & ii).value = remSpaces
  440.        
  441.     next
  442.  
  443.     call mergeAOB()
  444.  
  445.     end function
  446.     '============================
  447.     Function mergeAOB()
  448.  
  449.     T = document.getElementById("aobtextbox1").value
  450.     for ii = 2 to document.getElementById("seldd").value
  451.         if  not document.getElementById("aobtextbox" & ii) is nothing then
  452.             if document.getElementById("aobtextbox" & ii).value <> "" then
  453.                 T = T & vbcrlf & document.getElementById("aobtextbox" & ii).value
  454.             end if
  455.         end if
  456.     next
  457.  
  458.     call valChar(T)
  459.  
  460.     end function
  461.     '============================
  462.     Function valChar(C)
  463.  
  464.     'Validate wild card characters
  465.  
  466.     Set objRegEx1 = New RegExp
  467.     objRegEx1.IgnoreCase = True
  468.     objRegEx1.Global = True
  469.     wcPat = "[a-f0-9 ]"
  470.     objRegEx1.Pattern = wcPat
  471.  
  472.     wldChar = document.getElementByID("wldChar").value
  473.  
  474.     Set colMatches1 = objRegEx1.Execute(wldChar)
  475.  
  476.     If colMatches1.Count > 0 Then
  477.         For Each strMatch1 in colMatches1
  478.             errMatch1 = strMatch1.Value
  479.         Next
  480.  
  481.         If errMatch1 = " " then
  482.             alert "Ok, technically a space is a non-Hexadecimal character - so you're on the right track, but using a space causes other issues in this tool.  Please enter a non-Hexadecimal character (that's also not a space!)"
  483.             document.getElementByID("wldChar").value = "?"
  484.             exit function
  485.         else
  486.             alert chr(34) & errMatch1 & chr(34) & " is a Hexadecimal character.  Please enter a non-Hexadecimal character"
  487.             document.getElementByID("wldChar").value = "?"
  488.             exit function
  489.         end if
  490.     end if
  491.  
  492.     '-------------------------------------
  493.     'Validate AoB box characters
  494.     Set objRegEx = New RegExp
  495.     objRegEx.IgnoreCase = True
  496.     objRegEx.Global = True
  497.     newPat = "[^\?a-f0-9\s]"
  498.     objRegEx.Pattern = replace(newPat,"?",wldChar)
  499.  
  500.     strSearchString = C
  501.  
  502.     Set colMatches = objRegEx.Execute(strSearchString)
  503.  
  504.     If colMatches.Count > 0 Then
  505.        
  506.         For Each strMatch in colMatches
  507.             errMatch = errMatch & strMatch.Value
  508.         Next
  509.  
  510.         Set oCol = CreateObject("Scripting.Dictionary")
  511.         lCount = Len(errMatch)
  512.  
  513.         For lCtr = 1 To lCount
  514.             sChar = Mid(errMatch, lCtr, 1)
  515.             On Error Resume Next
  516.             oCol.Add sChar, sChar
  517.             If Err.Number = 0 Then sAns = sAns & sChar
  518.                 Err.Clear
  519.                 xChar = xChar & sChar & vbcrlf
  520.         Next                
  521.  
  522.             uniChar = split(xChar,vbcrlf)
  523.  
  524.         For iVal = 1 to document.getElementById("seldd").value
  525.  
  526.             For i = 0 to ubound(uniChar)-1
  527.  
  528.                 if instr(document.getElementById("aobtextbox" & iVal).value,uniChar(i)) then
  529.                     missingAoB = missingAoB & "AoB " & iVal & vbcrlf
  530.                     exit for
  531.                     'clearlist = clearlist & "," & iVal
  532.                 end if
  533.  
  534.             Next
  535.  
  536.         Next
  537.  
  538.         For iii = 1 To Len(sAns)
  539.             if Len(sAns) = 1 then
  540.                 badList = sAns
  541.             elseif iii < Len(sAns) and Len(sAns) > 1 then
  542.                 badList = badList & replace(Mid(sAns,iii,1),Mid(sAns,iii,1),Mid(sAns,iii,1) & ", ")
  543.             elseif iii = Len(sAns) and Len(sAns) > 1 then
  544.                 badList = badList & " and " & Mid(sAns,iii,1)
  545.             end if
  546.         next
  547.  
  548.         Alert "Non-hexadecimal character(s) (" & badList & ") found in: " & vbcrlf & missingAoB & vbcrlf & "Note: The chosen wilcard " & chr(34) & document.getElementByID("wldChar").value & chr(34) & " is the only acceptable non-hexadecimal character for this session."
  549.  
  550.         remBadCharMsg = msgbox("Would you like AoBTool™ to remove these for you?",4,"Remove Invalid Characters?")
  551.  
  552.         if remBadCharMsg = vbYes then
  553.             For ii = 1 to document.getElementById("seldd").value
  554.                 For iiii = 1 To Len(sAns)
  555.                     if instr(document.getElementById("aobtextbox" & ii).value,Mid(sAns,iiii,1)) then
  556.                         remBadChars = replace(document.getElementById("aobtextbox" & ii).value,Mid(sAns,iiii,1)," ")
  557.                         document.getElementById("aobtextbox" & ii).value = remBadChars
  558.                         document.getElementById("aobtextbox" & ii).value = trim(document.getElementById("aobtextbox" & ii).value)
  559.                     End If
  560.                 Next
  561.             Next
  562.         end if
  563.  
  564.     else
  565.  
  566.         call aob_Convert(C)
  567.  
  568.     end if
  569.  
  570.     end function
  571.  
  572.     '==========================================
  573.     Function localhexcalc()
  574.  
  575.     hex1 = document.getElementByID("ofst_strt").value
  576.     hex2 = document.getElementByID("ofst_end").value
  577.    
  578.     if hex1 = "" or hex2 = "" then
  579.         alert "Nothing to calculate!"
  580.         alert "Enter a hex value into each box."
  581.         exit function
  582.     end if
  583.  
  584.     '-------------------
  585.     'Hex Validation
  586.  
  587.     Set objRegEx = New RegExp
  588.     objRegEx.IgnoreCase = True
  589.     objRegEx.Global = True
  590.     hexPat = "[^a-f0-9]"
  591.     objRegEx.Pattern = hexPat
  592.  
  593.     hexVal1 = document.getElementByID("ofst_strt").value
  594.  
  595.     Set colMatches = objRegEx.Execute(hexVal1)
  596.  
  597.     If colMatches.Count > 0 Then
  598.         For Each strMatch in colMatches
  599.             errMatch = strMatch.Value
  600.         Next
  601.  
  602.         alert chr(34) & errMatch & chr(34) & " is not a Hexadecimal character." & vbcrlf & vbcrlf & "Only Hexadecimal characters can be calculated."
  603.         document.getElementByID("ofst_strt").value = ""
  604.         exit function
  605.     end if
  606.  
  607.     hexVal2 = document.getElementByID("ofst_end").value
  608.  
  609.     Set colMatches = objRegEx.Execute(hexVal2)
  610.  
  611.     If colMatches.Count > 0 Then
  612.         For Each strMatch in colMatches
  613.             errMatch = strMatch.Value
  614.         Next
  615.  
  616.         alert chr(34) & errMatch & chr(34) & " is not a Hexadecimal character." & vbcrlf & vbcrlf & "Only Hexadecimal characters can be calculated."
  617.         document.getElementByID("ofst_end").value = ""
  618.         exit function
  619.     end if
  620.  
  621.     '--------------------
  622.  
  623.     if len(hex1) > 8 or len(hex2) > 8 then
  624.         call webhexcalc()
  625.         exit function
  626.     end if
  627.        
  628.     ofst_LocMsgArea.style.display = "block"
  629.     document.getElementByID("ofst_WebMsgArea").innerHtml = "Getting local results..."
  630.            
  631.     int1 = CLng("&h" & hex1)
  632.     int2 = CLng("&h" & hex2)
  633.  
  634.     if document.getElementById("selArth").value = "Select" then
  635.         alert "Please select addition or subtraction."
  636.         exit function
  637.  
  638.     else
  639.  
  640.         arth = document.getElementById("selArth").value
  641.        
  642.         if arth = "+" then
  643.             int3 = int1 + int2
  644.         elseif arth = "-" then
  645.             int3 = int1 - int2
  646.         end if 
  647.        
  648.         on error resume next
  649.         document.getElementByID("ofst").value = Hex(int3)
  650.         if Err.Number <> 0 then
  651.             call webhexcalc()
  652.             Err.clear
  653.             on error goto 0
  654.             exit function
  655.         end if
  656.        
  657.     end if
  658.  
  659.     ofst_LocMsgArea.style.display = "none"
  660.     call ResizeWindow()
  661.            
  662.     end function
  663.  
  664.     '==========================================
  665.     function webhexcalc()
  666.  
  667.     document.getElementByID("ofst").value = ""
  668.  
  669.     hex1 = document.getElementByID("ofst_strt").value
  670.     hex2 = document.getElementByID("ofst_end").value
  671.    
  672.     if hex1 = "" or hex2 = "" then
  673.         alert "Nothing to calculate!"
  674.         alert "Enter a hex value into each box."
  675.         exit function
  676.     end if
  677.  
  678.     if document.getElementById("selArth").value = "Select" then
  679.         alert "Please select addition or subtraction."
  680.         exit function
  681.  
  682.     else
  683.        
  684.             timeOutMsg = "<center>There was a problem retrieving results...<br>Try again!</center>"
  685.        
  686.             ofst_WebMsgArea.style.display = "block"
  687.             document.getElementByID("ofst_WebMsgArea").innerHtml = "Calculation result exceeds local calculation capabilities<br>Getting results from web..."
  688.             call ResizeWindow()
  689.            
  690.             limit = second(Now())
  691.            
  692.             arth = document.getElementById("selArth").value
  693.        
  694.             if arth = "+" then
  695.                 Set IE = CreateObject("internetexplorer.application")
  696.                 IE.Visible = false
  697.                 IE.Navigate "http://www.calculator.net/hex-calculator.html?number1=" & hex1 & "&c2op=%2B&number2=" & hex2 & "&calctype=op&x=89&y"
  698.                 Do While (IE.Busy or IE.ReadyState <> 4) and abs(second(Now())-limit) <= 6:ccSleep(0.25):Loop
  699.                 on error resume next
  700.                 if not ie.document.GetElementsByTagName("p") is nothing then
  701.                     For Each p in ie.document.GetElementsByTagName("p")
  702.                         if p.getAttribute("class") = "verybigtext" and instr(p.innertext,"Hex value:") and not ie.document.GetElementsByTagName("p") is nothing then
  703.                             for each b in p.getElementsByTagName("b")
  704.                                 hexResult = b.innertext
  705.                                 exit for
  706.                             next
  707.                         elseif abs(second(Now())-limit) >=6 then
  708.                             document.getElementByID("ofst_WebMsgArea").innerHtml = "Having trouble retrieving web results...<br>Please try again!"
  709.                             document.getElementByID("ofst").value = ""
  710.                             ie.quit
  711.                             exit function
  712.                         end if
  713.                     Next
  714.                 else
  715.                     document.getElementByID("ofst_WebMsgArea").innerHtml = "Having trouble retrieving web results...<br>Please try again!"
  716.                     document.getElementByID("ofst").value = ""
  717.                     ie.quit
  718.                     exit function
  719.                 end if
  720.                 on error goto 0
  721.             elseif arth = "-" then
  722.                 Set IE = CreateObject("internetexplorer.application")
  723.                 IE.Visible = false
  724.                 IE.Navigate "http://www.calculator.net/hex-calculator.html?number1=" & hex1 & "&c2op=-&number2=" & hex2 & "&calctype=op&x=39&y"
  725.                 Do While (IE.Busy or IE.ReadyState <> 4) and abs(second(Now())-limit) <= 6:ccSleep(0.25):Loop
  726.                 on error resume next
  727.                 if not ie.document.GetElementsByTagName("p") is nothing then
  728.                     For Each p in ie.document.GetElementsByTagName("p")
  729.                         if p.getAttribute("class") = "verybigtext" and instr(p.innertext,"Hex value:") and not ie.document.GetElementsByTagName("p") is nothing then
  730.                             for each b in p.getElementsByTagName("b")
  731.                                 hexResult = b.innertext
  732.                                 exit for
  733.                             next
  734.                         elseif abs(second(Now())-limit) >=6 then
  735.                             document.getElementByID("ofst_WebMsgArea").innerHtml = "Having trouble retrieving web results...<br>Please try again!"
  736.                             document.getElementByID("ofst").value = ""
  737.                             ie.quit
  738.                             exit function
  739.                         end if
  740.                     Next
  741.                 else
  742.                     document.getElementByID("ofst_WebMsgArea").innerHtml = "Having trouble retrieving web results...<br>Please try again!"
  743.                     document.getElementByID("ofst").value = ""
  744.                     ie.quit
  745.                     exit function
  746.                 end if
  747.                 on error goto 0
  748.             end if 
  749.            
  750.             document.getElementByID("ofst").value = hexResult
  751.        
  752.             ofst_WebMsgArea.style.display = "none"
  753.             call ResizeWindow()
  754.        
  755.     end if
  756.  
  757.     ie.quit
  758.  
  759.     end function
  760.     '==========================================
  761.  
  762.     Sub ccSleep(seconds)
  763.      set oShell = CreateObject("Wscript.Shell")
  764.     cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul"
  765.     oShell.Run cmd,0,1
  766.      End Sub
  767.      
  768.     '==========================================
  769.  
  770.  
  771.     </script>
  772.     <!-- Subs and Functions (End)-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement