Leaderboard
Popular Content
Showing content with the highest reputation on 02/20/2019 in all areas
-
get LegacyAccessibleName from item in TreeView. UIAutomation
FordsFinest reacted to LarsJ for a topic
You're welcome. There will be a major update of UIASpy in the weekend. The new version is much better than the old one. Don't miss it.1 point -
$aArray = _FileListToArrayRec($sAutoItDir, "*.url||MSN*;*.url||Microsoft*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Try this, no tested1 point
-
$aArray = _FileListToArrayRec($sAutoItDir, "*.url||MSN*;Microsoft*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)1 point
-
get LegacyAccessibleName from item in TreeView. UIAutomation
LarsJ reacted to FordsFinest for a topic
Man...I can't express my gratitude enough. It worked great! I used StringInStr to check the items in the array and then _GUICtrlTreeView_ClickItem... I'm not sure why I was having the previous trouble. I used UIA to select an item, but once I invoked a button to "Set Sample Size", it brought up a menu for the wrong tree item. Everything in the UIASpy said it the correct tree item was selected, focused, etc, matching exactly as if I had clicked the tree item with my own mouse. But still the issue was occurring. But this works great and i'll be using it for many other things now too!1 point -
Executable file suddenly can't execute?
FrancescoDiMuro reacted to user4157124 for a topic
"... my computer has no AntiVirus ... its just come with Windows Defender Security Center." Windows Defender is an anti virus product.1 point -
Running PowerShell from Autoit doesn't always work
PawelD reacted to JLogan3o13 for a topic
Without seeing the PS code it is a bit difficult to troubleshoot. Hard coding the domain creds in an AutoIt script is not exactly secure, however. You would probably be better off simply creating an encrypted key ahead of time and then calling it in your PS Script. You could do something like this to create your key: # Prompt you to enter the username and password $credObject = Get-Credential # The credObject now holds the password in a ‘securestring’ format $passwordSecureString = $credObject.password # Define a location to store the AESKey $AESKeyFilePath = “MyPath\aeskey.txt” # Define a location to store the file that hosts the encrypted password $credentialFilePath = “MyPath\credpassword.txt” # Generate a random AES Encryption Key. $AESKey = New-Object Byte[] 32 [Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($AESKey) # Store the AESKey into a file. ACL on the file to allow only select people to read Set-Content $AESKeyFilePath $AESKey # Any existing AES Key file will be overwritten $password = $passwordSecureString | ConvertFrom-SecureString -Key $AESKey Add-Content $credentialFilePath $password You can then call it in your script or through a module like so: #Path to AES Key $AESKeyFilePath = 'MyPath\aeskey.txt' #Path to Secure File $SecurePwdFilePath = 'MyPath\credpassword.txt' #User account login $userUPN = "Domain\Admin" #use key and password to create local secure password $AESKey = Get-Content -Path $AESKeyFilePath $pwdTxt = Get-Content -Path $SecurePwdFilePath $securePass = $pwdTxt | ConvertTo-SecureString -Key $AESKey #create a new psCredential object with required username and password $creds = New-Object System.Management.Automation.PSCredential($userUPN, $securePass) The important thing is, once you create the AES key and Secure Password files, change the ACLs immediately so that only the script can read them.1 point -
Outlook Automation - (Moved)
Earthshine reacted to water for a topic
Or have a look at my signture And don't forget to check the AutoIt wiki1 point -
How can I filter and see only the posts I have clicked on "like" on? thanks1 point
-
get LegacyAccessibleName from item in TreeView. UIAutomation
FordsFinest reacted to LarsJ for a topic
I think it's fine to continue this thread. I'm not quite sure if you can blame the UIA-code for the inconsistency, though it may be convenient. You can load all Plant childs into an array ($aChilds) this way: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find "Reporting Client - Perceptron - Navigation" window --- ConsoleWrite( "--- Find ""Reporting Client - Perceptron - Navigation"" window ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Reporting Client - Perceptron - Navigation window", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find treeview --- ConsoleWrite( "--- Find treeview ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "SysTreeView32", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pTree1, $oTree1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition1, $pTree1 ) $oTree1 = ObjCreateInterface( $pTree1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oTree1 ) Then Return ConsoleWrite( "$oTree1 ERR" & @CRLF ) ConsoleWrite( "$oTree1 OK" & @CRLF ) ; --- Find Plant item --- ConsoleWrite( "--- Find Plant item ---" & @CRLF ) Local $pCondition2, $pCondition3, $pAndCondition3 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TreeItemControlTypeId, $pCondition2 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Plant", $pCondition3 ) ; <<<<<<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition3 OK" & @CRLF ) Local $pPlantItem, $oPlantItem $oTree1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pPlantItem ) $oPlantItem = ObjCreateInterface( $pPlantItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oPlantItem ) Then Return ConsoleWrite( "$oPlantItem ERR" & @CRLF ) ConsoleWrite( "$oPlantItem OK" & @CRLF ) ; --- Plant childs --- ConsoleWrite( "--- Plant childs ---" & @CRLF ) Local $pCondition4 $oUIAutomation.CreateTrueCondition( $pCondition4 ) If Not $pCondition4 Then Return ConsoleWrite( "$pCondition4 ERR" & @CRLF ) ConsoleWrite( "$pCondition4 OK" & @CRLF ) Local $pChilds $oPlantItem.FindAll( $TreeScope_Children, $pCondition4, $pChilds ) ; Childs only If Not $pChilds Then Return ConsoleWrite( "$pChilds ERR" & @CRLF ) ConsoleWrite( "$pChilds OK" & @CRLF ) Local $oAutomationElementArray, $iChilds $oAutomationElementArray = ObjCreateInterFace( $pChilds, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oAutomationElementArray.Length( $iChilds ) If Not $iChilds Then Return ConsoleWrite( "$iChilds ERR" & @CRLF ) ConsoleWrite( "$iChilds = " & $iChilds & @CRLF ) ConsoleWrite( "$iChilds OK" & @CRLF ) Local $pTVitem, $oTVitem Local $aChilds[$iChilds] For $i = 0 To $iChilds - 1 $oAutomationElementArray.GetElement( $i, $pTVitem ) $oTVitem = ObjCreateInterface( $pTVitem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oTVitem.GetCurrentPropertyValue( $UIA_NamePropertyId, $aChilds[$i] ) ConsoleWrite( "Child" & $i & " = " & $aChilds[$i] & @CRLF ) Next EndFunc I made a mistake in the previous code: ; --- Find treeview item --- ConsoleWrite( "--- Find treeview item ---" & @CRLF ) Local $pCondition2, $pCondition3, $pAndCondition3 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TreeItemControlTypeId, $pCondition2 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "LAP_VOW", $pCondition3 ) ; <<<<<<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition3 OK" & @CRLF ) Local $pTreeItem1, $oTreeItem1 $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pTreeItem1 ) $oTreeItem1 = ObjCreateInterface( $pTreeItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oTreeItem1 ) Then Return ConsoleWrite( "$oTreeItem1 ERR" & @CRLF ) ConsoleWrite( "$oTreeItem1 OK" & @CRLF ) Replace $oWindow1 with $oTree1. I don't think the error has had any consequences. You got the right result anyway.1 point -
ArrayAdd is probably useful. Im thinking _FileReadToArray, delete everything without URL, then build a Final array with the leftovers each time through. the below is just pseudo code, may or may not work at all: local $aFinal[0] local $aArray For $j = 0 to ubound($aListOfFiles) - 1 _FileReadToArray($ListofFiles[$j] , $aArray , 0) For $i = ubound($aArray) - 1 to 0 step -1 ;note to loop backwards if you are deleting stuff if stringleft($aArray[$i],3) <> "URL" then _ArrayDelete($aArray , $i) Next _ArrayAdd($aFinal , $aArray) Next1 point
-
XPaths can be made contextual too. Say you are attempting to replace a node value, but it's inside another node with some known attribute. You would have to reinvent the wheel to determine which child node to update with just a string replace; where with an xpath, you can do something like this to get the proper node: "//some/parent[@name='ThisIsTheParent']//child" There could be a million parent nodes, with unique name attributes, and you would be able to grab the child in one swoop rather than create complicated regular expressions or loops. Of course, there is a bit to the learning curve in creating well formed xpaths as well.1 point
-
probably going to want to look at _FileReadToArray or at least FileOpen and pass the handle (as you did with the outfile). Please note this from the FileReadLine help file: based off its location in the loop you are opening-reading-closing for every line of every file.1 point
-
please use tag for insert a code sleep(3000) is not much correct use _IELoadWait is mcuh better usally and explain what your script must should do1 point
-
one more go at it, think this line might pull off the trick #include<array.au3> local $a[9]=['entry 0 url match' , 1,2,'line 3 has url in it',4,5,6,'url begins line 7','line 8 ends with url'] _ArrayDisplay(StringRegExp(_ArrayToString($a, @LF) & @LF , "(.*url.*?)" & @LF , 3))1 point
-
I pull the entire file into a array then loop the array and check for the ITEM containing the word $file1 = "c:\somefile.txt" ; --------------------------------- ; FILE TO ARRAY ; --------------------------------- Func _GetValid() ; .................................................. $ListRead = FileRead($file1, FileGetSize($file1)) $aarray = StringRegExp($ListRead, "(?i)url(.*?)", 3) ;; THIS IS THE PART YOU NEED TO CHANGE TO FIND YOUR LINES ; .................................................. For $bi = 0 to UBound($aarray) - 1 ConsoleWrite("DEBUG: " & $aarray[$bi] & @CRLF) ; THIS IS THE PART YOU NEED TO EXPORT TO A FILE LINE BY LINE Next ; .................................................. Return EndFunc ;also try _StringExplode($sText, "##", 0) ;StringInStr("This is a sentence with whitespace.", "white")1 point
-
use arrayfindall to get the indices, then loop through that array putting the values back. #include<array.au3> local $a[9]=[1,2,'line 3 has url in it',4,5,6,'url begins line 7','line 8 ends with url',9] $aMatches = _ArrayFindAll($a , "url" , 0 ,0 , 0, 1) For $i = 0 to ubound($aMatches) - 1 $aMatches[$i] = $a[$aMatches[$i]] Next _ArrayDisplay($aMatches)1 point
-
NP Either method should work fine, but using xml dom is targeted whereas if there is one character out with _ReplaceStringInFile it will fail. Hope that made sense.1 point
-
Maybe like this (can't test at the moment): Func _GETcurrentNICinfo2() $oErrors = ObjEvent("AutoIt.Error", "Error_Handle") Local $DnsSecondry Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" ) Local $query = $objWMIService.ExecQuery("SELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 ) If @error Or NOT IsObj($query) Then Return 0 For $objItem In $query $aDNSIPAddress = $objItem.DNSServerSearchOrder MsgBox(0, "DNSServerSearchOrder", "# of IP-Addresses: " & UBound($aDNSIPAddress)) Return $objItem.DNSServerSearchOrder[1] next EndFunc1 point
-
WinHTTP functions
HamidZaeri reacted to trancexx for a topic
If it works then it's ok. Status line of HTTP response is standardized. As for the other... why in the world would you want that?1 point -
You could use something like: #include <_XMLDomWrapper.au3> Global $g_bSaveXml = False Global $g_sSample = @ScriptDir & "\sample.xml" Global $g_sRefNode = '//mobilePublicSafety/settings/customparam/ReferenceInformationAction' Global $g_sLocNode = '//mobilePublicSafety/settings/monitors/unitMonitor/grid/col[@dataFld="location"]' Global $g_sDGrNode = '//mobilePublicSafety/settings/monitors/unitMonitor/grid/col[@dataFld="dgroup"]' _XMLFileOpen($g_sSample, "", -1, False) Switch @error Case 1 MsgBox(16, "XML File Open Error", 'An error occurred while attempting to parse ' & @CRLF & $g_sSample) Exit Case 2 MsgBox(16, "XML File Open Error", 'No object was found while attempting to parse ' & @CRLF & $g_sSample) Exit EndSwitch Local $oRefNode = $objDoc.selectSingleNode($g_sRefNode) If IsObj($oRefNode) Then Local $sRefNode = $oRefNode.Text If $sRefNode = '"C:\Program Files\Internet Explorer\iexplore.exe" -k "c:\temp\temp.html"' Then $oRefNode.Text = '"C:\Program Files\Internet Explorer\iexplore.exe" -k "http:\\10.1.1.1\temp.html"' $g_bSaveXml = True EndIf EndIf Local $oLocNode = $objDoc.selectSingleNode($g_sLocNode) If IsObj($oLocNode) Then Local $sLocNode = $oLocNode.getAttribute("hidden") If $sLocNode = 1 Then $oLocNode.setAttribute("hidden", 0) $g_bSaveXml = True EndIf EndIf Local $oDGrNodeNode = $objDoc.selectSingleNode($g_sDGrNode) If IsObj($oDGrNodeNode) Then Local $sDRgNode = $oDGrNodeNode.getAttribute("hidden") If $sDRgNode = 0 Then $oDGrNodeNode.setAttribute("hidden", 1) $g_bSaveXml = True EndIf EndIf If $g_bSaveXml Then $objDoc.Save("sample.xml")1 point
-
You should look at using IE UDF and Excel UDF much better then using Mouse... and Send functions. But to loop you just need to use something like: For $i = 150 To 155 MsgBox(4096, "", "http://abc.com/" & $i) Next Here is how to copy all the links into Excel using IE and Excel UDF. #include <Array.au3> #include <Excel.au3> #include <IE.au3> Local $aLinks[0][2] $oIE = _IECreate("https://www.uygunparca.com/index.php?route=module/browse/ajax_model&p=59_68&manufacturer_id=13&category_id=68&page=150", 1) _IELoadWait($oIE) Local $iPageStart = 151, $iPageEnd = 160 For $iPage = $iPageStart To $iPageEnd $oDivs = _IETagNameGetCollection($oIE, "div") If IsObj($oDivs) Then For $oDiv In $oDivs If $oDiv.className = "modal-body" Then $oLinks = _IETagNameGetCollection($oDiv, "a") If IsObj($oLinks) Then For $oLink In $oLinks _ArrayAdd($aLinks, $oLink.innerText & "|" & $oLink.href) Next EndIf EndIf Next EndIf _IENavigate($oIE, "https://www.uygunparca.com/index.php?route=module/browse/ajax_model&p=59_68&manufacturer_id=13&category_id=68&page=" & $iPage) _IELoadWait($oIE) Next _ArrayDisplay($aLinks) Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookNew($oExcel) _Excel_RangeWrite($oWorkbook, Default, $aLinks, "A1")1 point
-
1 point
-
How To Read if radio button is selected
GoogleGonnaSaveUs reacted to Melba23 for a topic
AlchemistZim, A radio button is selected when GUICtrlRead returns 1 - like this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hRadio_1 = GUICtrlCreateRadio("One", 10, 10, 80, 20) GUICtrlSetState(-1, $GUI_CHECKED) $hRadio_2 = GUICtrlCreateRadio("Two", 90, 10, 80, 20) $hButton = GUICtrlCreateButton("Test", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton If GUICtrlRead($hRadio_1) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< MsgBox(0, "Test", "One was checked") Else MsgBox(0, "Test", "Two was checked") EndIf EndSwitch WEndAll clear? M231 point