Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/12/2015 in all areas

  1. Make your own version of the UDF. Problem solved.
    3 points
  2. kylomas

    Arrays

    badeend, The two UDF's that you are using require a file path as the first parameter, not a file handle. Some rudimentary error checking goes a long way toward solving these kinds of problems. Each function has clearly defined return codes in the Help file. This is one possible way to do what I think your code was attempting... #include <File.au3> #include <array.au3> Global $vReturn[3] _FileReadToArray(@ScriptDir & "\test.csv", $vReturn, $FRTA_NOCOUNT, ";") ; 1ST parm is file path, not handle ConsoleWrite(@error & @CRLF) ; display return from function _arraydisplay($vReturn) ; display the array If IsArray($vReturn) Then MsgBox(0, "hoera!", "hoera!") EndIf _FileWriteFromArray(@scriptdir & "\output.txt", $vReturn, 0) ; array is 2d with 1 row and three columns ConsoleWrite(@error & @CRLF) ; display return from function ; Display the file. ShellExecute(@scriptdir & "\output.txt") ; file path, not handle for first parm This is the file I used for testing test.csv kylomas
    2 points
  3. ISN AutoIt Studio Version 0.99 BETA is now online! Happy testing! Changelog (translated by google translator): -> ISN AutoIt Studio: <- ----------------------------------- - Fix: Several bugfixes - Fix: When you close a project was produced in error under certain conditions the message that a file in the folder for temporary scripts. This is now fixed. - Bug fix: When using the DBUG tools were often not deleted some temp files. This is now fixed. - Fix: Several bugfixes for the new autocomplete (If -> endif, etc.) - Bugfix: veringert fibrillation the toolbar and the menu bar when switching tabs - Fix: Autocomplete detection improved - Fix: The path to the last open tabs will now be saved in the * .isn file with real tive paths. - Bugfix: syntax update for AutoIt version 3.3.14.1 - NEW: AutoIt3Wrapper, Tidy & Au3Stripper updated to newer versions. - NEW: The project file (project.isn) can now be named anything! (Extension * must .isn naturally preserved! In addition, the file must be in the root directory of the project!) - NEW: When creating a new project, the name can now also directly to the project file (* .isn) be specified. - NEW: "Edit -> Go to function (Ctrl + J)" can now jump directly to the function. (As in the script tree) - NEW: In the program settings under "Script Editor -> File Types" can now any file types are set to be automatically opened with the Script Editor, the ISN. - NEW: New Tag for macros:% myisndatadir% -> Points to the directory by the cache, settings, etc. are stored. (In portable mode is% myisndatadir% =ScriptDir) - NEW: There is now in the program settings the ability more paths for AU3 * api files & * .keywords.properties files indicate... (File Locations -> API files) - NEW: The alphabetical sorting of functions in the script tree can now be disabled. (In the script tree characteristics) - NEW: New macro: Start script -> Starts an AutoIt script in ISN AutoIt Studio (similar to the script function test) -> ISN form Studio 2: <- ----------------------------------- - Fix: Several bugfixes - Bugfix: syntax update for AutoIt version 3.3.14.1 - Fix: Fixed a bug in which was selected in the GUI properties automatically "text from func". - Bug fix: could ComboBoxes often difficult marked with the mouse. This is now fixed. - Fix: Some controls have simply disappeared again after copying. This is now fixed. - Fix: Fixed a bug by the entries could be changed anyway in a locked menu Control. - NEW: The Control Editor in form Studio 2 can now be folded up in the Control Editor or be restored by an icon to the right. (If it is sometimes requires more space quickly.) - NEW: In the GUI properties under "AutoIt code settings" can now be determined whether will be inserted in the script #include one should or not. - NEW: Settings such as "declaration of Handles" can now be obtained from the Global program settings form Studios. - NEW: It can now be selected as Style or States in the AutoIt code be adopted. Either as a variable (eg. $ BS_DEFPUSHBUTTON) or Magic Numer (as before). New default for this setting is the variant with variable. (Because the code is easier to read) The whole can be set in the GUI properties for each .isf or in the program settings Global. - NEW: In Control Editor under "representation" can now be specified with an icon (.ico) and the Index. (If the icon of a .dll is based) - NEW: The loading screen has now been transferred to the GUI of the form Studios. - NEW: It is now possible properties in the Control Editor to change when multiple controls are selected. These are then applied to the Mark Controls.
    2 points
  4. Version 1.2

    29,304 downloads

    I wrote an introductory text for new programmers to learn how to code using AutoIt. It follows along with the help file for the most part – but provides additional context and attempts to connect all the information in a cohesive way for someone without any programming experience. I find the help file to be an AMAZING resource and the text I wrote in no way reflects any opinion to the contrary. Rather, it was created from the perspective of someone who struggled early on with the most basic concepts and thought that a hand-holding guide could be useful. I was also inspired by code.org who is trying to encourage people to learn to code. I thought – what better way than to use free tools that you can download at any time with access to an amazing community? If only there was a guide to walk people through it … Full discussion about the file can be found here: https://www.autoitscript.com/forum/topic/174205-introductory-learn-to-program-text-using-au3/
    1 point
  5. kangkeng

    Image Search Library

    Hi Folks, I'm a great fan of AutoIT. While trying to automate data entry into a java applet based ERP, I found that checking for entry error or success is quite a pain using pixelsearch. Instead, check for a data entry "success" or "failed" image is far simpler. This a feature found in AHK, I've cut out the necessary code and compiled it into a DLL, and written a au3 library around it. I've tested it in various XP and W2k3 machines, and it seems to work fine. It's a quick and dirty hack I did to get a job done, so your mileage may vary ImageSearch.zip (84K) Number of downloads:
    1 point
  6. Not sure if anyone else was ever looking for a way to get the DOM object of IE by the XPath, but i sure was. I Created this UDF... _IEGetDOMObjByXPathWithAttributes Still needs some work, here are the limitations: Solved: 1) no distinction between // and /, all are handled as // ...Won't address, use syntax like #3: 2) only able to search for Elements, can't end the xpath in an attribute, such as ...//@id='test' Solved: 3) When searching for only Elements with specific attributes, I'm only handling any number of condition, such as //test[@id="test2"] Solved: 4) use of contains() now 5) No use of strucutes, such as :Parent, or :Sibling 6) Solved * due to number 1, it's possible to return the same object mutliple times...that'll be the first correction Edit: This can still occur if using xpath provided leaves mutliple paths to the specific element...make xpath more specific to stop 7) No use of enumerated nodes...such as //test[4] 8) No use of <> when defining attributes //test[@id<>"test2"] So it's very simple, but returns an array of all objects matching the xpath provided...example xpaths to search for on the google home page: "//td[@id='gs_tti0']/div/input[@id='gbqfq']" this gives object of the search input #region SCITE_CallTipsForFunctions ;BGe_IEGetDOMObjByXPathWithAttributes($oIEObj, $sXPath, [$iMaxWait=2000]) Return array of objects on browser matching callers xpath #endregion SCITE_CallTipsForFunctions #include <ie.au3> #include <array.au3> #region GLOBALVariables Global $gbBGe_PerformConsoleWrites = True ; The XPath array to work with will be 2d, with the following Global Enum $giBGe_XPath_Dim2_sRawNode, _ $giBGe_XPath_Dim2_sNodeName, _ $giBGe_XPath_Dim2_bNodeIsRelative, _ $giBGe_XPath_Dim2_sRawNodeConstraints, _ $giBGe_XPath_Dim2_bIsConstrainted, _ $giBGe_XPath_Dim2_aNodeConstraints, _ $giBGe_XPath_Dim2_UBound ; $giBGe_XPath_Dim2_aNodeConstraints will contain a 2d, with the following Global Enum $giBGe_Constraint_Dim2_sNodeName, _ $giBGe_Constraint_Dim2_bIsAttribute, _ $giBGe_Constraint_Dim2_bIsSelf, _ $giBGe_Constraint_Dim2_sNodeValue, _ $giBGe_Constraint_Dim2_bIsContains, _ $giBGe_Constraint_Dim2_UBound ; Regexp to split xpath Global $gsBGe_RegExpNodeSplit = "(?U)(.*(?:['""].*['""].*){0,})(?:\/)" ; Split Xpath into nodes...split by / where it is part of x-path Global $gsBGe_RegExpNodeAndCondSplit = "([^\[\]]+)\[(.*)\]" ; Get node name and conditions...conditions can be empty Global $gsBGe_RegExpOrSplit = "(?i)(?U)(.*['""].*['""\)])(?:\sor\s)|.{1,}?" ; Split Or statements inside [] Global $gsBGe_RegExpAndSplit = "(?i)(?U)(.*['""].*['""\)])(?:\sand\s)|.{1,}?" ; Split And statements inside [] Global $gsBGe_RegExpSplitContains = "(?i)contains\s*\(\s*(.+)\s*,\s*['""](.+)['""]\s*\)" ; Split contains, remove spaces that are not needed Global $gsBGe_RegExpSplitNonContains = "(.*)\s*\=\s*['""](.*)['""]" ; Split constraint that is not a contains, remove spaces that are not needed #endregion GLOBALVariables #region SAMPLE ; Using multiple levels as an example...made comples on purpose to demonstrate...: $xpathForumLink = "//div[@id='top-menu']/ul[contains(@class,'WONT BE FOUND') or @id='menu-mainmenu']//a[contains(@href,'forum')]" $xpathGeneralHelpSuprt = "//table[contains(@class,'table') and @summary='Forums within the category 'AutoIt v3'']//h4/a[@title='General Help and Support']" $xpathGeneralHelpUsers = "//div[@id='forum_active_users']//span[@itemprop='name']" ; Create/navigate to page $oIE = _IECreate("http://www.autoitscript.com/site/",True,True) If IsObj($oIE) Then ConsoleWrite("Able to _IECreate('http://www.autoitscript.com/site/')" & @CRLF) Else ConsoleWrite("UNable to _IECreate('http://www.autoitscript.com/site/')" & @CRLF) Exit 1 EndIf ; Get Forum Link $aForumLink = BGe_IEGetDOMObjByXPathWithAttributes($oIE,$xpathForumLink) If IsArray($aForumLink) Then ConsoleWrite("Able to BGe_IEGetDOMObjByXPathWithAttributes($oIE, " & $xpathForumLink & ")" & @CRLF) For $i = 0 To UBound($aForumLink)-1 ConsoleWrite(" " & $aForumLink[$i].outerhtml ) Next Else ConsoleWrite("UNable to BGe_IEGetDOMObjByXPathWithAttributes($oIE, " & $xpathForumLink & ")" & @CRLF) Exit 2 EndIf ; Click the link _IEAction($aForumLink[0], "focus") If _IEAction($aForumLink[0], "click") Then ConsoleWrite("Able to _IEAction($aForumLink[0], 'click')" & @CRLF) _IELoadWait($oIE) Else ConsoleWrite("UNable to _IEAction($aForumLink[0], 'click')" & @CRLF) Exit 3 EndIf ; Get General help link $aGenHelpLink = BGe_IEGetDOMObjByXPathWithAttributes($oIE,$xpathGeneralHelpSuprt) If IsArray($aGenHelpLink) Then ConsoleWrite("Able to BGe_IEGetDOMObjByXPathWithAttributes($oIE, " & $xpathGeneralHelpSuprt & ")" & @CRLF) For $i = 0 To UBound($aGenHelpLink)-1 ConsoleWrite(" " & $aGenHelpLink[$i].outerhtml ) Next Else ConsoleWrite("UNable to BGe_IEGetDOMObjByXPathWithAttributes($oIE, " & $xpathGeneralHelpSuprt & ")" & @CRLF) Exit 4 EndIf ; Click the link _IEAction($aGenHelpLink[0], "focus") If _IEAction($aGenHelpLink[0], "click") Then ConsoleWrite("Able to _IEAction($aGenHelpLink[0], 'click')" & @CRLF) _IELoadWait($oIE) Else ConsoleWrite("UNable to _IEAction($aGenHelpLink[0], 'click')" & @CRLF) Exit 5 EndIf ; Get current users on page $aGenHelpUsers = BGe_IEGetDOMObjByXPathWithAttributes($oIE,$xpathGeneralHelpUsers) If IsArray($aGenHelpUsers) Then ConsoleWrite("Able to BGe_IEGetDOMObjByXPathWithAttributes($oIE, " & $xpathGeneralHelpSuprt & ")" & @CRLF) For $i = 0 To UBound($aGenHelpUsers)-1 ConsoleWrite(" " & $aGenHelpUsers[$i].outerhtml & @CRLF ) ConsoleWrite(" " & $aGenHelpUsers[$i].innertext & @CRLF ) Next Else ConsoleWrite("UNable to BGe_IEGetDOMObjByXPathWithAttributes($oIE, " & $xpathGeneralHelpSuprt & ")" & @CRLF) Exit 6 EndIf #endregion SAMPLE #region ExternalFunctions Func BGe_IEGetDOMObjByXPathWithAttributes($oIEObject, $sXPath, $iMaxWait=2000) ; Get dom object by XPath If $gbBGe_PerformConsoleWrites Then ConsoleWrite("Start Function=[BGe_IEGetDOMObjByXPathWithAttributes] with $sXPath=[" & $sXPath & "]." & @CRLF) Local $aReturnObjects = "" Local $aSplitXpath = BGe_ParseXPath($sXPath) If Not IsArray($aSplitXpath) Then ConsoleWrite("BGe_IEGetDOMObjByXPathWithAttributes: Callers XPath/Node/Conditions not well formed=[" & $sXPath & "]" & @CRLF) Return SetError(1,0,False) EndIf Local $iTimer = TimerInit() While TimerDiff($iTimer)<$iMaxWait And Not IsArray($aReturnObjects) $aReturnObjects = BGe_RecursiveGetObjWithAttributes($oIEObject,$aSplitXpath) WEnd Return $aReturnObjects EndFunc ;==>BGe_IEGetDOMObjByXPathWithAttributes #endregion ExternalFunctions #region InternalFunctions Func BGe_RecursiveGetObjWithAttributes($oParent, $aCallersSplitXPath, $asHolder="", $Level=0) $asObjects = $asHolder Local $sNodeName = $aCallersSplitXPath[$Level][$giBGe_XPath_Dim2_sNodeName] Local $bNodeIsRelative = $aCallersSplitXPath[$Level][$giBGe_XPath_Dim2_bNodeIsRelative] ; true=relative false=absolute Local $bIsConstrainted = $aCallersSplitXPath[$Level][$giBGe_XPath_Dim2_bIsConstrainted] ; array[OR] of arrays[AND]; all constraints on the node Local $aNodeOrConstraints = $aCallersSplitXPath[$Level][$giBGe_XPath_Dim2_aNodeConstraints] ; array[OR] of arrays[AND]; all constraints on the node Local $aPossibleNodeMatch = "" If $gbBGe_PerformConsoleWrites Then ConsoleWrite("Start Function=[BGe_RecursiveGetObjWithAttributes] level=[" & $Level & "]: $sNodeName=[" & $sNodeName & "], $bNodeIsRelative=[" & $bNodeIsRelative & "] $bIsConstrainted=[" & $bIsConstrainted & "]."& @CRLF) If Not IsObj($oParent) Then Return $asObjects ; Get nodes that match If $bNodeIsRelative Then If $sNodeName = "*" Then $oPossibleNodes = _IETagNameAllGetCollection($oParent) Else $oPossibleNodes = _IETagNameGetCollection($oParent, $sNodeName) EndIf For $oPossibleNode In $oPossibleNodes If $oPossibleNode.NodeType == 1 Then ; only add nodes If IsArray($aPossibleNodeMatch) Then _ArrayAdd($aPossibleNodeMatch,$oPossibleNode) Else Local $aPossibleNodeMatch[1] = [$oPossibleNode] EndIf EndIf Next Else $oPossibleNodes = $oParent.childnodes For $oPossibleNode In $oPossibleNodes If String($oPossibleNode.NodeName) = $sNodeName Or $sNodeName = "*" Then If IsArray($aPossibleNodeMatch) Then _ArrayAdd($aPossibleNodeMatch,$oPossibleNode) Else Local $aPossibleNodeMatch[1] = [$oPossibleNode] EndIf EndIf Next EndIf ; Loop through nodes against restraints If IsArray($aPossibleNodeMatch) Then For $iChild = 0 To UBound($aPossibleNodeMatch) - 1 Local $oChild = $aPossibleNodeMatch[$iChild] ; Find matching conditions, when necessary If $bIsConstrainted Then ; Loop through OR Conditions For $i = 0 To UBound($aNodeOrConstraints) - 1 Local $aNodeAndConstraints = $aNodeOrConstraints[$i] Local $bAndConditionsMet = True ; Loop through And Conditions, or conditions are outside of this loop, and will go if current and's are not met For $j = 0 To UBound($aNodeAndConstraints) - 1 ; Remove the @... Local $sConstraintName = StringReplace($aNodeAndConstraints[$j][$giBGe_Constraint_Dim2_sNodeName],"@","") Local $bConstraintIsAtt = $aNodeAndConstraints[$j][$giBGe_Constraint_Dim2_bIsAttribute] Local $bConstraintIsNode = $aNodeAndConstraints[$j][$giBGe_Constraint_Dim2_bIsSelf] Local $sConstraintValue = $aNodeAndConstraints[$j][$giBGe_Constraint_Dim2_sNodeValue] Local $bConstraintIsContains= $aNodeAndConstraints[$j][$giBGe_Constraint_Dim2_bIsContains] If $bConstraintIsNode Then If $bConstraintIsContains Then If Not StringInStr(String($oChild.innertext), $sConstraintValue) Then $bAndConditionsMet = False Else If String($oChild.innertext) <> $sConstraintValue Then $bAndConditionsMet = False EndIf ElseIf $bConstraintIsAtt Then Local $sAttributeValue = "" Switch $sConstraintName Case "class" $sAttributeValue = $oChild.className() Case "style" $sAttributeValue = $oChild.style.csstext Case "onclick" $sAttributeValue = $oChild.getAttributeNode($sConstraintName).value Case Else $sAttributeValue = $oChild.getAttribute($sConstraintName) EndSwitch If $bConstraintIsContains Then If Not StringInStr(String($sAttributeValue), $sConstraintValue) Then $bAndConditionsMet = False Else If String($sAttributeValue) <> $sConstraintValue Then $bAndConditionsMet = False EndIf Else ; failure EndIf ; Skip looping if a condition of the And array was not met If Not $bAndConditionsMet Then ExitLoop Next If $bAndConditionsMet Then ; If last level, add the object If $Level = UBound($aCallersSplitXPath) - 1 Then If Not IsArray($asObjects) Then Local $asObjects[1]=[$oChild] Else $bUnique = True ; Only add if not present in the array For $iObject = 0 To UBound($asObjects)-1 If $oChild = $asObjects[$iObject] Then $bUnique=False ExitLoop EndIf Next If $bUnique Then _ArrayAdd($asObjects, $oChild) EndIf Else $asObjects = BGe_RecursiveGetObjWithAttributes($oChild, $aCallersSplitXPath, $asObjects, $Level + 1) EndIf EndIf ; No need to loop additional or if already found one and If $bAndConditionsMet Then ExitLoop Next Else ; No constraints, match is implied If $Level = UBound($aCallersSplitXPath) - 1 Then ; Final xpath level, so add to final array If Not IsArray($asObjects) Then Local $asObjects[1]=[$oChild] Else Local $bUnique=True ; Only add if not present in the array For $iObject = 0 To UBound($asObjects)-1 If $oChild = $asObjects[$iObject] Then $bUnique=False ExitLoop EndIf Next If $bUnique Then _ArrayAdd($asObjects, $oChild) EndIf Else ; Continue Recurssion $asObjects = BGe_RecursiveGetObjWithAttributes($oChild, $aCallersSplitXPath, $asObjects, $Level + 1) EndIf EndIf Next EndIf Return $asObjects EndFunc ;==>BGe_RecursiveGetObjWithAttributes Func BGe_ParseXPath($sCallersXPath) ; RegExp require a trailing "/" $sCallersXPath &= "/" Local $aReturnParsedXPath=False ; Parse all the '/' outside of single, or double, quotes Local $aNodesWithQualifiers = StringRegExp($sCallersXPath,$gsBGe_RegExpNodeSplit,3) ; Loop through, and determine if the node is direct, or relative.../ vs // Local $iSlashCount = 0 For $i = 0 To UBound($aNodesWithQualifiers) - 1 If StringLen($aNodesWithQualifiers[$i])=0 Then $iSlashCount+=1 Else ; Add dimentions to the return array If Not IsArray($aReturnParsedXPath) Then Local $aReturnParsedXPath[1][$giBGe_XPath_Dim2_UBound] Else ReDim $aReturnParsedXPath[UBound($aReturnParsedXPath)+1][$giBGe_XPath_Dim2_UBound] EndIf $aReturnParsedXPath[UBound($aReturnParsedXPath)-1][$giBGe_XPath_Dim2_sRawNode] = $aNodesWithQualifiers[$i] ; Split current Node Local $aSplitNodeAndCond = StringRegExp($aNodesWithQualifiers[$i],$gsBGe_RegExpNodeAndCondSplit,3) If UBound($aSplitNodeAndCond) = 2 Then Local $sNodeName = $aSplitNodeAndCond[0] Local $sNodeConstraints = $aSplitNodeAndCond[1] $aNodeConstraints = BGe_ParseXPathConstraints($sNodeConstraints) If Not IsArray($aNodeConstraints) Then ConsoleWrite("ParseXPath: Callers XPath/Node/Conditions not well formed=[" & $aNodesWithQualifiers[$i] & "]" & @CRLF) Return SetError(1,1,False) EndIf ElseIf UBound($aSplitNodeAndCond) = 0 Then Local $sNodeName = $aNodesWithQualifiers[$i] Local $sNodeConstraints = "" Local $aNodeConstraints = "" Else ConsoleWrite("ParseXPath: Callers XPath/Node/Conditions not well formed=[" & $aNodesWithQualifiers[$i] & "]" & @CRLF) Return SetError(1,2,False) EndIf $aReturnParsedXPath[UBound($aReturnParsedXPath)-1][$giBGe_XPath_Dim2_sNodeName] = $sNodeName $aReturnParsedXPath[UBound($aReturnParsedXPath)-1][$giBGe_XPath_Dim2_sRawNodeConstraints] = $sNodeConstraints $aReturnParsedXPath[UBound($aReturnParsedXPath)-1][$giBGe_XPath_Dim2_bIsConstrainted] = (StringLen($sNodeConstraints)>0) $aReturnParsedXPath[UBound($aReturnParsedXPath)-1][$giBGe_XPath_Dim2_aNodeConstraints] = $aNodeConstraints $aReturnParsedXPath[UBound($aReturnParsedXPath)-1][$giBGe_XPath_Dim2_bNodeIsRelative] = $iSlashCount>1 $iSlashCount=1 EndIf Next Return $aReturnParsedXPath EndFunc Func BGe_ParseXPathConstraints($sCallersXPathConstraints) ; Returns array of arrays ; Array is split of all 'or' statements, and then includes array of 'and' statements, which are split out into 2d array of name/value/bcontains Local $aReturnParsedXPathConstraints[1] ; Will always return at least the first condition Local $aOrQualifiers = StringRegExp($sCallersXPathConstraints,$gsBGe_RegExpOrSplit,3) ReDim $aReturnParsedXPathConstraints[UBound($aOrQualifiers)] For $i = 0 To UBound($aReturnParsedXPathConstraints)-1 Local $aAndQualifiers = StringRegExp($aOrQualifiers[$i],$gsBGe_RegExpAndSplit,3) Local $aaSplitQualitfiers = BGe_ParseXPathConstraint($aAndQualifiers) If IsArray($aaSplitQualitfiers) Then $aReturnParsedXPathConstraints[$i]=$aaSplitQualitfiers Else ConsoleWrite("ParseXPathConstraints: Callers XPath/Node/Conditions not well formed=[" & $aOrQualifiers[$i] & "]" & @CRLF) Return SetError(1,3,False) EndIf Next Return $aReturnParsedXPathConstraints EndFunc Func BGe_ParseXPathConstraint($aCallersXPathConstraint) Local $aReturnParsedXPathConstraints[UBound($aCallersXPathConstraint)][$giBGe_Constraint_Dim2_UBound] For $i = 0 To UBound($aCallersXPathConstraint)-1 ; Remove leading and trailing spaces Local $sCurrentConstraint = StringStripWS($aCallersXPathConstraint[$i], 3) ; Check if $sCurrentConstraint makes use of contains() Local $aTempContains = StringRegExp($sCurrentConstraint,$gsBGe_RegExpSplitContains,3) Local $aTempNonContains = StringRegExp($sCurrentConstraint,$gsBGe_RegExpSplitNonContains,3) If UBound($aTempContains)=2 Then $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_bIsContains] = True $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_bIsSelf] = ($aTempContains[0]=".") $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_sNodeName] = $aTempContains[0] $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_bIsAttribute] = (StringLeft($aTempContains[0],1)="@") $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_sNodeValue] = $aTempContains[1] ElseIf UBound($aTempNonContains)=2 And Not StringInStr($aTempNonContains[0],"(") Then $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_bIsContains] = False $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_bIsSelf] = ($aTempNonContains[0]=".") $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_sNodeName] = $aTempNonContains[0] $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_bIsAttribute] = (StringLeft($aTempNonContains[0],1)="@") $aReturnParsedXPathConstraints[$i][$giBGe_Constraint_Dim2_sNodeValue] = $aTempNonContains[1] Else ConsoleWrite("ParseXPathConstraint: Callers XPath/Node/Conditions not well formed=[" & $aCallersXPathConstraint[$i] & "]" & @CRLF) Return SetError(1,4,False) EndIf Next Return $aReturnParsedXPathConstraints EndFunc #endregion InternalFunctions Edit 08/12/2015...navigate here to get new functionality which allows for specific types of predicates:
    1 point
  7. JohnOne

    Arrays

    ShellExecute($file3)
    1 point
  8. Hello, I am a little confused why most of the Functions in Color.au3 use arrays to get color values ? I think its burden to create an array every time if you want something like a COLORREF value, Lets take _ColorSetCOLORREF as an example, I modified the function to take normal parameters instead of an array: Func _ColorSetCOLORREF($iRed, $iGreen, $iBlue, Const $_iCurrentExtended = @extended) Local $aColor[3] = [$iRed, $iGreen, $iBlue] ; Replaced the array check with an array declaration Local $iColor = 0, $iColorI For $i = 2 To 0 Step -1 $iColor = BitShift($iColor, -8) $iColorI = $aColor[$i] If $iColorI < 0 Or $iColorI > 255 Then Return SetError(2, $i, -1) ; invalid color value $iColor += $iColorI Next Return SetExtended($_iCurrentExtended, $iColor) EndFunc ;==>_ColorSetCOLORREFIt works fine & the array gets deleted when the function returns, so a Win-Win for me... Is there any special reason about accepting an array instead of individual parameters ? Thanks in Advance, TD
    1 point
  9. User751139, Delighted I could help - but my wife insists that a simple "thanks" would have sufficed. M23
    1 point
  10. You are welcome. My friend.
    1 point
  11. This should give you the idea: $str = '"One of the holiday is sunday for this week." ... and today is not sunDay (but I love Sundays even if today is not sunday!)' $s = "SuNDay" ConsoleWrite($str & @LF) $res = StringRegExpReplace($str, '".*?"', "") ; removes anything inside pair of double quotes ConsoleWrite($res & @LF) $res = StringRegExpReplace($res, '(?i)\b' & $s & '(?![[:alnum:]])', '###') ; replaces $s by ### ConsoleWrite($res & @LF)You can use this site to play with Perl (PCRE) regexp.
    1 point
  12. I agree, the array parameter is weird. And furthermore, so is the undocumented good for nothing optional parameter.
    1 point
  13. Processing speed depends on the encryption algorithm you use. Check the _Crypt* functions for encrypting a file.
    1 point
  14. @TheDcoder, maybe you shouldn't keep color components in separate variables. =) How did you even end up with them as 3 separate values? TRWTF is lack of inline array declaration. But. Nothing that can't be solved with a little helper method. #include <Color.au3> Local $red = 0xFF, $green = 0x00, $blue = 0xFF _ColorSetCOLORREF(Color($red, $green, $blue)) Func Color($red, $green, $blue) Local $ret[3] = [$red, $green, $blue] Return $ret EndFuncCall it Color. RGB. Maybe even C or A. Whatever.
    1 point
  15. Just came across this library on GitHub and just thought how awesome it was that I had to tell the community. PHPJS: https://github.com/kvz/phpjs
    1 point
  16. orbs

    get Windows version info

    HEADS UP! Windows 10 RTM returns 6.3, not 10.0 as expected. Microsoft, for their own reasons, chose to cripple this entry in the registry. do NOT use this function for Windows 10. instead, an alternative method was suggested by all-mighty KaFu here: EDIT: the rest of the said registry branch still contains relevant information. it seems that only the CurrentVersion value is crippled.
    1 point
  17. 1 point
  18. http://www.regular-expressions.info/tutorial.html
    1 point
  19. OK #Include <Array.au3> $source = BinaryToString(InetRead("http://www.hearthhead.com/card=374/ragnaros-the-firelord")) $res = StringRegExp($source, '(?s)^|(?:cardsoundlink.*?<i>([^<]+))+', 3) $res[0] = StringRegExpReplace($source, '(?s).*?<title>(.*?)\h*-\h*Card.*', "$1") _ArrayDisplay($res)Using ^| in the first regex is a way to ensure that index [0] in the resulting array $res is set aside and empty Then this $res[0] is filled with the result of the SREReplace The srer is easy to understand : "keep all chars (lazy) after the first '<title>' found, up to a sequence 'space(s)-hyphen-space(s)-Card' "
    1 point
  20. Well if you're busy then my advice is wait until you're not.The forum shouldn't be a substitute for asking questions simply because of laziness or being "busy". Use it as a tool and don't abuse it. I like to give people the benefit of the doubt and will often help if someone shows effort in the subject they're stuck on. You're only asking questions and I have yet to see any physical evidence of what that effort has led you to. If you want me to write a tutorial, then at least be honest. If you do, then I would expect some code in return.
    1 point
  21. "Send" keystrokes worked into XP CMD windows, but injecting keystrokes into console apps is now blocked by Microsoft, and has been since 2008R2: http://blogs.technet.com/b/askperf/archive/2009/10/05/windows-7-windows-server-2008-r2-console-host.aspx This was a nasty shock for me when I developed a large testing app in XP and it did not work in the 2008R2 deployment environment. However, I found that you can redirect input. My particular use cases required specific, predictable keystrokes to start command line apps and provide command line inputs, so I created text files and started my CMD windows with the input redirected from the text file. This works fine but you have to know the entire input session from beginning to end for this to work, as you can't modify the input files once the session has begun. If you want to start a CMD and inject commands on-the-fly, then you will have to do something tricky, such as start a CMD window with a BAT file that checks another BAT file at intervals, and executes the commands in there.
    1 point
  22. The easiest way is to show the hidden window, capture it and then hide again.
    1 point
  23. Although I agree with guinness that nothing broadens one's programming perspective more than engaging with a new language, there's also plenty of scope for developing "advanced" programming skills within pure AutoIt. A few suggestions: Study the various AutoIt games people have posted. Figure out how the algorithms subdivide into regions that handle work environment (e.g., moving sprites, collision physics, sounds), user events, and artifcial intelligence). Then build your own 2D platformer.Hook up the irrlicht 3D rendering engine. play with over one hundred examples, then write your own 3D graphics animation. Not challenging enough? Make it real-time user-interactive. Check out the irrlicht tutorials too.Figure out how scripts might communicate with each other when running on the same machine. How about on different machines on the same (W)LAN network? How about halfway across the world? Instead of sending TCP packets with triple handshake, can you use UDP streaming instead? How about encryption to protect the content?Turn your laptop into a burglar alarm; whenever a sound is detected it starts recording video and audio, and sends an email or SMS to your mobile that someone may be in your roomLike music? Get the BASS environment, and mabe develop your own audio visualisation like this one, or explore MIDI , maybe to control your own synthesizer or sequencer software. Check out czardas's various contributions that mix maths and music.Open the Help, and navigate to _WinAPI Management or _WinAPIEx Reference, and study the different subtopics to check what might interest you. This is like looking under the hood of the Windows Operating System engine. Some of these functions are barely documented, yet some are very powerful. Look them up on MSDN, and imagine how they could be used. Check out the many contributions by Ascend4nt; there's an entire universe of low-level features that beckon to be explored.The key ingredient here is motivation. You'll need tons of it, because when you're pushing yourself and your scripts beyond your comfort zone, you're going to spend a lot of time (months) just figuring out why the sections you copied from various other threads don't play nice together, let alone how your own code is going to work. So choose a topic you really like, or an application that you (and/or other people) really need, or that would save you loads of time, or one that is simply lacking and incredibly cool to look at, to listen to, to play with, or to share with your friends. So spend several days just exploring the Example Scripts forum to see what is out there. People have shared some amazing scripts on this site, so be inspired and learn from it (and always acknowledge your sources!) Start small. Don't expect your voice-activated 3D chess-playing supermodel simulation to be able to also control your coffee machine and answer your personal emails. Best of luck, be productive, and if it;s cool in any way, shape, or form, please share what you make.
    1 point
  24. Enum all the children of the Shell_TrayWnd class, store them in an array, hide them all, then return them all from the array when you're ready. Or you can cheat and hope this never fails: #include <WinAPI.au3> __myTaskHS(True) Sleep(3000) __myTaskHS(False) Func __myTaskHS($f_hide = False) Local $h_task = WinGetHandle("[CLASS:Shell_TrayWnd]") If Not $h_task Then Return SetError(1, 0, 0) Local $h_start = 0 Local $a_wlist = WinList("[CLASS:Button]") If Not IsArray($a_wlist) Then Return SetError(2, 0, 0) For $iwin = 1 To $a_wlist[0][0] If _WinAPI_GetParent($a_wlist[$iwin][1]) = $h_task Then $h_start = $a_wlist[$iwin][1] ExitLoop EndIf Next If Not $h_start Then Return SetError(3, 0, 0) If $f_hide Then _WinAPI_ShowWindow($h_start, @SW_HIDE) _WinAPI_ShowWindow($h_task, @SW_HIDE) Else _WinAPI_ShowWindow($h_start, @SW_SHOW) _WinAPI_ShowWindow($h_task, @SW_SHOW) EndIf EndFunc
    1 point
×
×
  • Create New...