-
Posts
3,149 -
Joined
-
Last visited
-
Days Won
7
Reputation Activity
-
jdelaney got a reaction from vergil250493 in Get All Window's Controls
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups).
I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts.
Output can be filtered by:
1) Filter by IsVisible
2) Filter by matching class (ex Button, Label, Static)
3) Filter by containing text
#include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls -
jdelaney got a reaction from Tacomas in Get All Window's Controls
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups).
I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts.
Output can be filtered by:
1) Filter by IsVisible
2) Filter by matching class (ex Button, Label, Static)
3) Filter by containing text
#include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls -
jdelaney got a reaction from KoolDJMic in Searching fields within XML
I'd go this route:
#include <Array.au3> $xml = "<Servers>" & _ "<ServerInfo><Server_Name>MyServerName1</Server_Name><User>user_name1</User><Password>0x8534C1E508D4CF29AC17a</Password></ServerInfo>" & _ "<ServerInfo><Server_Name>MyServerName2</Server_Name><User>user_name2</User><Password>0x8534C1E508D4CF29AC17b</Password></ServerInfo>" & _ "<ServerInfo><Server_Name>MyServerName3</Server_Name><User>user_name3</User><Password>0x8534C1E508D4CF29AC17b</Password></ServerInfo>" & _ "</Servers>" Global Enum $iServerName, $iUser, $iPassword, $iUBound Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.LoadXML($xml) $oServers = $oXML.selectNodes("//ServerInfo") Local $a For $oServer In $oServers If IsArray($a) Then ReDim $a[UBound($a)+1][$iUBound] Else Local $a[1][$iUBound] EndIf $a[UBound($a)-1][$iServerName] = $oServer.selectSingleNode("./Server_Name").text $a[UBound($a)-1][$iUser] = $oServer.selectSingleNode("./User").text $a[UBound($a)-1][$iPassword] = $oServer.selectSingleNode("./Password").text Next _ArrayDisplay($a)
-
jdelaney got a reaction from Danyfirex in Get a value inside nth child in a DOM
You already have a solution, but using an xpath can be like this:
$xpathMonthlyCharges = "//div/label[.='Monthly Charges:']/../div/div"
#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 = False ; 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 $xpathMonthlyCharges = "//div/label[.='Monthly Charges:']/../div/div" ; Create/navigate to page $oIE = _IECreate("",True,True) If IsObj($oIE) Then ConsoleWrite("Able to _IECreate('')" & @CRLF) Else ConsoleWrite("UNable to _IECreate('')" & @CRLF) Exit 1 EndIf _IEBodyWriteHTML($oIE,'<div class="box-header"> <div class="title"> Account Summary </div> </div> <div class="box-content box-overflow-fix"> <div class="form-group"> <label class="col-xs-2 control-label">Previous Account Balance:</label> <div class="col-xs-1"> <div id="previous-account-balance" class="form-control-static currency"> 203.39 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">Monthly Charges:</label> <div class="col-xs-1"> <div class="form-control-static currency"> 87.80 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">One Time Charges:</label> <div class="col-xs-1"> <div class="form-control-static currency"> 0.00 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">Call Usage:</label> <div class="col-xs-1"> <div class="form-control-static currency"> 0.00 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">Hosted Fax Usage:</label> <div class="col-xs-1"> <div class="form-control-static currency"> 0.00 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">Directory Assistance:</label> <div class="col-xs-1"> <div class="form-control-static currency"> 0.00 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">Taxes and Fees:</label> <div class="col-xs-1"> <div id="taxes-fees" class="form-control-static currency"> 5.13 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">Total New Charges - Due 8/30/2022:</label> <div class="col-xs-1"> <div id="total-new-charges" class="form-control-static currency"> 02.93 </div> </div> </div> <div class="form-group"> <label class="col-xs-2 control-label">Total Due:</label> <div class="col-xs-1"> <div id="total-due" class="form-control-static currency"> 306.32 </div> </div> </div> </div> </div>') ; Get Forum Link $aForumLink = BGe_IEGetDOMObjByXPathWithAttributes($oIE,$xpathMonthlyCharges,0) For $i = 0 to UBound($aForumLink)-1 ConsoleWrite("text = " & $aForumLink[$i].innertext & @CRLF) Next _IEQuit($oIE) Exit #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() Do $aReturnObjects = BGe_RecursiveGetObjWithAttributes($oIEObject,$aSplitXpath) Until TimerDiff($iTimer)>$iMaxWait Or IsArray($aReturnObjects) 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 ElseIf $sNodeName = ".." Then $asObjects = BGe_RecursiveGetObjWithAttributes($oParent.parentNode, $aCallersSplitXPath, $asObjects, $Level + 1) 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 consoleoutput:
text = 87.80
-
jdelaney got a reaction from jimmy123j in Get All Window's Controls
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups).
I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts.
Output can be filtered by:
1) Filter by IsVisible
2) Filter by matching class (ex Button, Label, Static)
3) Filter by containing text
#include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls -
jdelaney got a reaction from GoogleDude in How to Generate a Random English Word
try:
$aWords = StringRegExp(FileRead("some.txt"),"(\w+)",3) $sRandom = $aWords[Random(0,UBound($aWords),1)] ConsoleWrite($sRandom & @CRLF) -
jdelaney got a reaction from Arjuntina in Trying to wait for a webpage to load
As long as you loop for whatever object you are attempting to interact with, and not just try to grab it once, and assume you have it, I don't see what the issue is...do this kind of loop with ALL your object grabbing (of course, this is just a sample...add whatever _IE function you need, obviously)
$iTimer = TimerInit() $oObj = _IEGetObjById($oIE, "yourID") While Not IsObj($oObj) And TimerDiff($iTimer)<5000 sleep (100) $oObj = _IEGetObjById($oIE, "yourID") WEnd If IsObj($oObj) Then MsgBox(1,1,"ABLE to grab object within 5 seconds") Else MsgBox(1,1,"unable to grab object within 5 seconds") EndIf then, you can get fancy, and create encapsulating functions for all that you need, so you don't need repeating blocks of code:
Func _WaitFor_IEGetObjById($oCallersIE, $iCallersID, $iCallersMaxWaitMilSec = 5000) ConsoleWrite("Func[_WaitFor_IEGetObjById]: Start with params=[IsObj(" & $oCallersIE & ")," & $iCallersID & "," & $iCallersMaxWaitMilSec & "]." & @CRLF) $iTimer = TimerInit() $oObj = _IEGetObjById($oCallersIE, $iCallersID) While Not IsObj($iObj) And TimerDiff($iTimer) < $iCallersMaxWaitMilSec Sleep(100) $oObj = _IEGetObjById($oCallersIE, $iCallersID) WEnd If IsObj($oObj) Then ConsoleWrite("Func[_WaitFor_IEGetObjById]: Found callers ID=[" & $iCallersID & "]." & @CRLF) Return $oObj Else ConsoleWrite("Func[_WaitFor_IEGetObjById]: UNable to find callers ID=[" & $iCallersID & "] within milliseconds=[" & iCallersMaxWaitMilSec & "]." & @CRLF) Return False EndIf EndFunc ;==>_WaitFor_IEGetObjById you can even make one function...as long as they accept the proper params (or create array to hold the params...then can be any number) AND they do not have by-ref variables:
If $bContinue Then $oObject4 = _WaitFor_IEObj($oIE, "_IEGetObjById", 4) $bContinue = IsObj($oObject4) ; your action EndIf Exit Func _WaitFor_IEObj($oCallersIE, $sCallerIEFuncName, $iCallersIdentifier, $iCallersMaxWaitMilSec = 5000) ConsoleWrite("Func[_WaitFor_IEGetObjById]: Start with params=[IsObj(" & $oCallersIE & ")," & $sCallerIEFuncName & "," & $iCallersIdentifier & "," & $iCallersMaxWaitMilSec & "]" & @CRLF) $iTimer = TimerInit() $oObj = Call($sCallerIEFuncName, $oCallersIE, $iCallersIdentifier) While Not IsObj($oObj) And TimerDiff($iTimer) < $iCallersMaxWaitMilSec Sleep(500) $oObj = Call($sCallerIEFuncName, $oCallersIE, $iCallersIdentifier) WEnd If IsObj($oObj) Then ConsoleWrite("Func[_WaitFor_IEGetObjById]: Found callers ID=[" & $iCallersIdentifier & "]" & @CRLF) Return $oObj Else ConsoleWrite("Func[_WaitFor_IEGetObjById]: UNable to find callers ID=[" & $iCallersIdentifier & "]" & @CRLF) Return False EndIf EndFunc ;==>_WaitFor_IEObj -
jdelaney got a reaction from PHAK in Get All Window's Controls
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups).
I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts.
Output can be filtered by:
1) Filter by IsVisible
2) Filter by matching class (ex Button, Label, Static)
3) Filter by containing text
#include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls -
jdelaney got a reaction from TinyCoopMan in Get All Window's Controls
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups).
I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts.
Output can be filtered by:
1) Filter by IsVisible
2) Filter by matching class (ex Button, Label, Static)
3) Filter by containing text
#include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls -
jdelaney got a reaction from TinyCoopMan in Can I make coordinates relative to a window instead of a screen?
AutoItSetOption("MouseCoordMode",2) for client
AutoItSetOption("MouseCoordMode",0) for window
But a Control based click will be more effective, and doesn't need an X/Y coord at all. ControlClick.
-
jdelaney got a reaction from PoojaKrishna in problem sending Window Handle via pipe
Pass it as a param to the script instead...
then you can convert to hwnd, just like you are doing hwnd()
helpfile: Command Line Parameters
Shows how to send, and then read the params
Run("ConsoleRead.exe " & $sHWnd) ; note the trailing space after .exe
then, in consoleread.exe...
$data = $CmdLine[1] ; of course, it's better to loop through the $CmdLine array, but this is just the simplest sample
$hwnd = hwnd($data)
-
jdelaney got a reaction from markyrocks in Question that is kinda a riddle
Something like this I guess
$a = 3 Local $aArray[1] = ["a"] ConsoleWrite(Eval($aArray[0]) & @CRLF) $a = 6 ConsoleWrite(Eval($aArray[0]) & @CRLF) setAVariable($a, 25) ConsoleWrite(Eval($aArray[0]) & @CRLF) Func setAVariable(ByRef $a, $i) $a = $i EndFunc output
3
6
25
-
jdelaney got a reaction from aart in tiny soduku solver no gui
I scripted mine to screen scrape a sudoku site and automatically solve it:
edit: this is the first iteration of that script that will constantly solve sudoku puzzles, nvermind.
-
jdelaney got a reaction from PilotPen in Get mouse position
try:
#include <array.au3> #include <Misc.au3> While True If _IsPressed(01) Then While _IsPressed(01) WEnd $hTimer = TimerInit() While TimerDiff($hTimer)<500 If _IsPressed(01) Then While _IsPressed(01) WEnd $a = MouseGetPos() _ArrayDisplay($a) ExitLoop EndIf WEnd EndIf WEnd Change 500 to be less time, if half a second is too slow.
-
jdelaney got a reaction from FrancescoDiMuro in (solved) Matching text in control
Example of looping a menu, and looping through a child menu, to get what you need:
#include <GuiMenu.au3> $hwnd = WinGetHandle("[CLASS:Notepad]") WinActivate($hwnd) $hMenu = _GUICtrlMenu_GetMenu($hwnd) $iFile = _GUICtrlMenu_FindItem($hMenu, "File") $hFileMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $iFile) For $i = 0 To _GUICtrlMenu_GetItemCount($hMenu) - 1 ConsoleWrite(_GUICtrlMenu_GetItemText($hMenu,$i) & " " & @error & @CRLF) Next ConsoleWrite($hFileMenu & @CRLF) For $i = 0 To _GUICtrlMenu_GetItemCount($hFileMenu) - 1 ConsoleWrite("text=[" & _GUICtrlMenu_GetItemText($hFileMenu,$i, True) & "] " & @error & @CRLF) Next &File 0
&Edit 0
F&ormat 0
&View 0
&Help 0
0x000E0869
text=[&New Ctrl+N] 0
text=[&Open... Ctrl+O] 0
text=[&Save Ctrl+S] 0
text=[Save &As...] 0
text=[] 0
text=[Page Set&up...] 0
text=[&Print... Ctrl+P] 0
text=[] 0
-
jdelaney got a reaction from RadicalKoncepts in Get All Window's Controls
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups).
I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts.
Output can be filtered by:
1) Filter by IsVisible
2) Filter by matching class (ex Button, Label, Static)
3) Filter by containing text
#include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls -
jdelaney got a reaction from Cooler in How to get instance of a specific Button
provide the output from my the function in my signature
-
jdelaney got a reaction from DaLiMan in IE - Clicking in <SPAN
Loop through _IETagNameGetCollection
$object.className() grabs the class attribute value
or .getAttribute to loop by the other attribute
or .innertext for the text in the span
Then, when found, _ieaction, and exit loop
-
jdelaney got a reaction from AlienStar in Internet explorer doesn't run well in _IECreate with loop
When you close IE it does a bunch of stuff to "clean" itself up, which then makes new instances fail to create. Put error handling and retry loops around _iecreate. our use _ienavigate.
-
jdelaney got a reaction from Earthshine in ControlClick doesn't work
My 2 cents. Use control id rather than instances. Instances change, more frequently than ids. 2: why do you grab the handle to a window and then use a window class to identify the window? if you have the specific handle, use it.
-
jdelaney got a reaction from argumentum in Find control with ID and other property
I have some udf that can do that. I'll upload them tonight. It allows you to find controls with any combination of data points including text, id, class, visibility enabled status, etc.
Note: it does not include logic on instance. Personal preference to never use that property because instances change with business logic in most apps
-
jdelaney got a reaction from AndroidZero in Access Local Scope
Byref parameters or return from functions to variables and pass those to other functions. or don't use local for variables needed globally
-
jdelaney got a reaction from FrancescoDiMuro in How to run scripts on virtual machine independently of guest OS?
Use functions like ControlSetText rather than Send, and ControlClick rather that MouseClick.
Another option, run it on session 0 (where services run) so that it won't interact with your current user session.
Also, if you are only doing file manipulation, just use FileRead and FileWrite.
Using Send and MouseClick will make concurrent running scripts easily conflict with each-other.
-
jdelaney got a reaction from sosimple in Run script every time unlock screen?
There are a ton of options for task outside of just that though. i believe the startup folder is only when you first create a user session and not for subsequent locks and unlocks. but there aredefinitely ways to create tasks on unlock actions for all users (requires admin settings to save)
Triggers:
On connection of user profile
On workstation unlock
those are the ones you should look into. Google them to see if you need both triggers, or just the workstation unlock trigger.
-
jdelaney got a reaction from sosimple in Run script every time unlock screen?
Check out all the options in scheduled tasks. easiest way to do it.