Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/26/2015 in all areas

  1. If I'm not mistaken, the ENTIRE script, including all the ip-addresses, are covered by the following 5 lines: $ipregex = "10\.20\.(1|24)\.[\d]{1,3}|10\.20\.32\.103" If StringRegExp(@IPAddress1, $ipregex) Then MsgBox(0, 0, "Ip address 1 matches") If StringRegExp(@IPAddress2, $ipregex) Then MsgBox(0, 0, "Ip address 2 matches") If StringRegExp(@IPAddress3, $ipregex) Then MsgBox(0, 0, "Ip address 3 matches") If StringRegExp(@IPAddress4, $ipregex) Then MsgBox(0, 0, "Ip address 4 matches") Top that
    2 points
  2. nobbe

    EBCDIC to ASCII

    hi there may be a more elegant solution to this, but i convert the chars that i need, others i dont really need ; ; $Recv = _Ebcdic_2_ascii($Recv) ; ; --- convert ebcdic into ASCII Func _Ebcdic_2_ascii($in_buffer) Local $r_text = '' ; other $r_text = StringReplace($in_buffer, "@", Chr(32)); blank $r_text = StringReplace($r_text, ",", " "); . $r_text = StringReplace($r_text, "}", " "); $r_text = StringReplace($r_text, "O", " "); ! $r_text = StringReplace($r_text, "Q", "e"); ! $r_text = StringReplace($r_text, "`", "-"); $r_text = StringReplace($r_text, "z", ":"); $r_text = StringReplace($r_text, "N", "+"); $r_text = StringReplace($r_text, "\", "*"); $r_text = StringReplace($r_text, "k", ","); $r_text = StringReplace($r_text, "_", "("); $r_text = StringReplace($r_text, "]", ")"); $r_text = StringReplace($r_text, "^", ";"); $r_text = StringReplace($r_text, "P", "&"); $r_text = StringReplace($r_text, "a", "/"); $r_text = StringReplace($r_text, "j", "ö"); $r_text = StringReplace($r_text, ",", " "); its a "." $r_text = StringReplace($r_text, "À", "ä"); its a "." ;$r_text = StringReplace($r_text, CHR(74) , " " ); "¢"); ;$r_text = StringReplace($r_text, CHR(91) , " " ) ; "$"); ;$r_text = StringReplace($r_text, CHR(97) , " " ); "/"); ;$r_text = StringReplace($r_text, CHR(108) , " " );"%"); $r_text = StringReplace($r_text, Chr(109), "("); $r_text = StringReplace($r_text, Chr(123), "#"); $r_text = StringReplace($r_text, Chr(124), "@"); $r_text = StringReplace($r_text, Chr(129), "a"); $r_text = StringReplace($r_text, Chr(130), "b"); $r_text = StringReplace($r_text, Chr(131), "c"); $r_text = StringReplace($r_text, Chr(132), "d"); $r_text = StringReplace($r_text, Chr(133), "e"); $r_text = StringReplace($r_text, Chr(134), "f"); $r_text = StringReplace($r_text, Chr(135), "g"); $r_text = StringReplace($r_text, Chr(136), "h"); $r_text = StringReplace($r_text, Chr(137), "i"); $r_text = StringReplace($r_text, Chr(145), "j"); $r_text = StringReplace($r_text, Chr(146), "k"); $r_text = StringReplace($r_text, Chr(147), "l"); $r_text = StringReplace($r_text, Chr(148), "m"); $r_text = StringReplace($r_text, Chr(149), "n"); $r_text = StringReplace($r_text, Chr(150), "o"); $r_text = StringReplace($r_text, Chr(151), "p"); $r_text = StringReplace($r_text, Chr(152), "q"); $r_text = StringReplace($r_text, Chr(153), "r"); $r_text = StringReplace($r_text, Chr(162), "s"); $r_text = StringReplace($r_text, Chr(163), "t"); $r_text = StringReplace($r_text, Chr(164), "u"); $r_text = StringReplace($r_text, Chr(165), "v"); $r_text = StringReplace($r_text, Chr(166), "w"); $r_text = StringReplace($r_text, Chr(167), "x"); $r_text = StringReplace($r_text, Chr(168), "y"); $r_text = StringReplace($r_text, Chr(169), "z"); $r_text = StringReplace($r_text, Chr(193), "A"); $r_text = StringReplace($r_text, Chr(194), "B"); $r_text = StringReplace($r_text, Chr(195), "C"); $r_text = StringReplace($r_text, Chr(196), "D"); $r_text = StringReplace($r_text, Chr(197), "E"); $r_text = StringReplace($r_text, Chr(198), "F"); $r_text = StringReplace($r_text, Chr(199), "G"); $r_text = StringReplace($r_text, Chr(200), "H"); $r_text = StringReplace($r_text, Chr(201), "I"); $r_text = StringReplace($r_text, Chr(209), "J"); $r_text = StringReplace($r_text, Chr(210), "K"); $r_text = StringReplace($r_text, Chr(211), "L"); $r_text = StringReplace($r_text, Chr(212), "M"); $r_text = StringReplace($r_text, Chr(213), "N"); $r_text = StringReplace($r_text, Chr(214), "O"); $r_text = StringReplace($r_text, Chr(215), "P"); $r_text = StringReplace($r_text, Chr(216), "Q"); $r_text = StringReplace($r_text, Chr(217), "R"); $r_text = StringReplace($r_text, Chr(226), "S"); $r_text = StringReplace($r_text, Chr(227), "T"); $r_text = StringReplace($r_text, Chr(228), "U"); $r_text = StringReplace($r_text, Chr(229), "V"); $r_text = StringReplace($r_text, Chr(230), "W"); $r_text = StringReplace($r_text, Chr(231), "X"); $r_text = StringReplace($r_text, Chr(232), "Y"); $r_text = StringReplace($r_text, Chr(233), "Z"); $r_text = StringReplace($r_text, Chr(240), "0"); $r_text = StringReplace($r_text, Chr(241), "1"); $r_text = StringReplace($r_text, Chr(242), "2"); $r_text = StringReplace($r_text, Chr(243), "3"); $r_text = StringReplace($r_text, Chr(244), "4"); $r_text = StringReplace($r_text, Chr(245), "5"); $r_text = StringReplace($r_text, Chr(246), "6"); $r_text = StringReplace($r_text, Chr(247), "7"); $r_text = StringReplace($r_text, Chr(248), "8"); $r_text = StringReplace($r_text, Chr(249), "9"); Return $r_text EndFunc ;==>_Ebcdic_2_ascii
    2 points
  3. Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip
    1 point
  4. trancexx

    MailSlot

    This way of communication between processes very much resemble to the communication we do with our mail accounts. I would guess (smartly, no doubt) that was the key factor used for naming the functions when they were created. Information about mailslots can be found on microsoft's site, link. Summary could be that datagrams are used for communication and it's one-way and asynchronous. Attached zip file contains MailSlot.au3, AutoIt's implementation of these functions. Also there would be two scripts in there MailSlot_Sender.au3 and MailSlot_Reciever.au3. Both scripts are demos of the mailslot mechanism. Start both and use former to send mails to latter. Examples are basic and should show what's this about. MailSlot.zip Available functions are alphabetically: _MailSlotCheckForNextMessage_MailSlotClose_MailSlotCreate_MailSlotGetMessageCount_MailSlotGetTimeout_MailSlotSetTimeout_MailSlotRead_MailSlotWriteedit: New attachment. _MailSlotGetTimeout() function added to MailSlot.au3.
    1 point
  5. 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
  6. Hi all, Sometimes we need to know instantly what our array contains. For this, i have made a little function to print your array in console. You may use this function in MsgBox too. Here is the code. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: kcvinu Script Function: Sometimes we need to see what an array or a list contains. And this script will help you to see the all elements without a loop Example : If you have an array like this = Local $MyArray[4] = ['Red','Green','Blue','Yellow'] You need to use the fuction like this = PrintList($MyArray) Result : It will print your Array in Console like this [Red,Green,Blue,Yellow] Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Func PrintList($List) If IsArray($List) Then Local $txt = "" For $i = 0 to UBound($List) -1 $txt = $txt & "," & $List[$i] Next Local $out = StringMid($txt,2) Global $Result = "[" & $out & "]" ConsoleWrite($Result) Return $Result Else MsgBox(0, "List Error", "Variable is not an array or a list") EndIf EndFunc ;==>PrintList PrintList.au3
    1 point
  7. Some time ago I ask How to Read/Display file content - non txt file ?. here is my new version: Example() Func Example() Local $hTimer = 0 Local $sText = '' $hTimer = TimerInit() $sText = _GetTextFromTextStream(@ScriptDir & "\TEST123_Polish.skk") MsgBox(0, '# of lines = ' & @extended & ' in ' & Round(TimerDiff($hTimer) / 1000, 3) & ' sec.', $sText) $hTimer = TimerInit() $sText = _GetTextFromTextStream(@ScriptDir & "\TEST123_Polish.skk", False) MsgBox(0, '# of lines = ' & @extended & ' in ' & Round(TimerDiff($hTimer) / 1000, 3) & ' sec.', $sText) ; the text should be like this #cs Polish Diacritic mark: ąćęłńóśżź English: acelnoszz #ce EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetTextFromTextStream ; Description ...: Get text from binary file. ; Syntax ........: _GetTextFromTextStream($sFileFullPath[, $bGetAsLine = True]) ; Parameters ....: $sFileFullPath - a string value. ; $bGetAsLine - [optional] a boolean value. Default is True. ; Return values .: Text or set @error to non zero ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _GetTextFromTextStream($sFileFullPath, $bGetAsLine = True) Local Const $iForReading = 1, $iForWriting = 2, $iForAppending = 3 Local Const $iTristateUseDefault = -2, $iTristateTrue = -1, $iTristateFalse = 0 Local $oFSO = ObjCreate("Scripting.FileSystemObject") If @error Then Return SetError(1, 0, '') Local $oFile = $oFSO.GetFile($sFileFullPath) If @error Then Return SetError(2, 0, '') Local $oTS = $oFile.OpenAsTextStream($iForReading, $iTristateUseDefault) If @error Then Return SetError(3, 0, '') Local $sText = '' Local $sTemp = '' Do If $bGetAsLine Then $sText &= $oTS.ReadLine Else $sText &= $oTS.Read(1) EndIf Until $oTS.AtEndOfStream Local $iLineCounter = $oTS.Line $oTS.Close $oFile = '' $oFSO = '' Return SetExtended($iLineCounter, $sText) EndFunc ;==>_GetTextFromTextStream _GetTextFromTextStream.ZIP
    1 point
  8. kylomas

    Listview in Tab

    Damn it, M23... #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $hGUI, $hListview, $aHit[2] = [-1, -1] $hGUI = GUICreate("Listview in TAB", 250, 180) GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) Local $idTab = GUICtrlCreateTab(0, 0, 250, 130) GUICtrlCreateTabItem("tab") $iListview = GUICtrlCreateListView("one|two|three", 0, 20, 350, 130, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListview = GUICtrlGetHandle($iListview) GUICtrlCreateListViewItem("0-0|0-1|0-2", $iListview) GUICtrlCreateListViewItem("1-0|1-1|1-2", $iListview) GUICtrlCreateListViewItem("2-0|2-1|2-2", $iListview) GUICtrlCreateTabItem("") $hButton = GUICtrlCreateButton("Click", 0, 155, 250, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Local $idMsg While 2 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch $tNMHDR.hWndFrom Case $hListview Switch $tNMHDR.Code Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, false) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CLICK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $aHit[0] = $tInfo.Index $aHit[1] = $tInfo.SubItem Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    1 point
  9. Melba23

    Listview in Tab

    JohnOne, Hope your luck changes - and look at post #14. M23
    1 point
  10. Melba23

    Listview in Tab

    JohnOne, You need to set the correct coordinates of your ListView in this line: $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 2, $aInfo[1] - 20) ; Upper left = ( 2, 20 ) As you still had the coordinates of the other example it was not giving you the correct return in $aHit. M23
    1 point
  11. mLipok

    Listview in Tab

    Maybe here you can find your hints I'am thinking about makeing an array to check what was clicked , and using this array to change back color in selected cell.
    1 point
  12. kylomas

    Listview in Tab

    Belay the above, the cell selection is jumping all over the place...sorry...
    1 point
  13. UEZ

    Listview in Tab

    Just relax awhile watching a european league match which has just started. I'm watching Sporting Lissabon - Wolfburg... Br, UEZ
    1 point
  14. kylomas

    Listview in Tab

    J1, This works for me... <code deleted> To recolor the items I believe you have to loop back throught the listview, not sure though... Have you seen M23's listview UDF? I think it's called _GuiCtrlListViewEX...
    1 point
  15. mLipok

    Listview in Tab

    do you want to select X ?? Edit: I mean:
    1 point
  16. UEZ

    Listview in Tab

    You have to check your code in the WM_NOTIFY function -> $LVN_ITEMCHANGED and $NM_CUSTOMDRAW. If you disable those check it will work properly but you have no explicitly cell selection. Br, UEZ
    1 point
  17. UEZ

    Listview in Tab

    The problem is that you are not selecting a cell explicitly. Your code will work till you select a cell and not mark a row only -> not tab related! Try this: Switch $iCode Case $NM_CLICK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $aHit[0] = $tInfo.Index $aHit[1] = $tInfo.SubItem Case $LVN_ITEMCHANGED Br, UEZ
    1 point
  18. mLipok

    Listview in Tab

    I'am not sure, but maybe this: ;~ $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 2, $aInfo[1] - 2) ; Upper left = ( 2, 2 ) $aInfo = _GUICtrlListView_SubItemHitTest($hListview, -1, -1) ; Upper left = ( 2, 2 )
    1 point
  19. Are you enlightening us on the benefits of multithreading, or just disparaging the solutions that allow for IPC. This is a retarded statement, about a language that is transparently if not deliberately slow and wasteful. If your mission is speed and efficiency you made the first wrong turn when you selected this language, and then the second was coming here to tell us about the obvious.
    1 point
  20. kcvinu, If you were to open the Help file and search for a useful function name, perhaps FileListToArray might seem a good place to start reading. Or you could just post and get us to do all the research for you. M23
    1 point
  21. maniootek, A minimalist version: #include <MsgBoxConstants.au3> _Test() MsgBox($MB_SYSTEMMODAL, "Test", "Continuing") Func _Test() SetError(1) ; Force error If @error And _Warning("Error with test") Then Exit EndFunc ;==>_Test Func _Warning($sText) If MsgBox($MB_ICONWARNING + $MB_YESNO, "Warning!", $sText & @CRLF & "Continue?") = 6 Then Return Else Exit EndIf EndFunc ;==>_Warning This works because AutoIt will not run the _Warning function at all if @error is not set - a nice "feature"! M23
    1 point
  22. Rex

    ISN AutoIt Studio [old thread]

    @arts yea thats a false positive. /Rex
    1 point
  23. In your script, after the If statement, it moved on to the next few lines which declare the log name, path, and contents, and then run _FileWriteLog (that is why it would build even if there were no matches). Then you attempt to declare the built in _FileWriteLog as your own function and that's just wrong. Global $IPRANGE[509] $IPRANGE[1] = "10.20.1.1" $IPRANGE[2] = "10.10.1.2" $IPRANGE[3] = "10.20.1.3" $IPRANGE[4] = "10.20.1.4" $IPRANGE[5] = "10.20.1.5" $IPRANGE[6] = "10.20.1.6" $IPRANGE[7] = "10.20.1.7" $IPRANGE[8] = "10.20.1.8" $IPRANGE[9] = "10.20.1.9" $IPRANGE[10] = "10.20.1.10" $IPRANGE[11] = "10.20.1.11" $IPRANGE[12] = "10.20.1.12" $IPRANGE[13] = "10.20.1.13" $IPRANGE[14] = "10.20.1.14" $IPRANGE[15] = "10.20.1.15" $IPRANGE[16] = "10.20.1.16" $IPRANGE[17] = "10.20.1.17" $IPRANGE[18] = "10.20.1.18" $IPRANGE[19] = "10.20.1.19" $IPRANGE[20] = "10.20.1.20" $IPRANGE[21] = "10.20.1.21" $IPRANGE[22] = "10.20.1.22" $IPRANGE[23] = "10.20.1.23" $IPRANGE[24] = "10.20.1.24" $IPRANGE[25] = "10.20.1.25" $IPRANGE[26] = "10.20.1.26" $IPRANGE[27] = "10.20.1.27" $IPRANGE[28] = "10.20.1.28" $IPRANGE[29] = "10.20.1.29" $IPRANGE[30] = "10.20.1.30" $IPRANGE[31] = "10.20.1.31" $IPRANGE[32] = "10.20.1.32" $IPRANGE[33] = "10.20.1.33" $IPRANGE[34] = "10.20.1.34" $IPRANGE[35] = "10.20.1.35" $IPRANGE[36] = "10.20.1.36" $IPRANGE[37] = "10.20.1.37" $IPRANGE[38] = "10.20.1.38" $IPRANGE[39] = "10.20.1.39" $IPRANGE[40] = "10.20.1.40" $IPRANGE[41] = "10.20.1.41" $IPRANGE[42] = "10.20.1.42" $IPRANGE[43] = "10.20.1.43" $IPRANGE[44] = "10.20.1.44" $IPRANGE[45] = "10.20.1.45" $IPRANGE[46] = "10.20.1.46" $IPRANGE[47] = "10.20.1.47" $IPRANGE[48] = "10.20.1.48" $IPRANGE[49] = "10.20.1.49" $IPRANGE[50] = "10.20.1.50" $IPRANGE[51] = "10.20.1.51" $IPRANGE[52] = "10.20.1.52" $IPRANGE[53] = "10.20.1.53" $IPRANGE[54] = "10.20.1.54" $IPRANGE[55] = "10.20.1.55" $IPRANGE[56] = "10.20.1.56" $IPRANGE[57] = "10.20.1.57" $IPRANGE[58] = "10.20.1.58" $IPRANGE[59] = "10.20.1.59" $IPRANGE[60] = "10.20.1.60" $IPRANGE[61] = "10.20.1.61" $IPRANGE[62] = "10.20.1.62" $IPRANGE[63] = "10.20.1.63" $IPRANGE[64] = "10.20.1.64" $IPRANGE[65] = "10.20.1.65" $IPRANGE[66] = "10.20.1.66" $IPRANGE[67] = "10.20.1.67" $IPRANGE[68] = "10.20.1.68" $IPRANGE[69] = "10.20.1.69" $IPRANGE[70] = "10.20.1.70" $IPRANGE[71] = "10.20.1.71" $IPRANGE[72] = "10.20.1.72" $IPRANGE[73] = "10.20.1.73" $IPRANGE[74] = "10.20.1.74" $IPRANGE[75] = "10.20.1.75" $IPRANGE[76] = "10.20.1.76" $IPRANGE[77] = "10.20.1.77" $IPRANGE[78] = "10.20.1.78" $IPRANGE[79] = "10.20.1.79" $IPRANGE[80] = "10.20.1.80" $IPRANGE[81] = "10.20.1.81" $IPRANGE[82] = "10.20.1.82" $IPRANGE[83] = "10.20.1.83" $IPRANGE[84] = "10.20.1.84" $IPRANGE[85] = "10.20.1.85" $IPRANGE[86] = "10.20.1.86" $IPRANGE[87] = "10.20.1.87" $IPRANGE[88] = "10.20.1.88" $IPRANGE[89] = "10.20.1.89" $IPRANGE[90] = "10.20.1.90" $IPRANGE[91] = "10.20.1.91" $IPRANGE[92] = "10.20.1.92" $IPRANGE[93] = "10.20.1.93" $IPRANGE[94] = "10.20.1.94" $IPRANGE[95] = "10.20.1.95" $IPRANGE[96] = "10.20.1.96" $IPRANGE[97] = "10.20.1.97" $IPRANGE[98] = "10.20.1.98" $IPRANGE[99] = "10.20.1.99" $IPRANGE[100] = "10.20.1.100" $IPRANGE[101] = "10.20.1.101" $IPRANGE[102] = "10.20.1.102" $IPRANGE[103] = "10.20.1.103" $IPRANGE[104] = "10.20.1.104" $IPRANGE[105] = "10.20.1.105" $IPRANGE[106] = "10.20.1.106" $IPRANGE[107] = "10.20.1.107" $IPRANGE[108] = "10.20.1.108" $IPRANGE[109] = "10.20.1.109" $IPRANGE[110] = "10.20.1.110" $IPRANGE[111] = "10.20.1.111" $IPRANGE[112] = "10.20.1.112" $IPRANGE[113] = "10.20.1.113" $IPRANGE[114] = "10.20.1.114" $IPRANGE[115] = "10.20.1.115" $IPRANGE[116] = "10.20.1.116" $IPRANGE[117] = "10.20.1.117" $IPRANGE[118] = "10.20.1.118" $IPRANGE[119] = "10.20.1.119" $IPRANGE[120] = "10.20.1.120" $IPRANGE[121] = "10.20.1.121" $IPRANGE[122] = "10.20.1.122" $IPRANGE[123] = "10.20.1.123" $IPRANGE[124] = "10.20.1.124" $IPRANGE[125] = "10.20.1.125" $IPRANGE[126] = "10.20.1.126" $IPRANGE[127] = "10.20.1.127" $IPRANGE[128] = "10.20.1.128" $IPRANGE[129] = "10.20.1.129" $IPRANGE[130] = "10.20.1.130" $IPRANGE[131] = "10.20.1.131" $IPRANGE[132] = "10.20.1.132" $IPRANGE[133] = "10.20.1.133" $IPRANGE[134] = "10.20.1.134" $IPRANGE[135] = "10.20.1.135" $IPRANGE[136] = "10.20.1.136" $IPRANGE[137] = "10.20.1.137" $IPRANGE[138] = "10.20.1.138" $IPRANGE[139] = "10.20.1.139" $IPRANGE[140] = "10.20.1.140" $IPRANGE[141] = "10.20.1.141" $IPRANGE[142] = "10.20.1.142" $IPRANGE[143] = "10.20.1.143" $IPRANGE[144] = "10.20.1.144" $IPRANGE[145] = "10.20.1.145" $IPRANGE[146] = "10.20.1.146" $IPRANGE[147] = "10.20.1.147" $IPRANGE[148] = "10.20.1.148" $IPRANGE[149] = "10.20.1.149" $IPRANGE[150] = "10.20.1.150" $IPRANGE[151] = "10.20.1.151" $IPRANGE[152] = "10.20.1.152" $IPRANGE[153] = "10.20.1.153" $IPRANGE[154] = "10.20.1.154" $IPRANGE[155] = "10.20.1.155" $IPRANGE[156] = "10.20.1.156" $IPRANGE[157] = "10.20.1.157" $IPRANGE[158] = "10.20.1.158" $IPRANGE[159] = "10.20.1.159" $IPRANGE[160] = "10.20.1.160" $IPRANGE[161] = "10.20.1.161" $IPRANGE[162] = "10.20.1.162" $IPRANGE[163] = "10.20.1.163" $IPRANGE[164] = "10.20.1.164" $IPRANGE[165] = "10.20.1.165" $IPRANGE[166] = "10.20.1.166" $IPRANGE[167] = "10.20.1.167" $IPRANGE[168] = "10.20.1.168" $IPRANGE[169] = "10.20.1.169" $IPRANGE[170] = "10.20.1.170" $IPRANGE[171] = "10.20.1.171" $IPRANGE[172] = "10.20.1.172" $IPRANGE[173] = "10.20.1.173" $IPRANGE[174] = "10.20.1.174" $IPRANGE[175] = "10.20.1.175" $IPRANGE[176] = "10.20.1.176" $IPRANGE[177] = "10.20.1.177" $IPRANGE[178] = "10.20.1.178" $IPRANGE[179] = "10.20.1.179" $IPRANGE[180] = "10.20.1.180" $IPRANGE[181] = "10.20.1.181" $IPRANGE[182] = "10.20.1.182" $IPRANGE[183] = "10.20.1.183" $IPRANGE[184] = "10.20.1.184" $IPRANGE[185] = "10.20.1.185" $IPRANGE[186] = "10.20.1.186" $IPRANGE[187] = "10.20.1.187" $IPRANGE[188] = "10.20.1.188" $IPRANGE[189] = "10.20.1.189" $IPRANGE[190] = "10.20.1.190" $IPRANGE[191] = "10.20.1.191" $IPRANGE[192] = "10.20.1.192" $IPRANGE[193] = "10.20.1.193" $IPRANGE[194] = "10.20.1.194" $IPRANGE[195] = "10.20.1.195" $IPRANGE[196] = "10.20.1.196" $IPRANGE[197] = "10.20.1.197" $IPRANGE[198] = "10.20.1.198" $IPRANGE[199] = "10.20.1.199" $IPRANGE[200] = "10.20.1.200" $IPRANGE[201] = "10.20.1.201" $IPRANGE[202] = "10.20.1.202" $IPRANGE[203] = "10.20.1.203" $IPRANGE[204] = "10.20.1.204" $IPRANGE[205] = "10.20.1.205" $IPRANGE[206] = "10.20.1.206" $IPRANGE[207] = "10.20.1.207" $IPRANGE[208] = "10.20.1.208" $IPRANGE[209] = "10.20.1.209" $IPRANGE[210] = "10.20.1.210" $IPRANGE[211] = "10.20.1.211" $IPRANGE[212] = "10.20.1.212" $IPRANGE[213] = "10.20.1.213" $IPRANGE[214] = "10.20.1.214" $IPRANGE[215] = "10.20.1.215" $IPRANGE[216] = "10.20.1.216" $IPRANGE[217] = "10.20.1.217" $IPRANGE[218] = "10.20.1.218" $IPRANGE[219] = "10.20.1.219" $IPRANGE[220] = "10.20.1.220" $IPRANGE[221] = "10.20.1.221" $IPRANGE[222] = "10.20.1.222" $IPRANGE[223] = "10.20.1.223" $IPRANGE[224] = "10.20.1.224" $IPRANGE[225] = "10.20.1.225" $IPRANGE[226] = "10.20.1.226" $IPRANGE[227] = "10.20.1.227" $IPRANGE[228] = "10.20.1.228" $IPRANGE[229] = "10.20.1.229" $IPRANGE[230] = "10.20.1.230" $IPRANGE[231] = "10.20.1.231" $IPRANGE[232] = "10.20.1.232" $IPRANGE[233] = "10.20.1.233" $IPRANGE[234] = "10.20.1.234" $IPRANGE[235] = "10.20.1.235" $IPRANGE[236] = "10.20.1.236" $IPRANGE[237] = "10.20.1.237" $IPRANGE[238] = "10.20.1.238" $IPRANGE[239] = "10.20.1.239" $IPRANGE[240] = "10.20.1.240" $IPRANGE[241] = "10.20.1.241" $IPRANGE[242] = "10.20.1.242" $IPRANGE[243] = "10.20.1.243" $IPRANGE[244] = "10.20.1.244" $IPRANGE[245] = "10.20.1.245" $IPRANGE[246] = "10.20.1.246" $IPRANGE[247] = "10.20.1.247" $IPRANGE[248] = "10.20.1.248" $IPRANGE[249] = "10.20.1.249" $IPRANGE[250] = "10.20.1.250" $IPRANGE[251] = "10.20.1.251" $IPRANGE[252] = "10.20.1.252" $IPRANGE[253] = "10.20.1.253" $IPRANGE[254] = "10.20.1.254" $IPRANGE[255] = "10.20.24.1" $IPRANGE[256] = "10.20.24.2" $IPRANGE[257] = "10.20.24.3" $IPRANGE[258] = "10.20.24.4" $IPRANGE[259] = "10.20.24.5" $IPRANGE[260] = "10.20.24.6" $IPRANGE[261] = "10.20.24.7" $IPRANGE[262] = "10.20.24.8" $IPRANGE[263] = "10.20.24.9" $IPRANGE[264] = "10.20.24.10" $IPRANGE[265] = "10.20.24.11" $IPRANGE[266] = "10.20.24.12" $IPRANGE[267] = "10.20.24.13" $IPRANGE[268] = "10.20.24.14" $IPRANGE[269] = "10.20.24.15" $IPRANGE[270] = "10.20.24.16" $IPRANGE[271] = "10.20.24.17" $IPRANGE[272] = "10.20.24.18" $IPRANGE[273] = "10.20.24.19" $IPRANGE[274] = "10.20.24.20" $IPRANGE[275] = "10.20.24.21" $IPRANGE[276] = "10.20.24.22" $IPRANGE[277] = "10.20.24.23" $IPRANGE[278] = "10.20.24.24" $IPRANGE[279] = "10.20.24.25" $IPRANGE[280] = "10.20.24.26" $IPRANGE[281] = "10.20.24.27" $IPRANGE[282] = "10.20.24.28" $IPRANGE[283] = "10.20.24.29" $IPRANGE[284] = "10.20.24.30" $IPRANGE[285] = "10.20.24.31" $IPRANGE[286] = "10.20.24.32" $IPRANGE[287] = "10.20.24.33" $IPRANGE[288] = "10.20.24.34" $IPRANGE[289] = "10.20.24.35" $IPRANGE[290] = "10.20.24.36" $IPRANGE[291] = "10.20.24.37" $IPRANGE[292] = "10.20.24.38" $IPRANGE[293] = "10.20.24.39" $IPRANGE[294] = "10.20.24.40" $IPRANGE[295] = "10.20.24.41" $IPRANGE[296] = "10.20.24.42" $IPRANGE[297] = "10.20.24.43" $IPRANGE[298] = "10.20.24.44" $IPRANGE[299] = "10.20.24.45" $IPRANGE[300] = "10.20.24.46" $IPRANGE[301] = "10.20.24.47" $IPRANGE[302] = "10.20.24.48" $IPRANGE[303] = "10.20.24.49" $IPRANGE[304] = "10.20.24.50" $IPRANGE[305] = "10.20.24.51" $IPRANGE[306] = "10.20.24.52" $IPRANGE[307] = "10.20.24.53" $IPRANGE[308] = "10.20.24.54" $IPRANGE[309] = "10.20.24.55" $IPRANGE[310] = "10.20.24.56" $IPRANGE[311] = "10.20.24.57" $IPRANGE[312] = "10.20.24.58" $IPRANGE[313] = "10.20.24.59" $IPRANGE[314] = "10.20.24.60" $IPRANGE[315] = "10.20.24.61" $IPRANGE[316] = "10.20.24.62" $IPRANGE[317] = "10.20.24.63" $IPRANGE[318] = "10.20.24.64" $IPRANGE[319] = "10.20.24.65" $IPRANGE[320] = "10.20.24.66" $IPRANGE[321] = "10.20.24.67" $IPRANGE[322] = "10.20.24.68" $IPRANGE[323] = "10.20.24.69" $IPRANGE[324] = "10.20.24.70" $IPRANGE[325] = "10.20.24.71" $IPRANGE[326] = "10.20.24.72" $IPRANGE[327] = "10.20.24.73" $IPRANGE[328] = "10.20.24.74" $IPRANGE[329] = "10.20.24.75" $IPRANGE[330] = "10.20.24.76" $IPRANGE[331] = "10.20.24.77" $IPRANGE[332] = "10.20.24.78" $IPRANGE[333] = "10.20.24.79" $IPRANGE[334] = "10.20.24.80" $IPRANGE[335] = "10.20.24.81" $IPRANGE[336] = "10.20.24.82" $IPRANGE[337] = "10.20.24.83" $IPRANGE[338] = "10.20.24.84" $IPRANGE[339] = "10.20.24.85" $IPRANGE[340] = "10.20.24.86" $IPRANGE[341] = "10.20.24.87" $IPRANGE[342] = "10.20.24.88" $IPRANGE[343] = "10.20.24.89" $IPRANGE[344] = "10.20.24.90" $IPRANGE[345] = "10.20.24.91" $IPRANGE[346] = "10.20.24.92" $IPRANGE[347] = "10.20.24.93" $IPRANGE[348] = "10.20.24.94" $IPRANGE[349] = "10.20.24.95" $IPRANGE[350] = "10.20.24.96" $IPRANGE[351] = "10.20.24.97" $IPRANGE[352] = "10.20.24.98" $IPRANGE[353] = "10.20.24.99" $IPRANGE[354] = "10.20.24.100" $IPRANGE[355] = "10.20.24.101" $IPRANGE[356] = "10.20.24.102" $IPRANGE[357] = "10.20.24.103" $IPRANGE[358] = "10.20.24.104" $IPRANGE[359] = "10.20.24.105" $IPRANGE[360] = "10.20.24.106" $IPRANGE[361] = "10.20.24.107" $IPRANGE[362] = "10.20.24.108" $IPRANGE[363] = "10.20.24.109" $IPRANGE[364] = "10.20.24.110" $IPRANGE[365] = "10.20.24.111" $IPRANGE[366] = "10.20.24.112" $IPRANGE[367] = "10.20.24.113" $IPRANGE[368] = "10.20.24.114" $IPRANGE[369] = "10.20.24.115" $IPRANGE[370] = "10.20.24.116" $IPRANGE[371] = "10.20.24.117" $IPRANGE[372] = "10.20.24.118" $IPRANGE[373] = "10.20.24.119" $IPRANGE[374] = "10.20.24.120" $IPRANGE[375] = "10.20.24.121" $IPRANGE[376] = "10.20.24.122" $IPRANGE[377] = "10.20.24.123" $IPRANGE[378] = "10.20.24.124" $IPRANGE[379] = "10.20.24.125" $IPRANGE[380] = "10.20.24.126" $IPRANGE[381] = "10.20.24.127" $IPRANGE[382] = "10.20.24.128" $IPRANGE[383] = "10.20.24.129" $IPRANGE[384] = "10.20.24.130" $IPRANGE[385] = "10.20.24.131" $IPRANGE[386] = "10.20.24.132" $IPRANGE[387] = "10.20.24.133" $IPRANGE[388] = "10.20.24.134" $IPRANGE[389] = "10.20.24.135" $IPRANGE[390] = "10.20.24.136" $IPRANGE[391] = "10.20.24.137" $IPRANGE[392] = "10.20.24.138" $IPRANGE[393] = "10.20.24.139" $IPRANGE[394] = "10.20.24.140" $IPRANGE[395] = "10.20.24.141" $IPRANGE[396] = "10.20.24.142" $IPRANGE[397] = "10.20.24.143" $IPRANGE[398] = "10.20.24.144" $IPRANGE[399] = "10.20.24.145" $IPRANGE[400] = "10.20.24.146" $IPRANGE[401] = "10.20.24.147" $IPRANGE[402] = "10.20.24.148" $IPRANGE[403] = "10.20.24.149" $IPRANGE[404] = "10.20.24.150" $IPRANGE[405] = "10.20.24.151" $IPRANGE[406] = "10.20.24.152" $IPRANGE[407] = "10.20.24.153" $IPRANGE[408] = "10.20.24.154" $IPRANGE[409] = "10.20.24.155" $IPRANGE[410] = "10.20.24.156" $IPRANGE[411] = "10.20.24.157" $IPRANGE[412] = "10.20.24.158" $IPRANGE[413] = "10.20.24.159" $IPRANGE[414] = "10.20.24.160" $IPRANGE[415] = "10.20.24.161" $IPRANGE[416] = "10.20.24.162" $IPRANGE[417] = "10.20.24.163" $IPRANGE[418] = "10.20.24.164" $IPRANGE[419] = "10.20.24.165" $IPRANGE[420] = "10.20.24.166" $IPRANGE[421] = "10.20.24.167" $IPRANGE[422] = "10.20.24.168" $IPRANGE[423] = "10.20.24.169" $IPRANGE[424] = "10.20.24.170" $IPRANGE[425] = "10.20.24.171" $IPRANGE[426] = "10.20.24.172" $IPRANGE[427] = "10.20.24.173" $IPRANGE[428] = "10.20.24.174" $IPRANGE[429] = "10.20.24.175" $IPRANGE[430] = "10.20.24.176" $IPRANGE[431] = "10.20.24.177" $IPRANGE[432] = "10.20.24.178" $IPRANGE[433] = "10.20.24.179" $IPRANGE[434] = "10.20.24.180" $IPRANGE[435] = "10.20.24.181" $IPRANGE[436] = "10.20.24.182" $IPRANGE[437] = "10.20.24.183" $IPRANGE[438] = "10.20.24.184" $IPRANGE[439] = "10.20.24.185" $IPRANGE[440] = "10.20.24.186" $IPRANGE[441] = "10.20.24.187" $IPRANGE[442] = "10.20.24.188" $IPRANGE[443] = "10.20.24.189" $IPRANGE[444] = "10.20.24.190" $IPRANGE[445] = "10.20.24.191" $IPRANGE[446] = "10.20.24.192" $IPRANGE[447] = "10.20.24.193" $IPRANGE[448] = "10.20.24.194" $IPRANGE[449] = "10.20.24.195" $IPRANGE[450] = "10.20.24.196" $IPRANGE[451] = "10.20.24.197" $IPRANGE[452] = "10.20.24.198" $IPRANGE[453] = "10.20.24.199" $IPRANGE[454] = "10.20.24.200" $IPRANGE[455] = "10.20.24.201" $IPRANGE[456] = "10.20.24.202" $IPRANGE[457] = "10.20.24.203" $IPRANGE[458] = "10.20.24.204" $IPRANGE[459] = "10.20.24.205" $IPRANGE[460] = "10.20.24.206" $IPRANGE[461] = "10.20.24.207" $IPRANGE[462] = "10.20.24.208" $IPRANGE[463] = "10.20.24.209" $IPRANGE[464] = "10.20.24.210" $IPRANGE[465] = "10.20.24.211" $IPRANGE[466] = "10.20.24.212" $IPRANGE[467] = "10.20.24.213" $IPRANGE[468] = "10.20.24.214" $IPRANGE[469] = "10.20.24.215" $IPRANGE[470] = "10.20.24.216" $IPRANGE[471] = "10.20.24.217" $IPRANGE[472] = "10.20.24.218" $IPRANGE[473] = "10.20.24.219" $IPRANGE[474] = "10.20.24.220" $IPRANGE[475] = "10.20.24.221" $IPRANGE[476] = "10.20.24.222" $IPRANGE[477] = "10.20.24.223" $IPRANGE[478] = "10.20.24.224" $IPRANGE[479] = "10.20.24.225" $IPRANGE[480] = "10.20.24.226" $IPRANGE[481] = "10.20.24.227" $IPRANGE[482] = "10.20.24.228" $IPRANGE[483] = "10.20.24.229" $IPRANGE[484] = "10.20.24.230" $IPRANGE[485] = "10.20.24.231" $IPRANGE[486] = "10.20.24.232" $IPRANGE[487] = "10.20.24.233" $IPRANGE[488] = "10.20.24.234" $IPRANGE[489] = "10.20.24.235" $IPRANGE[490] = "10.20.24.236" $IPRANGE[491] = "10.20.24.237" $IPRANGE[492] = "10.20.24.238" $IPRANGE[493] = "10.20.24.239" $IPRANGE[494] = "10.20.24.240" $IPRANGE[495] = "10.20.24.241" $IPRANGE[496] = "10.20.24.242" $IPRANGE[497] = "10.20.24.243" $IPRANGE[498] = "10.20.24.244" $IPRANGE[499] = "10.20.24.245" $IPRANGE[500] = "10.20.24.246" $IPRANGE[501] = "10.20.24.247" $IPRANGE[502] = "10.20.24.248" $IPRANGE[503] = "10.20.24.249" $IPRANGE[504] = "10.20.24.250" $IPRANGE[505] = "10.20.24.251" $IPRANGE[506] = "10.20.24.252" $IPRANGE[507] = "10.20.24.253" $IPRANGE[508] = "10.20.24.254" ;$IPRANGE[509] = "10.20.32.103" ;Testing only Local $ip1 Local $ip2 Local $ip3 Local $ip4 Dim $sLogPath = @ScriptDir & "\TESTIPLOG.txt" Dim $sLogMsg = "User: " For $i = 1 To UBound($IPRANGE) - 1 If $IPRANGE[$i] = @IPAddress1 OR $IPRANGE[$i] = @IPAddress2 OR $IPRANGE[$i] = @IPAddress3 OR $IPRANGE[$i] = @IPAddress4 Then _MyFileWriteLog($sLogPath , $sLogMsg) EndIf Next Func _MyFileWriteLog($sLogPath, $sLogMsg) Local $sDateNow Local $sTimeNow Local $sMsg Local $hOpenFile Local $hWriteFile Local $user Local $cname $sDateNow = "On " & @YEAR & "-" & @MON & "-" & @MDAY $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC $ip1 = @IPAddress1 $ip2 = @IPAddress2 $ip3 = @IPAddress3 $ip4 = @IPAddress4 $user = @UserName $cname = @ComputerName $osversion = @OSVersion $sMsg = $sDateNow & "," & $cname & "," & $osversion & "," & $user & "," & $ip1 & "," & $ip2 & "," & $ip3 & "," & $ip4 $hOpenFile = FileOpen($sLogPath, 1) If $hOpenFile = -1 Then SetError(1) Return 0 EndIf $hWriteFile = FileWriteLine($hOpenFile, $sMsg) If $hWriteFile = -1 Then SetError(2) Return 0 EndIf FileClose($hOpenFile) Return 1 EndFunc FileCopy('c:\windows\' & @ComputerName & ".txt", '\\lon-srv2\logs',1)
    1 point
  24. UEZ of the german forum has already created such an UDF to display the content of an array in a formated way on the console. It works pretty well
    1 point
  25. Want to develop your PrintList idea for good coding practice? Make it print out in a uniform manner in rows and columns, which you could actually print via a printer.
    1 point
  26. bogQ

    ListView select subitems.

    and another interesting topic it is maybe from 2007 but that code still works
    1 point
  27. ;~ Example made by LarsJ, just some very little change by Johnmcloud - 2015 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hListview, $aHit[2] = [-1, -1] ; $aHit contains row & col of marked cell $hGUI = GUICreate("Mark Cell in Listview", 250, 222) Local $iListview = GUICtrlCreateListView("Column 0|Column 1", 2, 2, 248, 180, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $$hListview = GUICtrlGetHandle($iListview) Local $iButton = GUICtrlCreateButton("Value?", 90, 193, 70, 20) For $i = 0 To 50 GUICtrlCreateListViewItem("Item" & $i & "|SubItem " & $i, $iListview) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListview Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, False) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 2, $aInfo[1] - 2) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY  $LVS_EX_BORDERSELECT works only with icon Listview style, your use is wrong. Rename the thread accordy to the request, so "how to select subitem in listview" or similar.
    1 point
  28. You are aware of the _ArrayDisplay command in the UDF section of the Help file? I don't wish to discourage you on your programming journey, but I suggest you read what I wrote >here. P.S. Nice to see you coming along with your programming though.
    1 point
  29. Reproduced on windows 8.1.
    1 point
  30. Exit

    AutoIt3.exe ended.rc:255

    No source = No error
    1 point
  31. Radiance

    Can't get output correct

    UBound basically tells you how much slots your array has. $Array[4] = 4 Slots, ranging from 0-3 $Array[300] = 300 slots, ranging from 0 to 299 It's a common tactic to use the [0] for saving how much filled slots your array contains. This removes the use of the UBound funtcion. Dim $array[5] $Array[0] = 4 $Array[1] = "Data 1" $Array[2] = "Data 2" $Array[3] = "Data 3" $Array[4] = "Data 4" For $i = 1 To $Array[0] MsgBox(0, "", $Array[$i]) Next
    1 point
  32. Radiance

    Can't get output correct

    ;.... $IPRANGE[501] = "10.20.24.247" $IPRANGE[502] = "10.20.24.248" $IPRANGE[503] = "10.20.24.249" $IPRANGE[504] = "10.20.24.250" $IPRANGE[505] = "10.20.24.251" $IPRANGE[506] = "10.20.24.252" $IPRANGE[507] = "10.20.24.253" $IPRANGE[508] = "10.20.24.254" $IPRANGE[509] = "10.20.32.103" For $i = 1 To UBound($IPRANGE) - 1 If $IPRANGE[$i] = @IPAddress1 OR $IPRANGE[$i] = @IPAddress2 OR $IPRANGE[$i] = @IPAddress3 OR $IPRANGE[$i] = @IPAddress4 Then MsgBox(0, "IP Address:", $IPRANGE[$i]) EndIf Next
    1 point
  33. JohnOne

    Can't get output correct

    For $i = 0 To UBound($IPRANGE) -1 If @IPAddress1 = $IPRANGE[$i] Then MsgBox(0, "IP Address:", $IPRANGE[$i]) ElseIf @IPAddress2 = $IPRANGE[$i] Then MsgBox(0, "IP Address:", $IPRANGE[$i]) ElseIf @IPAddress3 = $IPRANGE[$i] Then MsgBox(0, "IP Address:", $IPRANGE[$i]) ElseIf @IPAddress4 = $IPRANGE[$i] Then MsgBox(0, "IP Address:", $IPRANGE[$i]) EndIf Next
    1 point
  34. the link you provided is based on findstr which is also limited to text files. use xdoc2txt (google it) to extract text and then feed the text to your AutoIt script. EDIT: here is a WinMerge plugin that is based on xdoc2txt, you can use it independently. this is an older version though, look for the newer one from the author site (Japanese, but manageable)
    1 point
  35. Hello, I think i have another bug. If i minimize and then maximize ISN, then i can no longer click the toolbar buttons of the IDE. If i then just resize the IDE(by dragging the edge), i can then again click the toolbar buttons. This is very consistent, it happens every time. Not a big problem to me, i just wanted to mention this.
    1 point
  36. The intention with the above function was to return true for all numeric formats recognized by AutoIt: 0xABC0FF becomes a number when the interpreter executes that string. We can remove parts of the regular expression to prevent various formats from returning True, as I have done below. This gives several alternatives. ; #include <Array.au3> Func _StrIsNumHx($sString) ; original expression Return StringRegExp($sString, "(?i)\A(\-?\d+(\.\d+)?(e[\+\-]\d{1,3})?|0x[A-F\d]{1,16})\z") = 1 EndFunc Func _StrIsNumEx($sString) ; no hex representation Return StringRegExp($sString, "(?i)\A(\-?\d+(\.\d+)?(e[\+\-]\d{1,3})?)\z") = 1 EndFunc Func _StrIsNumFl($sString) ; no exponential notation Return StringRegExp($sString, "\A(\-?\d+(\.\d+)?)\z") = 1 EndFunc Func _StrIsNumIn($sString) ; no floats Return StringRegExp($sString, "\A(\-?\d+)\z") = 1 EndFunc Local $aTruthTable[5][5] = [['Input','_StrIsNumHx','_StrIsNumEx','_StrIsNumFl','_StrIsNumIn']] $aTruthTable[1][0] = '0xABC0FF' ; binary $aTruthTable[2][0] = '-1e-101' ; exponential $aTruthTable[3][0] = '12.007' ; float $aTruthTable[4][0] = '-123' ; integer For $i = 1 To 4 $aTruthTable[$i][1] = _StrIsNumHx($aTruthTable[$i][0]) $aTruthTable[$i][2] = _StrIsNumEx($aTruthTable[$i][0]) $aTruthTable[$i][3] = _StrIsNumFl($aTruthTable[$i][0]) $aTruthTable[$i][4] = _StrIsNumIn($aTruthTable[$i][0]) Next _ArrayDisplay($aTruthTable, "Truth Table")
    1 point
  37. No problem friend, we don't do it for the points score here, at least I don't. As we say in Dutch, "small effort, big pleasure".
    1 point
  38. val75, Try the following... #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> OnAutoItExitRegister ( "_fini" ) local $st = timerinit() Local $oE = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL,'Open Failed', @error & @lf & @extended) ; get columns and populate array Local $sWorkbook = @ScriptDir & "\Exceltest.xls" Local $oWB = _Excel_BookOpen($oE, $sWorkbook, Default, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $aResult = _Excel_RangeRead($oWB, Default, $oWB.ActiveSheet.Usedrange.Columns("A:Z"), 2) local $aFinal[UBound($aResult)][3] for $1 = 0 to UBound($aResult) - 1 $aFinal[$1][0] = $aResult[$1][0] $aFinal[$1][1] = $aResult[$1][1] $aFinal[$1][2] = $aResult[$1][25] next ConsoleWrite('Time to get spreadsheet and populate final array = ' & timerdiff($st)/1000 & @CRLF) _arraydisplay($aFinal,'Final',default,default,default,'A|B|Z') func _fini() _Excel_Close($oE) endfunc The spread sheet is 6000 rows and runs as follows >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\ADMIN010\Documents\help - Excel.au3" /UserParams +>16:07:38 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\ADMIN010\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\ADMIN010\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.13.19) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\ADMIN010\Documents\help - Excel.au3 +>16:07:38 AU3Check ended.rc:0 >Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\ADMIN010\Documents\help - Excel.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Time to get spreadsheet and populate final array = 1.05814865721724 +>16:07:43 AutoIt3.exe ended.rc:0 +>16:07:43 AutoIt3Wrapper Finished. >Exit code: 0 Time: 5.86 kylomas
    1 point
  39. Not for this - the "Use Windows XP style DPI scaling" is not a compatibility mode, it's actually what this thread is all about. On Win7 when you select a custom DPI (emphasis on custom) and in Win8 as well (though in a slightly different place) the options window has an extra checkbox which is what controls the system-wide DWM scaling (sometimes called "DPI Virtualisation") that was introduced in Vista+. Basically it's what this manifest setting actually does: declaring an application DPI "aware" means that the application itself is 100% responsible for any scaling (as it was in XP). Normally (as above) if the user selects a DPI of 150 Windows automatically enables DPI Virtualisation (i.e., it's the same as forcing the Use Windows XP style box to be unchecked). This is what causes the blurriness that people don't like. On the other hand, it does conveniently scale all elements of a (non-aware) GUI in a nice clean way - no worrying about either calculating the expansion of individual controls, or reducing the font size or however one cares to handle it. At the end of the day, it's the same as the API's SetProcessDPIAware function, though AutoIt binaries have a tendency to resist that function's affections for some reason. Above, when I found that the DPI ratio was incorrectly being reported as 1 (instead of 1.5) that's the DPI Virtualisation getting in the way - when DPI awareness is set (by whatever method), the ratio will always return 1.5, regardless of what setting the user selected. The downside of this is that it is indeed not a magic bullet for scaling, and the developer has to do everything himself. Another downside is that some versions of obtaining the DPI setting will fail on these compiled EXE's because for some unknown reason the GDI+ method of reading the ratio fails when Awareness is set - but there are other methods available, like the one I used above (stolen and simplified from Phillip123Adams approach, found in an old post of his which has since slipped into the aether). Adding DPI-awareness to the wrapper is a good thing, if for no other reason than the user's programme will always behave predictably (and report the proper DPI) no matter what options in Windows were set or unset (beyond the dev's purview). And by "predictably" I mean that it will always have an ugly/skewed GUI because DPI Virtualisation can never be applied to it, thus requiring the dev to either shrink the font size (boo hiss!) or handle the control scaling on an individual basis himself. That part's up to us. All that being said, for those who don't mind letting Windows handle things, all they have to do is ignore this wrapper setting and tell their complaining users to uncheck the Use Windows XP style DPI scaling box like they've always done, and learn to live with the blur. Final verdict (at least by me): #AutoIt3Wrapper_Res_HiDpi=Y does work, and it's good thing, but it just doesn't work the way we hoped it would. There just is no magic bullet, and no substitute for hard work.
    1 point
  40. From your screen shot, it looks like: _GUICtrlListView* functions will work. Edit: Pays to read everything you wrote! That also looks like an embedded progress bar, so maybe the above functions (_GUICtrlListView with Guiness's progress bar functions: '?do=embed' frameborder='0' data-embedContent>> ) Not sure he has the right ones, but could help. Edit2: Looks like that just sets the progress, you're looking for pbm_getpos. If you can get the handle to the progress bar, then this little bit of code will work more than likely:
    1 point
  41. '?do=embed' frameborder='0' data-embedContent>> Maybe you can try with the SimpleSpy example if you can get it?
    1 point
  42. 1 point
  43. Unfortunately, there's no "DOM" au3... although it sounds like a fun and extremely lengthy project. I know chimp worked on raw html table parser though. If you got a group of descent coders together for the project, I might be willing to add to the mix. But, now you know why I suggested the IE engine. There's always methods to cleanup as well, but if you're doing this on client machines, your project may be too delicate and the need for a complete dom parser eludes me at the moment.
    1 point
  44. Okay now I am confused. $rowcount += 1 ; want to add rows below that You want to add empty rows after the last row used? Why? I mean this doesn't change a thing at all, because the rows after the last used row, are already empty.
    1 point
  45. OK, I think I need to enhance documentation how _Excel_RangeInsert works. Then the bugs in the example scripts need to removed. @JohnOne If you want to add data to the end of the worksheet use $oWorkbook.ActiveSheet.UsedRange.Rows.Count add 1 and you have the row where you can write data using _Excel_RangeWrite. This is true as long as the usedrange starts in row 1. For details and examples please check the wiki.
    1 point
  46. Interesting... a quick test using Win10 on a virtual machine does not change anything (the GUI is still all wrong), so just out of interest, what happens on Win8 if you use your same script manually converted into DPI-Awareness the traditional way? I don't have Win8 so can't test it myself - but this method is the only way I know how to do it properly for XP/Win7/Win10 - your method of reducing the font-size is not fair to users. #AutoIt3Wrapper_res_Compatibility=Windows7 #AutoIt3Wrapper_Res_HiDpi=y #include <WinAPI.au3> #include <FontConstants.au3> #include <GuiConstantsEx.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> Func _GetDPI() Local $hDC = _WinAPI_GetDC(0) Local $DPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY) _WinAPI_ReleaseDC(0, $hDC) Select Case $DPI = 0 $DPI = 1 Case $DPI < 84 $DPI /= 105 Case $DPI < 121 $DPI /= 96 Case $DPI < 145 $DPI /= 95 Case Else $DPI /= 94 EndSelect Return Round($DPI, 2) EndFunc $DPI = _GetDPI() ; GUI GUICreate("Sample GUI", 400 * $DPI, 400 * $DPI) GUISetIcon(@SystemDir & "\mspaint.exe", 0) ; MENU GUICtrlCreateMenu("Menu&One") GUICtrlCreateMenu("Menu&Two") GUICtrlCreateMenu("MenuTh&ree") GUICtrlCreateMenu("Menu&Four") ; CONTEXT MENU Local $iContextMenu = GUICtrlCreateContextMenu() GUICtrlCreateMenuItem("Context Menu", $iContextMenu) GUICtrlCreateMenuItem("", $iContextMenu) ; Separator GUICtrlCreateMenuItem("&Properties", $iContextMenu) ; PIC GUICtrlCreatePic("logo4.gif", 0, 0, 169 * $DPI, 68 * $DPI) GUICtrlCreateLabel("Sample Pic", 75 * $DPI, 1 * $DPI, 53 * $DPI, 15 * $DPI) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; AVI GUICtrlCreateAvi("SampleAVI.avi", 0, 180 * $DPI, 10 * $DPI, 32 * $DPI, 32 * $DPI, $ACS_AUTOPLAY) GUICtrlCreateLabel("Sample avi", 175 * $DPI, 50 * $DPI) ; TAB GUICtrlCreateTab(240 * $DPI, 0, 150 * $DPI, 70 * $DPI) GUICtrlCreateTabItem("One") GUICtrlCreateLabel("Sample Tab with tabItems", 250 * $DPI, 40 * $DPI) GUICtrlCreateTabItem("Two") GUICtrlCreateTabItem("Three") GUICtrlCreateTabItem("") ; COMBO GUICtrlCreateCombo("Sample Combo", 250 * $DPI, 80 * $DPI, 120 * $DPI, 100 * $DPI) ; PROGRESS GUICtrlCreateProgress(60 * $DPI, 80 * $DPI, 150 * $DPI, 20 * $DPI) GUICtrlSetData(-1, 60 * $DPI) GUICtrlCreateLabel("Progress:", 5 * $DPI, 82 * $DPI) ; EDIT GUICtrlCreateEdit(@CRLF & " Sample Edit Control", 10 * $DPI, 110 * $DPI, 150 * $DPI, 70 * $DPI) ; LIST GUICtrlCreateList("", 5 * $DPI, 190 * $DPI, 100 * $DPI, 90 * $DPI) GUICtrlSetData(-1, "A.Sample|B.List|C.Control|D.Here", "B.List") ; ICON GUICtrlCreateIcon("explorer.exe", 0, 175 * $DPI, 120 * $DPI) GUICtrlCreateLabel("Icon", 180 * $DPI, 160 * $DPI, 50 * $DPI, 20 * $DPI) ; LIST VIEW Local $iListView = GUICtrlCreateListView("Sample|ListView|", 110 * $DPI, 190 * $DPI, 110 * $DPI, 80 * $DPI) GUICtrlCreateListViewItem("A|One", $iListView) GUICtrlCreateListViewItem("B|Two", $iListView) GUICtrlCreateListViewItem("C|Three", $iListView) ; GROUP WITH RADIO BUTTONS GUICtrlCreateGroup("Sample Group", 230 * $DPI, 120 * $DPI) GUICtrlCreateRadio("Radio One", 250 * $DPI, 140 * $DPI, 80 * $DPI) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateRadio("Radio Two", 250 * $DPI, 165 * $DPI, 80 * $DPI) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group ; UPDOWN GUICtrlCreateLabel("UpDown", 350 * $DPI, 115 * $DPI) GUICtrlCreateInput("42", 350 * $DPI, 130 * $DPI, 40 * $DPI, 20 * $DPI) GUICtrlCreateUpdown(-1) ; LABEL GUICtrlCreateLabel("Green" & @CRLF & "Label", 350 * $DPI, 165 * $DPI, 40 * $DPI, 40 * $DPI) GUICtrlSetBkColor(-1, 0x00FF00) ; SLIDER GUICtrlCreateLabel("Slider:", 235 * $DPI, 215 * $DPI) GUICtrlCreateSlider(270 * $DPI, 210 * $DPI, 120 * $DPI, 30 * $DPI) GUICtrlSetData(-1, 30 * $DPI) ; INPUT GUICtrlCreateInput("Sample Input Box", 235 * $DPI, 255 * $DPI, 130 * $DPI, 20 * $DPI) ; DATE GUICtrlCreateDate("", 5 * $DPI, 280 * $DPI, 200 * $DPI, 20 * $DPI) GUICtrlCreateLabel("(Date control expands into a calendar)", 10 * $DPI, 305 * $DPI, 200 * $DPI, 20 * $DPI) ; BUTTON GUICtrlCreateButton("Sample Button", 10 * $DPI, 330 * $DPI, 100 * $DPI, 30 * $DPI) ; CHECKBOX GUICtrlCreateCheckbox("Checkbox", 130 * $DPI, 335 * $DPI, 80 * $DPI, 20 * $DPI) GUICtrlSetState(-1, $GUI_CHECKED) ; TREEVIEW ONE Local $iTreeView_1 = GUICtrlCreateTreeView(210 * $DPI, 290 * $DPI, 80 * $DPI, 80 * $DPI) Local $iTreeItem = GUICtrlCreateTreeViewItem("TreeView", $iTreeView_1) GUICtrlCreateTreeViewItem("Item1", $iTreeItem) GUICtrlCreateTreeViewItem("Item2", $iTreeItem) GUICtrlCreateTreeViewItem("Foo", -1) GUICtrlSetState($iTreeItem, $GUI_EXPAND) ; TREEVIEW TWO Local $iTreeView_2 = GUICtrlCreateTreeView(295 * $DPI, 290 * $DPI, 103 * $DPI, 80 * $DPI, $TVS_CHECKBOXES) GUICtrlCreateTreeViewItem("TreeView", $iTreeView_2) GUICtrlCreateTreeViewItem("With", $iTreeView_2) GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $iTreeView_2) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateTreeViewItem("Style", $iTreeView_2) ; GUI MESSAGE LOOP GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd And before you ask, no, the new Wrapper directive does not work for me either on Win7... I don't think there is a "simple" solution. Since reducing the font by DPI ratio defeats the purpose of DPI the only other means is the old-fashioned way of blood sweat and tears. And lots of multiplication.
    1 point
  47. Hello! I've made this script a year ago and I have been asked by people to post my final script so they can use it. This is nothing fancy, but just thought of sharing it with the community Script purpose and explanation: Search for a word / sentence* inside .txt and .log files (you may add more extensions)Search in sub-directories - Will search in main folder + all of the folders in the main folders if checked.Save a new log with the paths of the files containing the word / sentenceBugs are still available as I used it personally and knew how NOT to cause it to crash so this is not bug-free.This is very very usable however and shouldn't crash at all if used correctly. *Please note: In case of searching for a sentence, it will only return files containing the sentence in it's full. For example: Searching for "I am walking" will only return files containing "I am walking" and not files with "I", with "am" and "walking" in separate. Enjoy Search In Files_With GUI - By Kfir v1.1.au3
    1 point
  48. JScript

    _NetWork.au3 (UDF)

    Hello everyone, To Set/Get WorkGroupName and Set ComputerName without restarting! Try the code below: _NetWork.au3 #include-once #include "EnvUpdate.inc" ; #INDEX# ======================================================================================================================= ; Title .........: Set/Get WorkGroupName and Set ComputerName ; AutoIt Version.: 3.2.12++ ; Language.......: English ; Description ...: And Refreshes the OS environment. ; Author ........: João Carlos (jscript) ; Support .......: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_SetComputerName ;_SetWorkGroupName ;_GetWorkgroupName ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== ; #FUNCTION# ======================================================================================================================================================= ; Name...........: _SetComputerName ; Description ...: Sets the new computer name. ; Syntax.........: _SetComputerName( "ComputerName" ) ; Parameters ....: ; Requirement(s).: ; Return values .: Success - Returns 1 ; Failure - Returns 0 ; Author ........: jscript ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _SetComputerName( "VAIO" ) ; ================================================================================================================================================================== Func _SetComputerName($sCmpName) Local $sLogonKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" Local $sCtrlKey = "HKLM\SYSTEM\CurrentControlSet" ; RagsRevenge -> http://www.autoitscript.com/forum/index.php?showtopic=54091&view=findpost&p=821901 If StringRegExp($sCmpName, '\\|/|:|\*|\?|"|<|>|\.|,|~|!|@|#|\$|%|\^|&|\(|\)|\;|{|}|_|=|\+|\[|\]|\x60' & "|'", 0) = 0 Then Return 0 ; 5 = ComputerNamePhysicalDnsHostname $aRet = DllCall("Kernel32.dll", "BOOL", "SetComputerNameEx", "int", 5, "str", $sCmpName) If $aRet[0] = 0 Then Return 0 RegWrite($sCtrlKey & "\Control\Computername\ActiveComputername", "ComputerName", "REG_SZ", $sCmpName) RegWrite($sCtrlKey & "\Control\Computername\Computername", "ComputerName", "REG_SZ", $sCmpName) RegWrite($sCtrlKey & "\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $sCmpName) RegWrite($sCtrlKey & "\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $sCmpName) RegWrite($sLogonKey, "AltDefaultDomainName", "REG_SZ", $sCmpName) RegWrite($sLogonKey, "DefaultDomainName", "REG_SZ", $sCmpName) RegWrite("HKEY_USERS\.Default\Software\Microsoft\Windows Media\WMSDK\General", "Computername", "REG_SZ", $sCmpName) _EnvUpdate("COMPUTERNAME", $sCmpName, False, True) Return 1 EndFunc ;==>_SetComputerName ; #FUNCTION# ======================================================================================================================================================= ; Name...........: _SetWorkGroupName ; Description ...: Sets the new NetBIOS Workgroup name. ; Syntax.........: _SetWorkGroupName( "WorkGroupName" ) ; Parameters ....: ; Requirement(s).: ; Return values .: Success - Returns NERR_Success ; Failure - Return value can be one of the following error codes: http://msdn.microsoft.com/en-us/library/aa370433%28VS.85%29.aspx ; Author ........: jscript ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _SetWorkGroupName( "MSHOME" ) ; ================================================================================================================================================================== Func _SetWorkGroupName($sGroupName) Local $aRet = DllCall("Netapi32.dll", "long", "NetJoinDomain", "int", 0, "wstr", $sGroupName, "int", 0, "int", 0, "int", 0, "dword", 0x00000040) Return $aRet[0] EndFunc ;==>_SetWorkGroupName ; #FUNCTION# ======================================================================================================================================================= ; Name...........: _GetWorkgroupName ; Description ...: Retrivies the current NetBIOS Workgroup. ; Syntax.........: _GetWorkgroupName() ; Parameters ....: ; Requirement(s).: ; Return values .: Success - Returns the string value of the computer's current NetBIOS Workgroup ; Failure - Returns "MSHOME" and set @Error = 1 ; Author ........: joell ; Modified.......: Authenticity, jscript ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _GetWorkgroupName() ; ================================================================================================================================================================== Func _GetWorkgroupName() Local $NERR, $pBuffer, $sName Local Const $NetSetupUnknownStatus = 0 Local Const $NetSetupUnjoined = 1 Local Const $NetSetupWorkgroupName = 2 Local Const $NetSetupDomainName = 3 $NERR = DllCall("Netapi32.dll", "int", "NetGetJoinInformation", "wstr", @ComputerName, "ptr*", 0, "int*", 0) If @error Then Return SetError(@error, @extended, "") If $NERR[0] = 0 Then $pBuffer = $NERR[2] $sName = DllStructGetData(DllStructCreate("wchar[" & __NetApi_BufferSize($pBuffer) & "]", $pBuffer), 1) __NetApi_BufferFree($pBuffer) EndIf If @error Then Return SetError(@error, @extended, "") Return $sName EndFunc ;==>_GetWorkgroupName ; Authenticity Func __NetApi_BufferSize($pBuffer) Local $aResult = DllCall("Netapi32.dll", "int", "NetApiBufferSize", "ptr", $pBuffer, "uint*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] <> 0 Then Return SetError(-1, $aResult[0], 0) Return $aResult[2] EndFunc ;==>__NetApi_BufferSize ; Authenticity Func __NetApi_BufferFree($pBuffer) Local $aResult = DllCall("Netapi32.dll", "int", "NetApiBufferFree", "ptr", $pBuffer) If @error Then Return SetError(@error, @extended, False) If $aResult[0] <> 0 Then Return SetError(-1, $aResult[0], False) Return SetError(0, 0, True) EndFunc ;==>__NetApi_BufferFreeNeed the below code: _EnvUpdate.au3: #include-once ; #INDEX# ======================================================================================================================= ; Title .........: Environment Update ; AutoIt Version.: 3.2.12++ ; Language.......: English ; Description ...: Refreshes the OS environment. ; Author ........: João Carlos (jscript) ; Support .......: trancexx, PsaltyDS, KaFu ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_EnvUpdate ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== Global $MAX_VALUE_NAME = 1024 Global $HWND_BROADCAST = 0xffff Global $WM_SETTINGCHANGE = 0x001A Global $SMTO_ABORTIFHUNG = 0x0002 Global $SMTO_NORMAL = 0x0000 Global $MSG_TIMEOUT = 5000 ; #Example# ===================================================================================================================== ;_EnvUpdate("VERSION", "7.07.0110.2600") ;MsgBox(4096, @error, EnvGet("VERSION")) ;_EnvUpdate("VERSION", "", True, True) ;MsgBox(4096, @error, EnvGet("VERSION")) ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _EnvUpdate ; Description ...: Refreshes the OS environment. ; Syntax.........: _EnvUpdate( ["envvariable" [, "value" [, CurrentUser [, Machine ]]]] ) ; Parameters ....: envvariable - [optional] Name of the environment variable to set. If no variable, refreshes all variables. ; value - [optional] Value to set the environment variable to. If a value is not used the environment ; variable will be deleted. ; CurrentUser - [optional] Sets the variable in current user environment. ; Machine - [optional] Sets the variable in the machine environment. ; Return values .: Success - None ; Failure - Sets @error to 1. ; Author ........: João Carlos (jscript) ; Support .......: trancexx, PsaltyDS, KaFu ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; _EnvUpdate("TEMP", @SystemDir & "TEMP", True, True) ; =============================================================================================================================== Func _EnvUpdate($sEnvVar = "", $vValue = "", $fCurrentUser = True, $fMachine = False) Local $sREG_TYPE = "REG_SZ", $iRet1, $iRet2 If $sEnvVar <> "" Then If StringInStr($sEnvVar, "\") Then $sREG_TYPE = "REG_EXPAND_SZ" If $vValue <> "" Then If $fCurrentUser Then RegWrite("HKCU\Environment", $sEnvVar, $sREG_TYPE, $vValue) If $fMachine Then RegWrite("HKLM\System\CurrentControlSet\Control\Session Manager\Environment", $sEnvVar, $sREG_TYPE, $vValue) Else If $fCurrentUser Then RegDelete("HKCU\Environment", $sEnvVar) If $fMachine Then RegDelete("HKLM\System\CurrentControlSet\Control\Session Manager\Environment", $sEnvVar) EndIf ; http://msdn.microsoft.com/en-us/library/ms686206%28VS.85%29.aspx $iRet1 = DllCall("Kernel32.dll", "BOOL", "SetEnvironmentVariable", "str", $sEnvVar, "str", $vValue) If $iRet1[0] = 0 Then Return SetError(1) EndIf ; http://msdn.microsoft.com/en-us/library/ms644952%28VS.85%29.aspx $iRet2 = DllCall("user32.dll", "lresult", "SendMessageTimeoutW", _ "hwnd", $HWND_BROADCAST, _ "dword", $WM_SETTINGCHANGE, _ "ptr", 0, _ "wstr", "Environment", _ "dword", $SMTO_ABORTIFHUNG, _ "dword", $MSG_TIMEOUT, _ "dword_ptr*", 0) If $iRet2[0] = 0 Then Return SetError(1) EndFunc ;==>_EnvUpdateSend comments!
    1 point
  49. Remember Matrix? Spoon boy: Do not try and bend the spoon. That's impossible. Instead... only try to realize the truth. Neo: What truth? Spoon boy: There is no spoon. Neo: There is no spoon? Spoon boy: Then you'll see, that it is not the spoon that bends, it is only yourself. Do not try to find .rdata, find "AutoIt v3 GUI" $sCustomParameter = "yehia's class" $sDefaultParameter = "AutoIt v3 GUI" $AutoItBin = FileOpenDialog("Choose file", "", "Autoit compiled script (*.exe)|All files (*)") ConsoleWrite(">Modifying default parameter." & @CRLF) _CustomizeAutoIt3Parameter($AutoItBin, $sDefaultParameter, $sCustomParameter) Switch @error Case 1 ConsoleWrite("- Select different parameter to modify to. Skipping modification." & @CRLF) Case 3 ConsoleWrite("- Default parameter couldn't be located. Skipping modification." & @CRLF) Case 2, 4 ConsoleWrite("- Modifying default parameter cannot proceed. Skipping modification." & @CRLF) Case 5, 6 ConsoleWrite("- Internal error. Skipping default parameter modification." & @CRLF) Case False ConsoleWrite('+>Default parameter successfully modified to: "' & $sCustomParameter & '"' & @CRLF) EndSwitch Func _CustomizeAutoIt3Parameter($AutoItBin, $sDefaultParameter, ByRef $sCustomParameter) If Not $sCustomParameter Or $sCustomParameter == $sDefaultParameter Then Return SetError(1, 0, "") ; $sCustomParameter must be specified and different than original EndIf ; Making sure that $sCustomParameter will be the same size as $sDefaultClass. ; If it's bigger it will be truncated, if smaller anti-truncated (don't know the word) ; Also, converting to UTF16 Little Endian. Local $tCustomParameter = DllStructCreate("byte[" & 2 * StringLen($sDefaultParameter) & "]") DllStructSetData($tCustomParameter, 1, StringToBinary($sCustomParameter, 2)) Local $bCustomParameter = DllStructGetData($tCustomParameter, 1) $sCustomParameter = StringReplace(BinaryToString($bCustomParameter, 2), Chr(0), "") ; will use this to inform about the change after it's done ; Converting $sDefaultParameter to binary (UTF16 Little Endian) Local $bDefaultParameter = StringToBinary($sDefaultParameter, 2) ; reading $AutoItBin, binary mode Local $hBinHandle = FileOpen($AutoItBin, 16) If $hBinHandle = -1 Then Return SetError(2, 0, "") ; $AutoItBin culdn't be opened for reading EndIf Local $bBinary = FileRead($hBinHandle) FileClose($hBinHandle) If StringInStr(BinaryToString($bBinary), BinaryToString("0x497420697320612076696F6C6174696F" & _ "6E206F6620746865204175746F497420" & _ "45554C4120746F20617474656D707420" & _ "746F207265766572736520656E67696E" & _ "65657220746869732070726F6772616D"), 1) Then Exit ConsoleWrite("! Not allowed!!!" & @CRLF); don't be an ass EndIf ; Finding the offset in $AutoItBin where Parameter is written. ; Will use StringInStr() function to find offset after properly convert all binary data to coresponding strings. ; If there is no $sDefaultParameter inside $AutoItBin (no offset) return error. ; Real binary offset is this one minus 1; AutoIt takes offset 0 to be position 1. Local $iOffset = StringInStr(BinaryToString($bBinary), BinaryToString($bDefaultParameter), 1) If Not $iOffset Then Return SetError(3, 0, "") ; For some reason there is no $sDefaultParameter inside $AutoItBin EndIf ; One more checking needs to be done. That is to confirm that $sDefaultParameter is to be found at only one place inside $AutoItBin, ; to avoid possible wrong modification(s). ; Looking for the second occurence of $sDefaultParameter inside $AutoItBin and if found returning error. If StringInStr(BinaryToString($bBinary), BinaryToString($bDefaultParameter), 1, 2) Then Return SetError(4, 0, "") ; Exact unique location of $sDefaultParameter cannot be determined (multiple occurrences) EndIf ; Actual replacing can take place. ; Again using functions that handles strings since there is no binary versions of such. ; Binary data needs to be converted to coresponding strings before replacements. ; StringReplace() returns new string, so converting to new binary data is needed. Local $bBinaryNew = Binary(StringReplace(BinaryToString($bBinary), $iOffset, BinaryToString($bCustomParameter))) ; Will write new data to $AutoItBin now. $hBinHandle = FileOpen($AutoItBin, 18) If @error Then Return SetError(5, 0, "") ; $AutoItBin culdn't be opened for writing EndIf If Not FileWrite($hBinHandle, $bBinaryNew) Then FileClose($hBinHandle) Return SetError(6, 0, "") ; Problem writing. Highly unlikely to happen. EndIf FileClose($hBinHandle) Return SetError(0, 0, 1) ; All done! Return 1, set @error to 0. EndFunc ;==>_CustomizeAutoIt3Parameter There are few things that you should consider. AutoIt EULA strictly forbid any modification of AutoIt3.exe and AutoIt3_x64.exe. AutoIt EULA is also not completely clear about some things, but Jon and devs are lately very clear about compiled scripts not being their property nor responsibility. That would mean you can do what ever you want with them, they are yours if you compiled them.
    1 point
×
×
  • Create New...