Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/25/2022 in all areas

  1. Hmmmmm ... wouldn't even be 256 they'd only need to be a map of 128 that was reflective of whatever the mirror was. Not to mention that would scale up very well. I'm not usually a fan of the database type approach but being so small....ya I like it. Again this is just for fun but that's....wait I have something coming I think. An algorithm maybe looming.. I'll report back.
    2 points
  2. This is for extraction of data from HTML tables to an array. It uses an raw html source file as input, and does not relies on any browser. You can get the source of the html using commands like InetGet(), InetRead(), _INetGetSource(), _IEDocReadHTML() for example, or load an html file from disc as well. It also takes care of the data position in the table due to rowspan and colspan trying to keep the same layout in the generated array. It has the option to fill the cells in the array corresponding with the "span" zones all with the same value of the first "span" cell of the corresponding area. ; save this as _HtmlTable2Array.au3 #include-once #include <array.au3> ; ; #FUNCTION# ==================================================================================================================== ; Name ..........: _HtmlTableGetList ; Description ...: Finds and enumerates all the html tables contained in an html listing (even if nested). ; if the optional parameter $i_index is passed, then only that table is returned ; Syntax ........: _HtmlTableGetList($sHtml[, $i_index = -1]) ; Parameters ....: $sHtml - A string value containing an html page listing ; $i_index - [optional] An integer value indicating the number of the table to be returned (1 based) ; with the default value of -1 an array with all found tables is returned ; Return values .: Success; Returns an 1D 1 based array containing all or single html table found in the html. ; element [0] (and @extended as well) contains the number of tables found (or 0 if no tables are returned) ; if an error occurs then an ampty string is returned and the following @error code is setted ; @error: 1 - no tables are present in the passed HTML ; 2 - error while parsing tables, (opening and closing tags are not balanced) ; 3 - error while parsing tables, (open/close mismatch error) ; 4 - invalid table index request (requested table nr. is out of boundaries) ; =============================================================================================================================== Func _HtmlTableGetList($sHtml, $i_index = -1) Local $aTables = _ParseTags($sHtml, "<table", "</table>") If @error Then Return SetError(@error, 0, "") ElseIf $i_index = -1 Then Return SetError(0, $aTables[0], $aTables) Else If $i_index > 0 And $i_index <= $aTables[0] Then Local $aTemp[2] = [1, $aTables[$i_index]] Return SetError(0, 1, $aTemp) Else Return SetError(4, 0, "") ; bad index EndIf EndIf EndFunc ;==>_HtmlTableGetList ; #FUNCTION# ==================================================================================================================== ; Name ..........: _HtmlTableWriteToArray ; Description ...: It writes values from an html table to a 2D array. It tries to take care of the rowspan and colspan formats ; Syntax ........: _HtmlTableWriteToArray($sHtmlTable[, $bFillSpan = False[, $iFilter = 0]]) ; Parameters ....: $sHtmlTable - A string value containing the html code of the table to be parsed ; $bFillSpan - [optional] Default is False. If span areas have to be filled by repeating the data ; contained in the first cell of the span area ; $iFilter - [optional] Default is 0 (no filters) data extracted from cells is returned unchanged. ; - 0 = no filter ; - 1 = removes non ascii characters ; - 2 = removes all double whitespaces ; - 4 = removes all double linefeeds ; - 8 = removes all html-tags ; - 16 = simple html-tag / entities convertor ; Return values .: Success: 2D array containing data from the html table ; Faillure: An empty strimg and sets @error as following: ; @error: 1 - no table content is present in the passed HTML ; 2 - error while parsing rows and/or columns, (opening and closing tags are not balanced) ; 3 - error while parsing rows and/or columns, (open/close mismatch error) ; =============================================================================================================================== Func _HtmlTableWriteToArray($sHtmlTable, $bFillSpan = False, $iFilter = 0) $sHtmlTable = StringReplace(StringReplace($sHtmlTable, "<th", "<td"), "</th>", "</td>") ; th becomes td ; rows of the wanted table Local $iError, $aTempEmptyRow[2] = [1, ""] Local $aRows = _ParseTags($sHtmlTable, "<tr", "</tr>") ; $aRows[0] = nr. of rows If @error Then Return SetError(@error, 0, "") Local $aCols[$aRows[0] + 1], $aTemp For $i = 1 To $aRows[0] $aTemp = _ParseTags($aRows[$i], "<td", "</td>") $iError = @error If $iError = 1 Then ; check if it's an empty row $aTemp = $aTempEmptyRow ; Empty Row Else If $iError Then Return SetError($iError, 0, "") EndIf If $aCols[0] < $aTemp[0] Then $aCols[0] = $aTemp[0] ; $aTemp[0] = max nr. of columns in table $aCols[$i] = $aTemp Next Local $aResult[$aRows[0]][$aCols[0]], $iStart, $iEnd, $aRowspan, $aColspan, $iSpanY, $iSpanX, $iSpanRow, $iSpanCol, $iMarkerCode, $sCellContent Local $aMirror = $aResult For $i = 1 To $aRows[0] ; scan all rows in this table $aTemp = $aCols[$i] ; <td ..> xx </td> ..... For $ii = 1 To $aTemp[0] ; scan all cells in this row $iSpanY = 0 $iSpanX = 0 $iY = $i - 1 ; zero base index for vertical ref $iX = $ii - 1 ; zero based indexes for horizontal ref ; following RegExp kindly provided by SadBunny in this post: ; http://www.autoitscript.com/forum/topic/167174-how-to-get-a-number-located-after-a-name-from-within-a-string/?p=1222781 $aRowspan = StringRegExp($aTemp[$ii], "(?i)rowspan\s*=\s*[""']?\s*(\d+)", 1) ; check presence of rowspan If IsArray($aRowspan) Then $iSpanY = $aRowspan[0] - 1 If $iSpanY + $iY > $aRows[0] Then $iSpanY -= $iSpanY + $iY - $aRows[0] + 1 EndIf EndIf ; $aColspan = StringRegExp($aTemp[$ii], "(?i)colspan\s*=\s*[""']?\s*(\d+)", 1) ; check presence of colspan If IsArray($aColspan) Then $iSpanX = $aColspan[0] - 1 ; $iMarkerCode += 1 ; code to mark this span area or single cell If $iSpanY Or $iSpanX Then $iX1 = $iX For $iSpY = 0 To $iSpanY For $iSpX = 0 To $iSpanX $iSpanRow = $iY + $iSpY If $iSpanRow > UBound($aMirror, 1) - 1 Then $iSpanRow = UBound($aMirror, 1) - 1 EndIf $iSpanCol = $iX1 + $iSpX If $iSpanCol > UBound($aMirror, 2) - 1 Then ReDim $aResult[$aRows[0]][UBound($aResult, 2) + 1] ReDim $aMirror[$aRows[0]][UBound($aMirror, 2) + 1] EndIf ; While $aMirror[$iSpanRow][$iX1 + $iSpX] ; search first free column $iX1 += 1 ; $iSpanCol += 1 If $iX1 + $iSpX > UBound($aMirror, 2) - 1 Then ReDim $aResult[$aRows[0]][UBound($aResult, 2) + 1] ReDim $aMirror[$aRows[0]][UBound($aMirror, 2) + 1] EndIf WEnd Next Next EndIf ; $iX1 = $iX ; following RegExp kindly provided by mikell in this post: ; http://www.autoitscript.com/forum/topic/167309-how-to-remove-from-a-string-all-between-and-pairs/?p=1224207 $sCellContent = StringRegExpReplace($aTemp[$ii], '<[^>]+>', "") If $iFilter Then $sCellContent = _HTML_Filter($sCellContent, $iFilter) For $iSpX = 0 To $iSpanX For $iSpY = 0 To $iSpanY $iSpanRow = $iY + $iSpY If $iSpanRow > UBound($aMirror, 1) - 1 Then $iSpanRow = UBound($aMirror, 1) - 1 EndIf While $aMirror[$iSpanRow][$iX1 + $iSpX] $iX1 += 1 If $iX1 + $iSpX > UBound($aMirror, 2) - 1 Then ReDim $aResult[$aRows[0]][$iX1 + $iSpX + 1] ReDim $aMirror[$aRows[0]][$iX1 + $iSpX + 1] EndIf WEnd $aMirror[$iSpanRow][$iX1 + $iSpX] = $iMarkerCode ; 1 If $bFillSpan Then $aResult[$iSpanRow][$iX1 + $iSpX] = $sCellContent Next $aResult[$iY][$iX1] = $sCellContent Next Next Next ; _ArrayDisplay($aMirror, "Debug") Return SetError(0, $aResult[0][0], $aResult) EndFunc ;==>_HtmlTableWriteToArray ; ; #FUNCTION# ==================================================================================================================== ; Name ..........: _HtmlTableGetWriteToArray ; Description ...: extract the html code of the required table from the html listing and copy the data of the table to a 2D array ; Syntax ........: _HtmlTableGetWriteToArray($sHtml[, $iWantedTable = 1[, $bFillSpan = False[, $iFilter = 0]]]) ; Parameters ....: $sHtml - A string value containing the html listing ; $iWantedTable - [optional] An integer value. The nr. of the table to be parsed (default is first table) ; $bFillSpan - [optional] Default is False. If all span areas have to be filled by repeating the data ; contained in the first cell of the span area ; $iFilter - [optional] Default is 0 (no filters) data extracted from cells is returned unchanged. ; - 0 = no filter ; - 1 = removes non ascii characters ; - 2 = removes all double whitespaces ; - 4 = removes all double linefeeds ; - 8 = removes all html-tags ; - 16 = simple html-tag / entities convertor ; Return values .: success: 2D array containing data from the wanted html table. ; faillure: An empty string and sets @error as following: ; @error: 1 - no tables are present in the passed HTML ; 2 - error while parsing tables, (opening and closing tags are not balanced) ; 3 - error while parsing tables, (open/close mismatch error) ; 4 - invalid table index request (requested table nr. is out of boundaries) ; =============================================================================================================================== Func _HtmlTableGetWriteToArray($sHtml, $iWantedTable = 1, $bFillSpan = False, $iFilter = 0) Local $aSingleTable = _HtmlTableGetList($sHtml, $iWantedTable) If @error Then Return SetError(@error, 0, "") Local $aTableData = _HtmlTableWriteToArray($aSingleTable[1], $bFillSpan, $iFilter) If @error Then Return SetError(@error, 0, "") Return SetError(0, $aTableData[0][0], $aTableData) EndFunc ;==>_HtmlTableGetWriteToArray ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ParseTags ; Description ...: searches and extract all portions of html code within opening and closing tags inclusive. ; Returns an array containing a collection of <tag ...... </tag> lines. one in each element (even if are nested) ; Syntax ........: _ParseTags($sHtml, $sOpening, $sClosing) ; Parameters ....: $sHtml - A string value containing the html listing ; $sOpening - A string value indicating the opening tag ; $sClosing - A string value indicating the closing tag ; Return values .: success: an 1D 1 based array containing all the portions of html code representing the element ; element [0] af the array (and @extended as well) contains the counter of found elements ; faillure: An empty string and sets @error as following: ; @error: 1 - no tables are present in the passed HTML ; 2 - error while parsing tables, (opening and closing tags are not balanced) ; 3 - error while parsing tables, (open/close mismatch error) ; 4 - invalid table index request (requested table nr. is out of boundaries) ; =============================================================================================================================== Func _ParseTags($sHtml, $sOpening, $sClosing) ; example: $sOpening = '<table', $sClosing = '</table>' ; it finds how many of such tags are on the HTML page StringReplace($sHtml, $sOpening, $sOpening) ; in @xtended nr. of occurences Local $iNrOfThisTag = @extended ; I assume that opening <tag and closing </tag> tags are balanced (as should be) ; (so NO check is made to see if they are actually balanced) If $iNrOfThisTag Then ; if there is at least one of this tag ; $aThisTagsPositions array will contain the positions of the ; starting <tag and ending </tag> tags within the HTML Local $aThisTagsPositions[$iNrOfThisTag * 2 + 1][3] ; 1 based (make room for all open and close tags) ; 2) find in the HTML the positions of the $sOpening <tag and $sClosing </tag> tags For $i = 1 To $iNrOfThisTag $aThisTagsPositions[$i][0] = StringInStr($sHtml, $sOpening, 0, $i) ; start position of $i occurrence of <tag opening tag $aThisTagsPositions[$i][1] = $sOpening ; it marks which kind of tag is this $aThisTagsPositions[$i][2] = $i ; nr of this tag $aThisTagsPositions[$iNrOfThisTag + $i][0] = StringInStr($sHtml, $sClosing, 0, $i) + StringLen($sClosing) - 1 ; end position of $i^ occurrence of </tag> closing tag $aThisTagsPositions[$iNrOfThisTag + $i][1] = $sClosing ; it marks which kind of tag is this Next _ArraySort($aThisTagsPositions, 0, 1) ; now all opening and closing tags are in the same sequence as them appears in the HTML Local $aStack[UBound($aThisTagsPositions)][2] Local $aTags[Ceiling(UBound($aThisTagsPositions) / 2)] ; will contains the collection of <tag ..... </tag> from the html For $i = 1 To UBound($aThisTagsPositions) - 1 If $aThisTagsPositions[$i][1] = $sOpening Then ; opening <tag $aStack[0][0] += 1 ; nr of tags in html $aStack[$aStack[0][0]][0] = $sOpening $aStack[$aStack[0][0]][1] = $i ElseIf $aThisTagsPositions[$i][1] = $sClosing Then ; a closing </tag> was found If Not $aStack[0][0] Or Not ($aStack[$aStack[0][0]][0] = $sOpening And $aThisTagsPositions[$i][1] = $sClosing) Then Return SetError(3, 0, "") ; Open/Close mismatch error Else ; pair detected (the reciprocal tag) ; now get coordinates of the 2 tags ; 1) extract this tag <tag ..... </tag> from the html to the array $aTags[$aThisTagsPositions[$aStack[$aStack[0][0]][1]][2]] = StringMid($sHtml, $aThisTagsPositions[$aStack[$aStack[0][0]][1]][0], 1 + $aThisTagsPositions[$i][0] - $aThisTagsPositions[$aStack[$aStack[0][0]][1]][0]) ; 2) remove that tag <tag ..... </tag> from the html $sHtml = StringLeft($sHtml, $aThisTagsPositions[$aStack[$aStack[0][0]][1]][0] - 1) & StringMid($sHtml, $aThisTagsPositions[$i][0] + 1) ; 3) adjust the references to the new positions of remaining tags For $ii = $i To UBound($aThisTagsPositions) - 1 $aThisTagsPositions[$ii][0] -= StringLen($aTags[$aThisTagsPositions[$aStack[$aStack[0][0]][1]][2]]) Next $aStack[0][0] -= 1 ; nr of tags still in html EndIf EndIf Next If Not $aStack[0][0] Then ; all tags where parsed correctly $aTags[0] = $iNrOfThisTag Return SetError(0, $iNrOfThisTag, $aTags) ; OK Else Return SetError(2, 0, "") ; opening and closing tags are not balanced EndIf Else Return SetError(1, 0, "") ; there are no of such tags on this HTML page EndIf EndFunc ;==>_ParseTags ; #============================================================================= ; Name ..........: _HTML_Filter ; Description ...: Filter for strings ; AutoIt Version : V3.3.0.0 ; Syntax ........: _HTML_Filter(ByRef $sString[, $iMode = 0]) ; Parameter(s): .: $sString - String to filter ; $iMode - Optional: (Default = 0) : removes nothing ; - 0 = no filter ; - 1 = removes non ascii characters ; - 2 = removes all double whitespaces ; - 4 = removes all double linefeeds ; - 8 = removes all html-tags ; - 16 = simple html-tag / entities convertor ; Return Value ..: Success - Filterd String ; Failure - Input String ; Author(s) .....: Thorsten Willert, Stephen Podhajecki {gehossafats at netmdc. com} _ConvertEntities ; Date ..........: Wed Jan 27 20:49:59 CET 2010 ; modified ......: by Chimp Removed a double "&nbsp;" entities declaration, ; replace it with char(160) instead of chr(32), ; declaration of the $aEntities array as Static instead of just Local ; ============================================================================== Func _HTML_Filter(ByRef $sString, $iMode = 0) If $iMode = 0 Then Return $sString ;16 simple HTML tag / entities converter If $iMode >= 16 And $iMode < 32 Then Static Local $aEntities[95][2] = [["&quot;", 34],["&amp;", 38],["&lt;", 60],["&gt;", 62],["&nbsp;", 160] _ ,["&iexcl;", 161],["&cent;", 162],["&pound;", 163],["&curren;", 164],["&yen;", 165],["&brvbar;", 166] _ ,["&sect;", 167],["&uml;", 168],["&copy;", 169],["&ordf;", 170],["&not;", 172],["&shy;", 173] _ ,["&reg;", 174],["&macr;", 175],["&deg;", 176],["&plusmn;", 177],["&sup2;", 178],["&sup3;", 179] _ ,["&acute;", 180],["&micro;", 181],["&para;", 182],["&middot;", 183],["&cedil;", 184],["&sup1;", 185] _ ,["&ordm;", 186],["&raquo;", 187],["&frac14;", 188],["&frac12;", 189],["&frac34;", 190],["&iquest;", 191] _ ,["&Agrave;", 192],["&Aacute;", 193],["&Atilde;", 195],["&Auml;", 196],["&Aring;", 197],["&AElig;", 198] _ ,["&Ccedil;", 199],["&Egrave;", 200],["&Eacute;", 201],["&Ecirc;", 202],["&Igrave;", 204],["&Iacute;", 205] _ ,["&Icirc;", 206],["&Iuml;", 207],["&ETH;", 208],["&Ntilde;", 209],["&Ograve;", 210],["&Oacute;", 211] _ ,["&Ocirc;", 212],["&Otilde;", 213],["&Ouml;", 214],["&times;", 215],["&Oslash;", 216],["&Ugrave;", 217] _ ,["&Uacute;", 218],["&Ucirc;", 219],["&Uuml;", 220],["&Yacute;", 221],["&THORN;", 222],["&szlig;", 223] _ ,["&agrave;", 224],["&aacute;", 225],["&acirc;", 226],["&atilde;", 227],["&auml;", 228],["&aring;", 229] _ ,["&aelig;", 230],["&ccedil;", 231],["&egrave;", 232],["&eacute;", 233],["&ecirc;", 234],["&euml;", 235] _ ,["&igrave;", 236],["&iacute;", 237],["&icirc;", 238],["&iuml;", 239],["&eth;", 240],["&ntilde;", 241] _ ,["&ograve;", 242],["&oacute;", 243],["&ocirc;", 244],["&otilde;", 245],["&ouml;", 246],["&divide;", 247] _ ,["&oslash;", 248],["&ugrave;", 249],["&uacute;", 250],["&ucirc;", 251],["&uuml;", 252],["&thorn;", 254]] $sString = StringRegExpReplace($sString, '(?i)<p.*?>', @CRLF & @CRLF) $sString = StringRegExpReplace($sString, '(?i)<br>', @CRLF) Local $iE = UBound($aEntities) - 1 For $x = 0 To $iE $sString = StringReplace($sString, $aEntities[$x][0], Chr($aEntities[$x][1]), 0, 2) Next For $x = 32 To 255 $sString = StringReplace($sString, "&#" & $x & ";", Chr($x)) Next $iMode -= 16 EndIf ;8 Tag filter If $iMode >= 8 And $iMode < 16 Then ;$sString = StringRegExpReplace($sString, '<script.*?>.*?</script>', "") $sString = StringRegExpReplace($sString, "<[^>]*>", "") $iMode -= 8 EndIf ; 4 remove all double cr, lf If $iMode >= 4 And $iMode < 8 Then $sString = StringRegExpReplace($sString, "([ \t]*[\n\r]+[ \t]*)", @CRLF) $sString = StringRegExpReplace($sString, "[\n\r]+", @CRLF) $iMode -= 4 EndIf ; 2 remove all double withespaces If $iMode = 2 Or $iMode = 3 Then $sString = StringRegExpReplace($sString, "[[:blank:]]+", " ") $sString = StringRegExpReplace($sString, "\n[[:blank:]]+", @CRLF) $sString = StringRegExpReplace($sString, "[[:blank:]]+\n", "") $iMode -= 2 EndIf ; 1 remove all non ASCII (remove all chars with ascii code > 127) If $iMode = 1 Then $sString = StringRegExpReplace($sString, "[^\x00-\x7F]", " ") EndIf Return $sString EndFunc ;==>_HTML_Filter This simple demo allow to test those functions, showing what it can extract from the html tables in a web page of your choice or loading the html file from the disc. ; #include <_HtmlTable2Array.au3> ; <--- udf already included (hard coded) at bottom of this demo #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <File.au3> ; needed for _FileWriteFromArray() #include <array.au3> #include <IE.au3> Local $oIE1 = _IECreateEmbedded(), $oIE2 = _IECreateEmbedded(), $iFilter = 0 Local $sHtml_File, $iIndex, $aTable, $aMyArray, $sFilePath GUICreate("Html tables to array demo", 1000, 450, (@DesktopWidth - 1000) / 2, (@DesktopHeight - 450) / 2 _ , $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE1, 010, 10, 480, 360) ; left browser GUICtrlCreateTab(500, 10, 480, 360) GUICtrlCreateTabItem("view table") GUICtrlCreateObj($oIE2, 502, 33, 474, 335) ; right browser GUICtrlCreateTabItem("view html") Local $idLabel_HtmlTable = GUICtrlCreateInput("", 502, 33, 474, 335, $ES_MULTILINE + $ES_AUTOVSCROLL) GUICtrlSetFont(-1, 10, 0, 0, "Courier new") GUICtrlCreateTabItem("") Local $idInputUrl = GUICtrlCreateInput("", 10, 380, 440, 20) Local $idButton_Go = GUICtrlCreateButton("Go", 455, 380, 25, 20) Local $idButton_Load = GUICtrlCreateButton("Load html from disk", 10, 410, 480, 30) Local $idButton_Prev = GUICtrlCreateButton("Prev <-", 510, 375, 50, 30) Local $idLabel_NunTable = GUICtrlCreateLabel("00 / 00", 570, 375, 40, 30) GUICtrlSetFont(-1, 9, 700) Local $idButton_Next = GUICtrlCreateButton("Next ->", 620, 375, 50, 30) GUICtrlCreateGroup("Fill Span", 680, 370, 80, 40) Local $iFillSpan = GUICtrlCreateCheckbox("", 715, 388, 15, 15) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group Local $idButton_Array0 = GUICtrlCreateButton("Preview array", 770, 375, 100, 30) Local $idButton_Array1 = GUICtrlCreateButton("Write array to file", 880, 375, 100, 30) ; options for filtering GUICtrlCreateGroup("Filters", 510, 410, 470, 35) Local $iFilter01 = GUICtrlCreateCheckbox("non ascii", 520, 425, 85, 15) Local $iFilter02 = GUICtrlCreateCheckbox("double spaces", 610, 425, 85, 15) Local $iFilter04 = GUICtrlCreateCheckbox("double @LF", 700, 425, 85, 15) Local $iFilter08 = GUICtrlCreateCheckbox("html-tags", 790, 425, 85, 15) Local $iFilter16 = GUICtrlCreateCheckbox("tags to entities", 880, 425, 85, 15) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUISetState(@SW_SHOW) ;Show GUI ; _IEDocWriteHTML($oIE2, "<HTML></HTML>") GUICtrlSetData($idInputUrl, "http://www.danshort.com/HTMLentities/") ; GUICtrlSetData($idInputUrl, "http://www.mojotoad.com/sisk/projects/HTML-TableExtract/tables.html") ; example page ControlClick("", "", $idButton_Go) ; _IEAction($oIE1, "stop") Do; Waiting for user to close the window $iMsg = GUIGetMsg() Select Case $iMsg = $idButton_Go _IENavigate($oIE1, GUICtrlRead($idInputUrl)) ; _IEAction($oIE1, "stop") $aTables = _HtmlTableGetList(_IEBodyReadHTML($oIE1)) If Not @error Then ; _ArrayDisplay($aTables, "Tables contained in this html") $iIndex = 1 _IEBodyWriteHTML($oIE2, "<html>" & $aTables[$iIndex] & "</html>") ControlClick("", "", $idButton_Prev) _IEAction($oIE2, "stop") Else MsgBox(0, 0, "@error " & @error) EndIf Case $iMsg = $idButton_Load ConsoleWrite("$idButton_Load" & @CRLF) $sHtml_File = FileOpenDialog("Choose an html file", @ScriptDir & "\", "html page (*.htm;*.html)") If Not @error Then GUICtrlSetData($idInputUrl, $sHtml_File) ControlClick("", "", $idButton_Go) EndIf Case $iMsg = $idButton_Next If IsArray($aTables) Then $iIndex += $iIndex < $aTables[0] GUICtrlSetData($idLabel_NunTable, "Table" & @CRLF & $iIndex & " / " & $aTables[0]) GUICtrlSetData($idLabel_HtmlTable, $aTables[$iIndex]) _IEBodyWriteHTML($oIE2, "<html>" & $aTables[$iIndex] & "</html>") _IEAction($oIE2, "stop") EndIf Case $iMsg = $idButton_Prev If IsArray($aTables) Then $iIndex -= $iIndex > 1 GUICtrlSetData($idLabel_NunTable, "Table" & @CRLF & $iIndex & " / " & $aTables[0]) GUICtrlSetData($idLabel_HtmlTable, $aTables[$iIndex]) _IEBodyWriteHTML($oIE2, "<html>" & $aTables[$iIndex] & "</html>") _IEAction($oIE2, "stop") EndIf Case $iMsg = $idButton_Array0 ; Preview Array If IsArray($aTables) Then $iFilter = 1 * _IsChecked($iFilter01) + 2 * _IsChecked($iFilter02) + 4 * _IsChecked($iFilter04) + 8 * _IsChecked($iFilter08) + 16 * _IsChecked($iFilter16) $aMyArray = _HtmlTableWriteToArray($aTables[$iIndex], _IsChecked($iFillSpan), $iFilter) If Not @error Then _ArrayDisplay($aMyArray) EndIf Case $iMsg = $idButton_Array1 ; Saves the array in a csv file of your choice If IsArray($aTables) Then $iFilter = 1 * _IsChecked($iFilter01) + 2 * _IsChecked($iFilter02) + 4 * _IsChecked($iFilter04) + 8 * _IsChecked($iFilter08) + 16 * _IsChecked($iFilter16) $aMyArray = _HtmlTableWriteToArray($aTables[$iIndex], _IsChecked($iFillSpan), $iFilter) If Not @error Then $sFilePath = FileSaveDialog("Choose a file to save to", @ScriptDir, "(*.csv)") If $sFilePath <> "" Then If Not _FileWriteFromArray($sFilePath, $aMyArray, 0, Default, ",") Then MsgBox(0, "Error on file write", "Error code is " & @error & @CRLF & @CRLF & "@error meaning:" & @CRLF & _ "1 - Error opening specified file" & @CRLF & _ "2 - $aArray is not an array" & @CRLF & _ "3 - Error writing to file" & @CRLF & _ "4 - $aArray is not a 1D or 2D array" & @CRLF & _ "5 - Start index is greater than the $iUbound parameter") EndIf EndIf EndIf EndIf EndSelect Until $iMsg = $GUI_EVENT_CLOSE GUIDelete() ; returns 1 if CheckBox is checked Func _IsChecked($idControlID) ; $GUI_CHECKED = 1 Return GUICtrlRead($idControlID) = $GUI_CHECKED EndFunc ;==>_IsChecked ; ------------------------------------------------------------------------ ; Following code should be included by the #include <_HtmlTable2Array.au3> ; hard coded here for easy load an run to try the example ; ------------------------------------------------------------------------ #include-once #include <array.au3> ; ; #FUNCTION# ==================================================================================================================== ; Name ..........: _HtmlTableGetList ; Description ...: Finds and enumerates all the html tables contained in an html listing (even if nested). ; if the optional parameter $i_index is passed, then only that table is returned ; Syntax ........: _HtmlTableGetList($sHtml[, $i_index = -1]) ; Parameters ....: $sHtml - A string value containing an html page listing ; $i_index - [optional] An integer value indicating the number of the table to be returned (1 based) ; with the default value of -1 an array with all found tables is returned ; Return values .: Success; Returns an 1D 1 based array containing all or single html table found in the html. ; element [0] (and @extended as well) contains the number of tables found (or 0 if no tables are returned) ; if an error occurs then an ampty string is returned and the following @error code is setted ; @error: 1 - no tables are present in the passed HTML ; 2 - error while parsing tables, (opening and closing tags are not balanced) ; 3 - error while parsing tables, (open/close mismatch error) ; 4 - invalid table index request (requested table nr. is out of boundaries) ; =============================================================================================================================== Func _HtmlTableGetList($sHtml, $i_index = -1) Local $aTables = _ParseTags($sHtml, "<table", "</table>") If @error Then Return SetError(@error, 0, "") ElseIf $i_index = -1 Then Return SetError(0, $aTables[0], $aTables) Else If $i_index > 0 And $i_index <= $aTables[0] Then Local $aTemp[2] = [1, $aTables[$i_index]] Return SetError(0, 1, $aTemp) Else Return SetError(4, 0, "") ; bad index EndIf EndIf EndFunc ;==>_HtmlTableGetList ; #FUNCTION# ==================================================================================================================== ; Name ..........: _HtmlTableWriteToArray ; Description ...: It writes values from an html table to a 2D array. It tries to take care of the rowspan and colspan formats ; Syntax ........: _HtmlTableWriteToArray($sHtmlTable[, $bFillSpan = False[, $iFilter = 0]]) ; Parameters ....: $sHtmlTable - A string value containing the html code of the table to be parsed ; $bFillSpan - [optional] Default is False. If span areas have to be filled by repeating the data ; contained in the first cell of the span area ; $iFilter - [optional] Default is 0 (no filters) data extracted from cells is returned unchanged. ; - 0 = no filter ; - 1 = removes non ascii characters ; - 2 = removes all double whitespaces ; - 4 = removes all double linefeeds ; - 8 = removes all html-tags ; - 16 = simple html-tag / entities convertor ; Return values .: Success: 2D array containing data from the html table ; Faillure: An empty strimg and sets @error as following: ; @error: 1 - no table content is present in the passed HTML ; 2 - error while parsing rows and/or columns, (opening and closing tags are not balanced) ; 3 - error while parsing rows and/or columns, (open/close mismatch error) ; =============================================================================================================================== Func _HtmlTableWriteToArray($sHtmlTable, $bFillSpan = False, $iFilter = 0) $sHtmlTable = StringReplace(StringReplace($sHtmlTable, "<th", "<td"), "</th>", "</td>") ; th becomes td ; rows of the wanted table Local $iError, $aTempEmptyRow[2] = [1, ""] Local $aRows = _ParseTags($sHtmlTable, "<tr", "</tr>") ; $aRows[0] = nr. of rows If @error Then Return SetError(@error, 0, "") Local $aCols[$aRows[0] + 1], $aTemp For $i = 1 To $aRows[0] $aTemp = _ParseTags($aRows[$i], "<td", "</td>") $iError = @error If $iError = 1 Then ; check if it's an empty row $aTemp = $aTempEmptyRow ; Empty Row Else If $iError Then Return SetError($iError, 0, "") EndIf If $aCols[0] < $aTemp[0] Then $aCols[0] = $aTemp[0] ; $aTemp[0] = max nr. of columns in table $aCols[$i] = $aTemp Next Local $aResult[$aRows[0]][$aCols[0]], $iStart, $iEnd, $aRowspan, $aColspan, $iSpanY, $iSpanX, $iSpanRow, $iSpanCol, $iMarkerCode, $sCellContent Local $aMirror = $aResult For $i = 1 To $aRows[0] ; scan all rows in this table $aTemp = $aCols[$i] ; <td ..> xx </td> ..... For $ii = 1 To $aTemp[0] ; scan all cells in this row $iSpanY = 0 $iSpanX = 0 $iY = $i - 1 ; zero base index for vertical ref $iX = $ii - 1 ; zero based indexes for horizontal ref ; following RegExp kindly provided by SadBunny in this post: ; http://www.autoitscript.com/forum/topic/167174-how-to-get-a-number-located-after-a-name-from-within-a-string/?p=1222781 $aRowspan = StringRegExp($aTemp[$ii], "(?i)rowspan\s*=\s*[""']?\s*(\d+)", 1) ; check presence of rowspan If IsArray($aRowspan) Then $iSpanY = $aRowspan[0] - 1 If $iSpanY + $iY > $aRows[0] Then $iSpanY -= $iSpanY + $iY - $aRows[0] + 1 EndIf EndIf ; $aColspan = StringRegExp($aTemp[$ii], "(?i)colspan\s*=\s*[""']?\s*(\d+)", 1) ; check presence of colspan If IsArray($aColspan) Then $iSpanX = $aColspan[0] - 1 ; $iMarkerCode += 1 ; code to mark this span area or single cell If $iSpanY Or $iSpanX Then $iX1 = $iX For $iSpY = 0 To $iSpanY For $iSpX = 0 To $iSpanX $iSpanRow = $iY + $iSpY If $iSpanRow > UBound($aMirror, 1) - 1 Then $iSpanRow = UBound($aMirror, 1) - 1 EndIf $iSpanCol = $iX1 + $iSpX If $iSpanCol > UBound($aMirror, 2) - 1 Then ReDim $aResult[$aRows[0]][UBound($aResult, 2) + 1] ReDim $aMirror[$aRows[0]][UBound($aMirror, 2) + 1] EndIf ; While $aMirror[$iSpanRow][$iX1 + $iSpX] ; search first free column $iX1 += 1 ; $iSpanCol += 1 If $iX1 + $iSpX > UBound($aMirror, 2) - 1 Then ReDim $aResult[$aRows[0]][UBound($aResult, 2) + 1] ReDim $aMirror[$aRows[0]][UBound($aMirror, 2) + 1] EndIf WEnd Next Next EndIf ; $iX1 = $iX ; following RegExp kindly provided by mikell in this post: ; http://www.autoitscript.com/forum/topic/167309-how-to-remove-from-a-string-all-between-and-pairs/?p=1224207 $sCellContent = StringRegExpReplace($aTemp[$ii], '<[^>]+>', "") If $iFilter Then $sCellContent = _HTML_Filter($sCellContent, $iFilter) For $iSpX = 0 To $iSpanX For $iSpY = 0 To $iSpanY $iSpanRow = $iY + $iSpY If $iSpanRow > UBound($aMirror, 1) - 1 Then $iSpanRow = UBound($aMirror, 1) - 1 EndIf While $aMirror[$iSpanRow][$iX1 + $iSpX] $iX1 += 1 If $iX1 + $iSpX > UBound($aMirror, 2) - 1 Then ReDim $aResult[$aRows[0]][$iX1 + $iSpX + 1] ReDim $aMirror[$aRows[0]][$iX1 + $iSpX + 1] EndIf WEnd $aMirror[$iSpanRow][$iX1 + $iSpX] = $iMarkerCode ; 1 If $bFillSpan Then $aResult[$iSpanRow][$iX1 + $iSpX] = $sCellContent Next $aResult[$iY][$iX1] = $sCellContent Next Next Next ; _ArrayDisplay($aMirror, "Debug") Return SetError(0, $aResult[0][0], $aResult) EndFunc ;==>_HtmlTableWriteToArray ; ; #FUNCTION# ==================================================================================================================== ; Name ..........: _HtmlTableGetWriteToArray ; Description ...: extract the html code of the required table from the html listing and copy the data of the table to a 2D array ; Syntax ........: _HtmlTableGetWriteToArray($sHtml[, $iWantedTable = 1[, $bFillSpan = False[, $iFilter = 0]]]) ; Parameters ....: $sHtml - A string value containing the html listing ; $iWantedTable - [optional] An integer value. The nr. of the table to be parsed (default is first table) ; $bFillSpan - [optional] Default is False. If all span areas have to be filled by repeating the data ; contained in the first cell of the span area ; $iFilter - [optional] Default is 0 (no filters) data extracted from cells is returned unchanged. ; - 0 = no filter ; - 1 = removes non ascii characters ; - 2 = removes all double whitespaces ; - 4 = removes all double linefeeds ; - 8 = removes all html-tags ; - 16 = simple html-tag / entities convertor ; Return values .: success: 2D array containing data from the wanted html table. ; faillure: An empty string and sets @error as following: ; @error: 1 - no tables are present in the passed HTML ; 2 - error while parsing tables, (opening and closing tags are not balanced) ; 3 - error while parsing tables, (open/close mismatch error) ; 4 - invalid table index request (requested table nr. is out of boundaries) ; =============================================================================================================================== Func _HtmlTableGetWriteToArray($sHtml, $iWantedTable = 1, $bFillSpan = False, $iFilter = 0) Local $aSingleTable = _HtmlTableGetList($sHtml, $iWantedTable) If @error Then Return SetError(@error, 0, "") Local $aTableData = _HtmlTableWriteToArray($aSingleTable[1], $bFillSpan, $iFilter) If @error Then Return SetError(@error, 0, "") Return SetError(0, $aTableData[0][0], $aTableData) EndFunc ;==>_HtmlTableGetWriteToArray ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ParseTags ; Description ...: searches and extract all portions of html code within opening and closing tags inclusive. ; Returns an array containing a collection of <tag ...... </tag> lines. one in each element (even if are nested) ; Syntax ........: _ParseTags($sHtml, $sOpening, $sClosing) ; Parameters ....: $sHtml - A string value containing the html listing ; $sOpening - A string value indicating the opening tag ; $sClosing - A string value indicating the closing tag ; Return values .: success: an 1D 1 based array containing all the portions of html code representing the element ; element [0] af the array (and @extended as well) contains the counter of found elements ; faillure: An empty string and sets @error as following: ; @error: 1 - no tables are present in the passed HTML ; 2 - error while parsing tables, (opening and closing tags are not balanced) ; 3 - error while parsing tables, (open/close mismatch error) ; 4 - invalid table index request (requested table nr. is out of boundaries) ; =============================================================================================================================== Func _ParseTags($sHtml, $sOpening, $sClosing) ; example: $sOpening = '<table', $sClosing = '</table>' ; it finds how many of such tags are on the HTML page StringReplace($sHtml, $sOpening, $sOpening) ; in @xtended nr. of occurences Local $iNrOfThisTag = @extended ; I assume that opening <tag and closing </tag> tags are balanced (as should be) ; (so NO check is made to see if they are actually balanced) If $iNrOfThisTag Then ; if there is at least one of this tag ; $aThisTagsPositions array will contain the positions of the ; starting <tag and ending </tag> tags within the HTML Local $aThisTagsPositions[$iNrOfThisTag * 2 + 1][3] ; 1 based (make room for all open and close tags) ; 2) find in the HTML the positions of the $sOpening <tag and $sClosing </tag> tags For $i = 1 To $iNrOfThisTag $aThisTagsPositions[$i][0] = StringInStr($sHtml, $sOpening, 0, $i) ; start position of $i occurrence of <tag opening tag $aThisTagsPositions[$i][1] = $sOpening ; it marks which kind of tag is this $aThisTagsPositions[$i][2] = $i ; nr of this tag $aThisTagsPositions[$iNrOfThisTag + $i][0] = StringInStr($sHtml, $sClosing, 0, $i) + StringLen($sClosing) - 1 ; end position of $i^ occurrence of </tag> closing tag $aThisTagsPositions[$iNrOfThisTag + $i][1] = $sClosing ; it marks which kind of tag is this Next _ArraySort($aThisTagsPositions, 0, 1) ; now all opening and closing tags are in the same sequence as them appears in the HTML Local $aStack[UBound($aThisTagsPositions)][2] Local $aTags[Ceiling(UBound($aThisTagsPositions) / 2)] ; will contains the collection of <tag ..... </tag> from the html For $i = 1 To UBound($aThisTagsPositions) - 1 If $aThisTagsPositions[$i][1] = $sOpening Then ; opening <tag $aStack[0][0] += 1 ; nr of tags in html $aStack[$aStack[0][0]][0] = $sOpening $aStack[$aStack[0][0]][1] = $i ElseIf $aThisTagsPositions[$i][1] = $sClosing Then ; a closing </tag> was found If Not $aStack[0][0] Or Not ($aStack[$aStack[0][0]][0] = $sOpening And $aThisTagsPositions[$i][1] = $sClosing) Then Return SetError(3, 0, "") ; Open/Close mismatch error Else ; pair detected (the reciprocal tag) ; now get coordinates of the 2 tags ; 1) extract this tag <tag ..... </tag> from the html to the array $aTags[$aThisTagsPositions[$aStack[$aStack[0][0]][1]][2]] = StringMid($sHtml, $aThisTagsPositions[$aStack[$aStack[0][0]][1]][0], 1 + $aThisTagsPositions[$i][0] - $aThisTagsPositions[$aStack[$aStack[0][0]][1]][0]) ; 2) remove that tag <tag ..... </tag> from the html $sHtml = StringLeft($sHtml, $aThisTagsPositions[$aStack[$aStack[0][0]][1]][0] - 1) & StringMid($sHtml, $aThisTagsPositions[$i][0] + 1) ; 3) adjust the references to the new positions of remaining tags For $ii = $i To UBound($aThisTagsPositions) - 1 $aThisTagsPositions[$ii][0] -= StringLen($aTags[$aThisTagsPositions[$aStack[$aStack[0][0]][1]][2]]) Next $aStack[0][0] -= 1 ; nr of tags still in html EndIf EndIf Next If Not $aStack[0][0] Then ; all tags where parsed correctly $aTags[0] = $iNrOfThisTag Return SetError(0, $iNrOfThisTag, $aTags) ; OK Else Return SetError(2, 0, "") ; opening and closing tags are not balanced EndIf Else Return SetError(1, 0, "") ; there are no of such tags on this HTML page EndIf EndFunc ;==>_ParseTags ; #============================================================================= ; Name ..........: _HTML_Filter ; Description ...: Filter for strings ; AutoIt Version : V3.3.0.0 ; Syntax ........: _HTML_Filter(ByRef $sString[, $iMode = 0]) ; Parameter(s): .: $sString - String to filter ; $iMode - Optional: (Default = 0) : removes nothing ; - 0 = no filter ; - 1 = removes non ascii characters ; - 2 = removes all double whitespaces ; - 4 = removes all double linefeeds ; - 8 = removes all html-tags ; - 16 = simple html-tag / entities convertor ; Return Value ..: Success - Filterd String ; Failure - Input String ; Author(s) .....: Thorsten Willert, Stephen Podhajecki {gehossafats at netmdc. com} _ConvertEntities ; Date ..........: Wed Jan 27 20:49:59 CET 2010 ; modified ......: by Chimp Removed a double "&nbsp;" entities declaration, ; replace it with char(160) instead of chr(32), ; declaration of the $aEntities array as Static instead of just Local ; ============================================================================== Func _HTML_Filter(ByRef $sString, $iMode = 0) If $iMode = 0 Then Return $sString ;16 simple HTML tag / entities converter If $iMode >= 16 And $iMode < 32 Then Static Local $aEntities[95][2] = [["&quot;", 34],["&amp;", 38],["&lt;", 60],["&gt;", 62],["&nbsp;", 160] _ ,["&iexcl;", 161],["&cent;", 162],["&pound;", 163],["&curren;", 164],["&yen;", 165],["&brvbar;", 166] _ ,["&sect;", 167],["&uml;", 168],["&copy;", 169],["&ordf;", 170],["&not;", 172],["&shy;", 173] _ ,["&reg;", 174],["&macr;", 175],["&deg;", 176],["&plusmn;", 177],["&sup2;", 178],["&sup3;", 179] _ ,["&acute;", 180],["&micro;", 181],["&para;", 182],["&middot;", 183],["&cedil;", 184],["&sup1;", 185] _ ,["&ordm;", 186],["&raquo;", 187],["&frac14;", 188],["&frac12;", 189],["&frac34;", 190],["&iquest;", 191] _ ,["&Agrave;", 192],["&Aacute;", 193],["&Atilde;", 195],["&Auml;", 196],["&Aring;", 197],["&AElig;", 198] _ ,["&Ccedil;", 199],["&Egrave;", 200],["&Eacute;", 201],["&Ecirc;", 202],["&Igrave;", 204],["&Iacute;", 205] _ ,["&Icirc;", 206],["&Iuml;", 207],["&ETH;", 208],["&Ntilde;", 209],["&Ograve;", 210],["&Oacute;", 211] _ ,["&Ocirc;", 212],["&Otilde;", 213],["&Ouml;", 214],["&times;", 215],["&Oslash;", 216],["&Ugrave;", 217] _ ,["&Uacute;", 218],["&Ucirc;", 219],["&Uuml;", 220],["&Yacute;", 221],["&THORN;", 222],["&szlig;", 223] _ ,["&agrave;", 224],["&aacute;", 225],["&acirc;", 226],["&atilde;", 227],["&auml;", 228],["&aring;", 229] _ ,["&aelig;", 230],["&ccedil;", 231],["&egrave;", 232],["&eacute;", 233],["&ecirc;", 234],["&euml;", 235] _ ,["&igrave;", 236],["&iacute;", 237],["&icirc;", 238],["&iuml;", 239],["&eth;", 240],["&ntilde;", 241] _ ,["&ograve;", 242],["&oacute;", 243],["&ocirc;", 244],["&otilde;", 245],["&ouml;", 246],["&divide;", 247] _ ,["&oslash;", 248],["&ugrave;", 249],["&uacute;", 250],["&ucirc;", 251],["&uuml;", 252],["&thorn;", 254]] $sString = StringRegExpReplace($sString, '(?i)<p.*?>', @CRLF & @CRLF) $sString = StringRegExpReplace($sString, '(?i)<br>', @CRLF) Local $iE = UBound($aEntities) - 1 For $x = 0 To $iE $sString = StringReplace($sString, $aEntities[$x][0], Chr($aEntities[$x][1]), 0, 2) Next For $x = 32 To 255 $sString = StringReplace($sString, "&#" & $x & ";", Chr($x)) Next $iMode -= 16 EndIf ;8 Tag filter If $iMode >= 8 And $iMode < 16 Then ;$sString = StringRegExpReplace($sString, '<script.*?>.*?</script>', "") $sString = StringRegExpReplace($sString, "<[^>]*>", "") $iMode -= 8 EndIf ; 4 remove all double cr, lf If $iMode >= 4 And $iMode < 8 Then $sString = StringRegExpReplace($sString, "([ \t]*[\n\r]+[ \t]*)", @CRLF) $sString = StringRegExpReplace($sString, "[\n\r]+", @CRLF) $iMode -= 4 EndIf ; 2 remove all double withespaces If $iMode = 2 Or $iMode = 3 Then $sString = StringRegExpReplace($sString, "[[:blank:]]+", " ") $sString = StringRegExpReplace($sString, "\n[[:blank:]]+", @CRLF) $sString = StringRegExpReplace($sString, "[[:blank:]]+\n", "") $iMode -= 2 EndIf ; 1 remove all non ASCII (remove all chars with ascii code > 127) If $iMode = 1 Then $sString = StringRegExpReplace($sString, "[^\x00-\x7F]", " ") EndIf Return $sString EndFunc ;==>_HTML_Filter Any error reports or suggestions for enhancements are welcome
    1 point
  3. The F1 key in SciTE displays the documentation for the word on which the cursor is located. Up to now this was only available for AutoIt. But times change and we change with them With the "Simple Library Docs Generator" created by MrCreatoR and customized by me, any CHM help file (Compressed HTML Help) can be created (more about this later in a separate thread). The only prerequisite: All function names have to start with the same identifier (like _AD_, _OL_ etc.). We have already created CHM help files for the following UDFs: Active Directory AD-CHM.zip Outlook OutlookEX-CHM.zip TaskScheduler TaskScheduler-CHM.zip WebDriver Webdriver-CHM.zip Preliminary release of the WebDriver help file. This release is for you to play with. Please tell us what you like, what is missing or just what you think about it. For download please see the top of this post. Other CHM help files come with existing UDFs: WinHTTP The integration of these help files in SciTE is now done with the tool presented here. Advanced.Help This tool, created by BugFix from the german forum, allows custom CHM help files to be included in SciTE. The existing help key is used to call either the AutoIt help or the corresponding custom help. Depending on which keyword the cursor is currently on. For unknown keywords the AutoIt help is called. For AutoIt a separate window is opened and for the user-defined UDFs another window is opened, so you can work with both helps at the same time. The ZIP file contains an installation guide in German (Install_Deutsch.txt) and English (Install_English.txt) in which the installation and configuration is described in detail. For download please check the download forum.
    1 point
  4. I've been playing around with this for a lil bit. Not necessary mulling over the actual solving of the problem but the reversing of a series of bits... like its got my ocd kicking in. I know that it has to be possible algorithmically using some combination of bitwise operations, that doesn't involve a loop.... loops are BAD!! BAD LOOP NO. I just can't wrap my brain around it. Anyways its just for fun. The point of this is to check to see if a series of bits are a palindrome. so if you only had 8 bits it would need to look like 0001 1000 etc. An earlier version I had them all being checked individually but i was trying to come up with something a little cleaner... If you got any ideas hit me up. Its not that big of a deal bc its just some random thing someone of fb was asking for help with. Like shouldn't I be able to make the computer just read it backwards? like wtf. change the encoding or something. void reversebyte(byte* p) { byte b = 0;; for (int i = 0; i < 8; i++) { if(*p & (1 << i)){ b |= 1 << 7 - i; } } *p = b; } int main() { int a = 1; byte b[4]{}; while (a < 100000000) { *(int*)&b = a; reversebyte(&b[0]); reversebyte(&b[1]); if (b[0] == b[3] && b[1] == b[2]) { cout << "good result : a = " << a << "\n"; } a++; } } on the topic of reversing a series of bit. I can get it to work sometimes because of my bits are 0101 bitwise ~ is a good reverse which would be 1010 something like 1101 ~ is 0010 so no good.
    1 point
  5. Werty

    Pretty cool lil nerd out

    How about using a look-up table with all the 256 different bytes in an array representet as bits, would probably be faster also, as you wouldnt need to calculate anything.
    1 point
  6. Something for you to play with: ; #FUNCTION# ==================================================================================================================== ; Name...........: _OLT_EML_Get ; Description ...: Returns the content of an EML file as a serialized stream within a single ADO Stream object. ; Syntax.........: _OLT_EML_Get($sEMLPath[, $sProperty = Default]) ; Parameters ....: $sEMLPath - Path to an EML mail file e.g. "C:\Local\Test.EML" ; $sPropery - [optional] Property to return. See Remarks (default = keyword Default) ; Return values .: Success - Sets global variable $__g_oIMessage to the ADO stream object and [optional] returns the specified property ; Failure - Returns 0 and sets @error: ; |1 - Could not create the IMessage object. @extended is set to the COM error code ; |2 - Could not create the ADO stream object. @extended is set to the COM error code ; |3 - Error accessing property $sProperty. Maybe the specified property does not exist? ; Author ........: maniootek, mLipok (in alph. order) ; Modified ......: water ; Remarks .......: The function always sets the global variable $__g_oIMessage to the ADO stream object. ; So you can access all properties after the function has been called. ; This is true even when you call the function using $sProperty to return the value of a single property. ; A list of available properties can be found here: ; iMessage: https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2007/aa579703(v=exchg.80) ;+ ; Further information: ; ADO: https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/stream-object-ado?view=sql-server-ver15 ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _OLT_EML_Get($sEMLPath, $sProperty = Default) Local Const $sCLASSID_IMessage = "{CD000001-8B95-11D1-82DB-00C04FB1625D}" ; CLSID of the IMessage interface Local $oADOStream If Not IsDeclared("__g_oIMessage") Then Global Static $__g_oIMessage = ObjCreate($sCLASSID_IMessage) If @error Then Return SetError(1, @error, 0) EndIf $oADOStream = $__g_oIMessage.GetStream() ; Return the message in serialized (wire-transport) format in a ADO stream object If @error Then Return SetError(2, @error, 0) $oADOStream.LoadFromFile($sEMLPath) If @error Then Return SetError(3, @error, 0) $oADOStream.Flush() If $sProperty <> Default Then $sResult = Execute("$__g_oIMessage." & $sProperty) If @error Then Return SetError(3, @error, 0) Return $sResult EndIf EndFunc ;==>_OLT_EML_Get Example: #include <OutlookTools.au3> _OL_ErrorNotify(2) Global $sTextBody = _OLT_EML_Get("C:\Local\Test.EML", "TextBody") ConsoleWrite("@Error: " & @error & ", @Extended: " & @extended & @CRLF) ; Function _OLT_EML_Get returns property TextBody (1) or you directly retrieve the TextBody from the ADO stream (2) ConsoleWrite(StringLeft($sTextBody, 80) & @CRLF) ; Example (1) ConsoleWrite(StringLeft($__g_oIMessage.TextBody, 80) & @CRLF) ; Example (2)
    1 point
  7. @Palkiao you can move drag window:(G Key + Left Mouse): #include <Misc.au3> $dll = dllopen("user32.dll") if _IsPressed("47",$dll)And _IsPressed("01",$dll)Then _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) or using ALT+SPACE(Move): #include <Misc.au3> Global $window = WinWaitActive("Untitled - Notepad"),$dll = DllOpen("user32.dll") SendKeepActive($window) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") Global $TB,$RL,$PRL,$PTB,$state = "on" While 1 if WinActive("Untitled - Notepad") Then if $state = "on" Then $PRL = MouseGetPos(0); Sleep(500) $PTB = MouseGetPos(1); $state = "off" EndIf $RL = MouseGetPos(0); $TB = MouseGetPos(1); if _IsPressed("47",$dll)And _IsPressed("01",$dll) Then ; if [47] G key + [01] Left mouse button is pressed $state = "on" if $RL > $PRL Then Send("{RIGHT}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") Elseif $RL < $PRL Then Send("{LEFT}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") EndIf if $TB > $PTB Then Send("{DOWN}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") Elseif $TB < $PTB Then Send("{UP}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") EndIf EndIf EndIf WEnd or you can simply move window: #include <Misc.au3> local $dll = dllopen("user32.dll") if _IsPressed("47",$dll)And _IsPressed("01",$dll) Then ; if [47] G key + [01] Left mouse button is pressed WinMove($window,"",mousegetpos(0)-400,MouseGetPos(1)) EndIf or using (if your drag window like notepad it will Send ESC else if you G+LeftMouse) #include <Misc.au3> Global $state = "on" $dll = DllOpen("user32.dll") While 1 if _IsPressed("01",$dll) And WinActive("Untitled - Notepad") Then if $state = "off" Then Else Send("{ESC}") EndIf EndIf if _IsPressed("47",$dll) And _IsPressed("01",$dll) And WinActive("Untitled - Notepad") Then $state = "off" Else $state = "on" EndIf WEnd or by using Mouse Drag using (border): #include <FrameConstants.au3> #include <WinAPISysWin.au3> #include <WinAPIGdiDC.au3> #include <SendMessage.au3> #include <BorderConstants.au3> #include <Misc.au3> #include <WinAPIGdiDC.au3> ToolTip("waitting for window....") WinWaitActive("Untitled - Notepad") HotKeySet("{ESC}", "On_Exit") Global Const $tagRECT2 = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct") Global $dll = DllOpen("user32.dlL"), $state = "on" $Width = WinGetPos("Untitled - Notepad", "")[2] $Height = WinGetPos("Untitled - Notepad", "")[3] While 1 ToolTip("") If _KeyPeleased("01") = 1 Then WinMove("Untitled - Notepad", "", DllStructGetData($tagRECT2, "Left"), DllStructGetData($tagRECT2, "Top")) EndIf If $state = "on" Then ;ToolTip("") $hGUI = GUICreate("", @DesktopWidth + 10, @DesktopHeight + 10, -1, -1, 0x80000000) GUISetState() WinSetTrans($hGUI, "", 100) ;Make window invisible. $state = "off" EndIf If _IsPressed("01", $dll) Then _WinAPI_InvalidateRect($hGUI, 0, True) DllStructSetData($tagRECT2, "Left", MouseGetPos(0)) DllStructSetData($tagRECT2, "Top", MouseGetPos(1)) DllStructSetData($tagRECT2, "Right", MouseGetPos(0) + $Width) DllStructSetData($tagRECT2, "Bottom", MouseGetPos(1) + $Height) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_SOFT) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_TOP) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_BOTTOMRIGHT) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_BOTTOMLEFT) EndIf WEnd Func On_Exit() Exit EndFunc ;==>On_Exit Func _KeyPeleased($key) Global $stat If _IsPressed($key, $dll) Then $stat = 1 Sleep(5) EndIf If Not _IsPressed($key, $dll) Then If $stat = 1 Then $stat = 0 Return 1 ; Sleep(10) EndIf EndIf EndFunc ;==>_KeyPeleased
    1 point
  8. Today I found an interesting demo page: https://stqatools.com/demo/index.php It can be handy for developing examples, practice, and solving problems.
    1 point
  9. 747Skipper

    How to download a UDF

    Thank you both very much for your super quick replies. Subz: Yes I see that now, it was the fact it was from someone else not Ward that threw me. I did follow that google link and after the obligatory wrestle with GitHub, I managed to download. Danp2: Yes now I have found the latest version I see it includes Binarycall and have the demo working. Now I can get started on doing what I want to achieve! Thanks again both of you, you cannot believe the frustration when you go round and round in circles being sent back to the same page and not finding what you know must be there.
    1 point
  10. Danp2

    How to download a UDF

    FYI, BinaryCall UDF is included in the JSON zip file.
    1 point
  11. SelectorsHub give a relative xpath of "//ytd-mini-guide-entry-renderer[@aria-label='Subscriptions']//a[@id='endpoint']", so I would try using that to see if it works.
    1 point
  12. I like the premise of this extension and I believe it could be quite useful. I'd like to see a method to more easily add user snippets from within VSCode, similar to how https://snippet-generator.app/ works. If you could accomplish this, I believe that it would be high adopted. I'm not a fan of having to type !au3, however, I found that the included snippets can be accessed using a keyboard shortcut for "editor.action.showSnippets". Maybe you could add user friendly way to set this shortcut. Keep up the solid work!
    1 point
  13. I was tasked with creating a utility that would parse an Excel document and then update an existing MySQL table. I'm much more comfortable using object oriented programming and I didn't want to creating a bunch of update queries. After quite a lot of trial, error, and research, I finally found a working solution. Thanks to @jchd for the post above that pointed me in the right direction. Also, thank you to @mLipok for a great UDF. Note: This is snipped code and for concept purposes only. #include "ADO.au3" Global $sDriver = "" Global $sServer = "" Global $sDatabase = "" Global $sPort = "" Global $sUser = "" Global $sPassword = "" Global $sQuery = "SELECT * FROM table" Global $sNewValue = "Some Value" Global $sConnectionString = _ADO_ConnectionString_MySQL($sUser, $sPassword, $sDatabase, $sDriver, $sServer, $sPort) Global $oConnection = _ADO_Connection_Create() _ADO_Connection_OpenConString($oConnection, $sConnectionString) ; https://docs.microsoft.com/en-us/office/vba/access/concepts/miscellaneous/execute-method-ado-connection#remarks Global $oRecordset = _ADO_Recordset_Create() With $oRecordset .CursorLocation = $ADO_adUseClient .Properties("Update Criteria").Value = $ADO_adCriteriaKey .Open($sQuery, $oConnection, $ADO_adOpenDynamic, $ADO_adLockPessimistic) .MoveFirst() EndWith While Not $oRecordset.EOF() ; The update will fail if you attempt to update with equal values If StringCompare($oRecordset.Fields("Column").Value, $sNewValue) <> 0 Then _ $oRecordset.Fields("Column").Value = $sNewValue $oRecordset.MoveNext() WEnd $oRecordset.UpdateBatch()
    1 point
  14. Take a look on this my old script: ;~ https://www.autoitscript.com/forum/topic/174414-determining-size-of-attachment-from-eml-files-multiple-attachmentshashedcoded/ ;~ https://msdn.microsoft.com/en-us/library/ms526130(v=exchg.10).aspx ;~ https://msdn.microsoft.com/en-us/library/ms526453(v=exchg.10).aspx ;~ Interfaces ;~ https://msdn.microsoft.com/en-us/library/ms877953(v=exchg.65).aspx #include "array.au3" Global Const $sCLASSID_IMessage = "{CD000001-8B95-11D1-82DB-00C04FB1625D}" _Example() Func _Example($vParam = Default) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local Static $oMessage = Null If $vParam = Default Then _EML_MessageCreateObj($oMessage) _EML_LoadEml($oMessage, 'EMAIL2.eml') MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, 'Time1', _EML_Message_TimeSent($oMessage)) $oRecipients_col = $oMessage.Recipients For $oRecipient_enum In $oRecipients_col ConsoleWrite($oRecipient_enum.Name & @CRLF) ConsoleWrite($oRecipient_enum.Adress & @CRLF) Next Else MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, 'Time2', _EML_Message_TimeSent($oMessage)) EndIf EndFunc ;==>_Example _Example_1() Func _Example_1() Local $sEMLPath = "EMAIL.eml" $sAttachment = "IDAutomationHC39M.ttf" $iSize = GetAttachmentSize($sEMLPath, $sAttachment) Local $aAttachments = GetAttachmentList($sEMLPath) _ArrayDisplay($aAttachments) If @error Then $sErrDesc = "You can't use this method because " Switch @error Case 1 $sErrDesc &= "CDO sucks for you." Case 2 $sErrDesc &= "getting stream failed." Case 3 $sErrDesc &= "loading EML failed." Case 4 $sErrDesc &= "of some dumb error." Case 5 $sErrDesc = "No such attachment exists." EndSwitch MsgBox(4096, "Error", $sErrDesc & @CRLF) Else MsgBox(4096, "...", 'Attachment named "' & $sAttachment & '" is ' & $iSize & " bytes big" & @CRLF) EndIf EndFunc ;==>_Example_1 Func GetAttachmentSize($sEMLPath, $sAttachmentName) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oMessage = ObjCreate($sCLASSID_IMessage) ; with all the downsides ;~ https://msdn.microsoft.com/en-us/library/ms526453(v=exchg.10).aspx If @error Then Return SetError(1, 0, -1) ;~ ObjName_FlagsValue($oMessage) ;~ MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, '', 11) _EML_LoadEml($oMessage, $sEMLPath) If @error Then Return SetError(3, 0, -1) MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, '$oMessage.TimeSent', $oMessage.TimeSent) Local $iSize ;~ https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2007/aa579703(v=exchg.80) For $oAttachment In $oMessage.Attachments If $oAttachment.FileName = $sAttachmentName Then $iSize = $oAttachment.GetDecodedContentStream().Size EndIf If @error Then Return SetError(4, 0, -1) If $iSize Then Return $iSize Next Return SetError(5, 0, -1) EndFunc ;==>GetAttachmentSize Func SaveAttachment($sEMLPath, $sAttachmentName) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oMessage = ObjCreate($sCLASSID_IMessage) ; with all the downsides If @error Then Return SetError(1, 0, -1) Local $oMessageStream = $oMessage.GetStream() If @error Then Return SetError(2, 0, -1) $oMessageStream.LoadFromFile($sEMLPath) If @error Then Return SetError(3, 0, -1) $oMessageStream.Flush() ; this is essential Local $iSize For $oAttachment In $oMessage.Attachments If $oAttachment.FileName = $sAttachmentName Then $oAttachment.SaveToFile(@ScriptDir & "\" & $sAttachmentName) If @error Then Return SetError(4, 0, -1) Else Return SetError(0, 0, 1) EndIf Next Return SetError(5, 0, -1) EndFunc ;==>SaveAttachment Func GetAttachmentList($sEMLPath) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oMessage = ObjCreate($sCLASSID_IMessage) ; with all the downsides If @error Then Return SetError(1, 0, -1) Local $oMessageStream = $oMessage.GetStream() If @error Then Return SetError(2, 0, -1) ; LoadFromFile Method (ADO) ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms677570(v=vs.85).aspx $oMessageStream.LoadFromFile($sEMLPath) If @error Then Return SetError(3, 0, -1) $oMessageStream.Flush() ; this is essential Local $sAttachments = '' For $oAttachment In $oMessage.Attachments $sAttachments &= $oAttachment.FileName & '|' Next If $sAttachments <> '' Then StringTrimRight($sAttachments, 1) Local $aAttachments = StringSplit($sAttachments, '|') Return SetError(0, 0, $aAttachments) Else Return SetError(4, 0, -1) EndIf Return SetError(5, 0, -1) EndFunc ;==>GetAttachmentList Func _EML_Message_TimeSent(ByRef $oMessage) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ;~ TimeSent Property (Message Object) ;~ https://msdn.microsoft.com/en-us/library/ms528105(v=exchg.10).aspx ;~ ObjName_FlagsValue($oMessage) Return $oMessage.TimeSent ;~ Return $oMessage.TimeLastModified ;~ Return $oMessage.Type ;~ Return $oMessage.TimeReceived ;~ Return $oMessage.GetStream EndFunc ;==>_EML_Message_TimeSent Func _EML_MessageCreateObj(ByRef $oMessage) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ; IMessage Interface ; https://msdn.microsoft.com/en-us/library/ms526453(v=exchg.10).aspx $oMessage = ObjCreate($sCLASSID_IMessage) ; with all the downsides If @error Then Return SetError(1, @error, -1) Return SetError(0, 0, 1) EndFunc ;==>_EML_MessageCreateObj Func _EML_LoadEml(ByRef $oMessage, $sEMLPath) Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oMessageStream = $oMessage.GetStream() If @error Then Return SetError(2, 0, -1) ; LoadFromFile Method (ADO) ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms677570(v=vs.85).aspx $oMessageStream.LoadFromFile($sEMLPath) If @error Then Return SetError(3, 0, -1) $oMessageStream.Flush() ; this is essential ;~ MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, '1a', $oMessage.TimeRecevied) ;~ MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, '1b', $oMessage.Importance) EndFunc ;==>_EML_LoadEml #Region - DOC #cs IMessage Interface - http://msdn.microsoft.com/en-us/library/ms526453(v=vs.85).aspx CreateMHTMLBody Method - http://msdn.microsoft.com/en-us/library/ms527024(v=vs.85).aspx CdoMHTMLFlags Enum - http://msdn.microsoft.com/en-us/library/ms526977(v=vs.85).aspx GetStream Method - http://msdn.microsoft.com/en-us/library/ms527348(v=vs.85).aspx SaveToFile Method - http://msdn.microsoft.com/en-us/library/ms676152(v=vs.85).aspx SaveOptionsEnum - http://msdn.microsoft.com/en-us/library/ms676152(v=vs.85).aspx #ce #EndRegion - DOC ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Func ObjName_FlagsValue(ByRef $oObj) Local $sInfo = '' $sInfo &= '+>' & @TAB & 'ObjName($oObj,1) {The name of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_NAME) & @CRLF ; HELPFILE REMARKS: Not all Objects support flags 2 to 7. Always test for @error in these cases. $sInfo &= '+>' & @TAB & 'ObjName($oObj,2) {Description string of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_STRING) If @error Then $sInfo &= '@error = ' & @error $sInfo &= @CRLF & @CRLF $sInfo &= '+>' & @TAB & 'ObjName($oObj,3) {The ProgID of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_PROGID) If @error Then $sInfo &= '@error = ' & @error $sInfo &= @CRLF & @CRLF $sInfo &= '+>' & @TAB & 'ObjName($oObj,4) {The file that is associated with the object in the Registry} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_FILE) If @error Then $sInfo &= '@error = ' & @error $sInfo &= @CRLF & @CRLF $sInfo &= '+>' & @TAB & 'ObjName($oObj,5) {Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects.} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_MODULE) If @error Then $sInfo &= '@error = ' & @error $sInfo &= @CRLF & @CRLF $sInfo &= '+>' & @TAB & 'ObjName($oObj,6) {CLSID of the object''s coclass} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_CLSID) If @error Then $sInfo &= '@error = ' & @error $sInfo &= @CRLF & @CRLF $sInfo &= '+>' & @TAB & 'ObjName($oObj,7) {IID of the object''s interface} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_IID) If @error Then $sInfo &= '@error = ' & @error $sInfo &= @CRLF & @CRLF MsgBox($MB_SYSTEMMODAL, "ObjName:", $sInfo) EndFunc ;==>ObjName_FlagsValue and: IMessage Interface - https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2007/aa579703(v=exchg.80) IMessage Interface - http://msdn.microsoft.com/en-us/library/ms526453(v=vs.85).aspx https://docs.microsoft.com/en-us/previous-versions/exchange-server/exchange-10/ms527537(v=exchg.10)
    1 point
  15. Focus on UIAUtomatin in faq 31 mentioned above. Only way to manipulate WPF apps
    1 point
  16. AFAIK, you can't. You would need to use UIAutomation with InvokePattern.
    1 point
  17. Hi MakzNovice, here is a working example of pure mouse and window drag and drop usage which works also for Firefox. I don't like it and would stick with WebDriver, but this could help 😅 . I guess you have to improve and adjust this example to fit your needs, but it works. By the way @Danp2, thanks for the hint about Marionette. I wasn't aware of this by now - interesting 👍 . Best regards Sven ________________ Stay innovative!
    1 point
  18. WIN+w --> reserved by Windows for Whiteboard WIN+q --> reserved by Windows for Query WIN+s --> reserved by Windows for Search convince yourself with this script: _HotKey("{ESC}") _HotKey("#w") ; is reserved by Windows --> Whiteboard _HotKey("#q") ; is reserved by Windows --> Query _HotKey("#s") ; is reserved by Windows --> Search Func _HotKey($hotkey = "") ; ! ALT + SHIFT ^ CONTROL # WinKey Switch @HotKeyPressed Case "{ESC}" Exit 0*MsgBox(0, Default, "Exit", 3) Case "#w" Beep() ; will never beep Case "#q" Beep() ; will never beep Case "#s" Beep() ; will never beep Case Else If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed,15) If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.",15) EndSwitch EndFunc ;==>_HotKey While Sleep(100) MsgBox(262144, Default, "Press ESC to Exit." & @CRLF & @CRLF & "or WIN+w / WIN+q / WIN+s to verify the WIN Keys." ,3) WEnd
    1 point
×
×
  • Create New...