Leaderboard
Popular Content
Showing content with the highest reputation on 02/05/2022 in all areas
-
Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip1 point
-
Version 1.5.0.1
947 downloads
The F1 key in SciTE displays the documentation for the word on which the cursor is located. Up to now this was only available for AutoIt. But times change and we change with them Now with Advanced.Help ANY CHM help file (Compressed HTML Help) can be called with the F1 key. The only prerequisite: All function names have to start with the same identifier (like _AD_, _OL_ etc.). This tool, created by BugFix from the german forum and the help of Musashi, allows custom CHM help files to be included in SciTE. The existing help key is used to call either the AutoIt help or the corresponding custom help. Depending on which keyword the cursor is currently on. For unknown keywords the AutoIt help is called. For AutoIt a separate window is opened and for the user-defined UDFs another window is opened, so you can work with both helps at the same time. The ZIP file contains an installation guide in German (Install_Deutsch.txt) and English (Install_English.txt) in which the installation and configuration is described in detail. Most CHM help files come with UDFs you can download from this forum section (AD, OutlookEX, TaskScheduler). In addition we have added the preliminary release of the WebDriver help file. The most current CHM help file is now only distributed with the WebDriver UDF. BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort Known Bugs: (last changed: 2022-07-20) None1 point -
bug in _GUICtrlListView_SimpleSort or it's me ?
pixelsearch reacted to Resiak1811 for a topic
I found the problem ... In GuiListView.au3 the line 4502 --> $aListViewItems[$i][$j] = Number($sItemText) "Number" remove the 0 at the beginning of the item #... Can I expect any fix from the dev. ? Otherwise I will modify this part: In GuiListView.au3, line 4501 to 4505 : If (StringIsFloat($sItemText) Or StringIsInt($sItemText)) Then $aListViewItems[$i][$j] = Number($sItemText) Else $aListViewItems[$i][$j] = $sItemText EndIf to be only : $aListViewItems[$i][$j] = $sItemText1 point -
reading Excel cell value, writing to ini, and reading from ini.
AndreasNWWWWW reacted to Nine for a topic
Probably this : For $i = 0 to Ubound($aResult) - 1 GUICtrlSetData($aButton[$i], $aresult[$i]) GUICtrlSetState($aButton[$i], $GUI_SHOW) Next See my edit above, you can simplify the reading of the excel sheet...1 point -
Sort question in C++
pixelsearch reacted to jugador for a topic
@pixelsearch I am glad that I asked for help learn new things. (JS with JsArr3 array) Console output: $g_iRows = 100 $g_iCols = 6 JScript: sorted in = 14 ms $g_iRows = 1000 $g_iCols = 6 JScript: sorted in = 43 ms $g_iRows = 10000 $g_iCols = 6 JScript: sorted in = 394 ms $g_iRows = 100000 $g_iCols = 6 JScript: sorted in = 5026 ms $g_iRows = 200000 $g_iCols = 6 JScript: sorted in = 10705 ms so latest script runs faster1 point -
Maybe this ? .... Case $btnRight If _query($num + 1) Then $num += 1 GUICtrlSetData($Count, $num) EndIf .... Func _query($id) Local $retarr If _SQLite_QuerySingleRow($dbn, "SELECT max(id) FROM DataFile_DB;", $retarr) <> $SQLITE_OK Then Return False If Not $retarr[0] Or $id > Number($retarr[0]) Then Return False _SQLite_QuerySingleRow($dbn, "SELECT * FROM DataFile_DB WHERE id='" & $id & "';", $retarr) _clear() If $retarr[0] Then GUICtrlSetData($e_edit1, $retarr[1]) GUICtrlSetData($e_edit2, $retarr[2]) GUICtrlSetData($e_edit3, $retarr[3]) EndIf Return True EndFunc ;==>_query Untested. Tried to run your script from scratch, but it is not working for me. I get arrays errors and I do not feel to debug the whole thing.1 point
-
reading Excel cell value, writing to ini, and reading from ini.
AndreasNWWWWW reacted to Nine for a topic
I suggest you create your buttons in an array with a loop, then you can easily show/hide and set data based on another array. Example : #include <GUIConstants.au3> #include <Constants.au3> Local $hGUI = GUICreate("Test") Local $aButton[20] For $i = 0 To UBound($aButton) - 1 $aButton[$i] = GUICtrlCreateButton("", 10, 10 + $i * 25, 80, 20) GUICtrlSetState(-1, $GUI_HIDE) Next GUISetState() For $i = 0 to 6 GUICtrlSetData($aButton[$i], "Number " & $i +1) GUICtrlSetState($aButton[$i], $GUI_SHOW) Next Local $nMsg While True $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aButton[0] To $aButton[UBound($aButton) - 1] ConsoleWrite("Button " & $nMsg - $aButton[0] + 1 & " has been pressed" & @CRLF) EndSwitch WEnd1 point -
No. Tag names are the element type, such as input, img, span, etc). See here for further details. You will need to find a reliable way to locate the element using either CSS or xpath selectors. There's a Tools listing in the wiki that are helpful with this type of thing.1 point
-
1) Look in wd_core.au3 around line 73 for the global constant declarations. 2) Not sure what you mean by field names. Can you post an example? What site are you accessing?1 point
-
Sort question in C++
jugador reacted to pixelsearch for a topic
A second way to do it in JS, maybe simpler : * If original array is 1D, then we agree that we must use another separator than native JS comma as explained in the preceding post, because Strings of data are returned from JS to AutoIt (in the way the JS script is written), so it's ok to use Chr(1) as separator when 1D * If original array is 2D, why are we returning from JS the strings of sorted data + their old indexes ? Wouldn't it be better to return ONLY the old indexes, without the sorted data ? I just did that in the script below. So if we return only numbers (indexes) from JS, there's no problem with the native JS comma delimiter when 2D arrays. But this requires to create a new array while in JS (array named JsArr3 in the script below) and this new array is created only when the original array is 2D : AutoIt console : $o_SortData = 2,5,4,0,3,1 #cs #include <Array.au3> Opt("MustDeclareVars", 1) __Example1() Func __Example1() Local $arry[] = [6, 4, 1, 5, 3, 2] _ArrayDisplay($arry, "UNsorted") Local $x_Result = __ArraySortJs($arry, 0, True, True) ; col 0, numeric (True), ascending (True) _ArrayDisplay($x_Result, "sorted") Local $arry[] = ['D,0','F0','A0','E0','C0','B0'] _ArrayDisplay($arry, "UNsorted") Local $x_Result = __ArraySortJs($arry, 0, False, False) ; col 0, string, descending _ArrayDisplay($x_Result, "sorted") Local $arry[][] = [['D0',6,'D,D2'],['F0',4,'FF2'],['A0',1,'A2'],['E0',5,'E2'],['C0',3,'C2'],['B0',2,'B2']] Local $iCol_Sort = 2 _ArrayDisplay($arry, "UNsorted (col " & $iCol_Sort & ")") Local $x_Result = __ArraySortJs($arry, $iCol_Sort, False, True) ; string, ascending _ArrayDisplay($x_Result, "sorted (col " & $iCol_Sort & ")") EndFunc #ce #include <Array.au3> #include "RandomArray.au3" ; LarsJ Opt("MustDeclareVars", 1) Global $g_iRows = 10000, $g_iCols = 6, $g_aArray __Example2() Func __Example2() _Generate_All($g_aArray) _ArrayDisplay($g_aArray, "UNsorted", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*") Local $hTimer2 = TimerInit() Local $iCol_Sort = 0 Local $x_Result2 = __ArraySortJs($g_aArray, $iCol_Sort, False, True) ; string (False), ascending (True) If @error Then Exit Msgbox(0, "__ArraySortJs", "error " & @error) ConsoleWrite("JScript: sorted in = " & Int(TimerDiff($htimer2)) & " ms" & @crlf) _ArrayDisplay($x_Result2, "sorted (col " & $iCol_Sort & ")", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*") EndFunc ;=========================================== Func _Generate_All(ByRef $g_aArray) ; LarsJ ConsoleWrite("$g_iRows = " & $g_iRows & " $g_iCols = " & $g_iCols & @CRLF) $g_aArray = FAS_Random2DArrayAu3($g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz") EndFunc ;==>_Generate_All ; #FUNCTION# ============================================================================= ; Name...........: __ArraySortJs ; ======================================================================================== Func __ArraySortJs($o_array, $o_Column = 0, $o_Numeric = True, $o_ascending = True) ;==== If Not IsArray($o_array) Then Return SetError(1, 0, -1) Local $iNb_Cols = Ubound($o_array, 2) If ($iNb_Cols = 1) And ($o_Column > 0) Then Return SetError(1, 0, -1) If ($iNb_Cols > 1) And ($o_Column > $iNb_Cols - 1) Then Return SetError(1, 0, -1) ;==== ;==== Local $o_CBlock = _ 'function GetArray(arr){' & @CRLF & _ 'var oArray = new VBArray(arr)' & @CRLF & _ 'return oArray.toArray()' & @CRLF & _ '}' & @CRLF & _ 'function NumSort1D(a, b){' & @CRLF & _ 'return a - b' & @CRLF & _ '}' & @CRLF & _ 'function NumSort2D(a, b){' & @CRLF & _ 'return a[0] - b[0]' & @CRLF & _ ; always [0] +++ '}' & @CRLF & _ 'function StringSort1D(a, b){' & @CRLF & _ 'if (a === b) {' & @CRLF & _ 'return 0' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return (a < b) ? -1 : 1' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function StringSort2D(a, b){' & @CRLF & _ 'if (a[0] === b[0]) {' & @CRLF & _ ; always [0] +++ 'return 0' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return (a[0] < b[0]) ? -1 : 1' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function ArraySorting1D(arr, oNumeric, oascending){' & @CRLF & _ 'var JsArray = GetArray(arr)' & @CRLF & _ 'if (oNumeric) {' & @CRLF & _ 'JsArray.sort(NumSort1D)' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'JsArray.sort(StringSort1D)' & @CRLF & _ '}' & @CRLF & _ 'if (oascending) {' & @CRLF & _ 'return JsArray.join(String.fromCharCode(1))' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return JsArray.reverse().join(String.fromCharCode(1))' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function ArraySorting2D(arr, oNumeric, oascending){' & @CRLF & _ 'var JsArray = GetArray(arr)' & @CRLF & _ 'var JsArr2 = []' & @CRLF & _ 'for (var i=0; i<JsArray.length; i++) {' & @CRLF & _ 'JsArr2[i] = []' & @CRLF & _ 'JsArr2[i][0] = JsArray[i]' & @CRLF & _ 'JsArr2[i][1] = i' & @CRLF & _ '}' & @CRLF & _ 'if (oNumeric) {' & @CRLF & _ 'JsArr2.sort(NumSort2D)' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'JsArr2.sort(StringSort2D)' & @CRLF & _ '}' & @CRLF & _ 'var JsArr3 = []' & @CRLF & _ 'for (var i=0; i<JsArray.length; i++) {' & @CRLF & _ 'JsArr3[i] = JsArr2[i][1]' & @CRLF & _ '}' & @CRLF & _ 'if (oascending) {' & @CRLF & _ 'return JsArr3.toString()' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return JsArr3.reverse().toString()' & @CRLF & _ '}' & @CRLF & _ '}' ;==== ;==== Local $ObjErr = ObjEvent("AutoIt.Error", "_ErrorHandler") Local $o_Obj = 0 $o_Obj = ObjCreate("ScriptControl") $o_Obj.Language = "JScript" $o_Obj.AddCode($o_CBlock) ;==== ;==== If $iNb_Cols = 0 Then ; when original array is 1D Local $o_SortData = $o_Obj.run("ArraySorting1D", $o_array, $o_Numeric, $o_ascending) $o_Obj = 0 Local $o_SortArry = StringSplit($o_SortData, Chr(1), 2) ; same separator used in JsArray.join() Return $o_SortArry EndIf ;==== ; original array is 2D from now on ;==== Local $o_ExtColmn[UBound($o_array)] ; 1D array of UNsorted elements For $i = 0 To UBound($o_array) - 1 $o_ExtColmn[$i] = $o_array[$i][$o_Column] Next Local $o_SortData = $o_Obj.run("ArraySorting2D", $o_ExtColmn, $o_Numeric, $o_ascending) $o_Obj = 0 ; ConsoleWrite("$o_SortData = " & $o_SortData & @lf) ;==== ;==== Local $o_SortArry = StringSplit($o_SortData, ',', 2) ; 1D array of indexes BEFORE sort) ; _ArrayDisplay($o_SortArry, "$o_SortArry") Local $o_Index[Ubound($o_array)][$iNb_Cols] ; empty 2D array to be filled For $i = 0 To Ubound($o_SortArry) - 1 For $j = 0 To $iNb_Cols - 1 $o_Index[$i][$j] = $o_array[$o_SortArry[$i]][$j] Next Next Return $o_Index ;==== EndFunc Func _ErrorHandler($oError) EndFunc I don't know which script runs faster (this one or the preceding one). Anyway, we have more choices now. Returning only indexes from JS, without any additional data, that looks fine too1 point -
Sort question in C++
jugador reacted to pixelsearch for a topic
@jugador: there is a potential issue with the JavaScript native separator (comma) used in array.toString() to separate rows, with a fatal error in AutoIt script. For example, imagine there is a comma in any string of the column to be sorted. Let's change the string element "DD2" to "D,D2" and let's run the preceding script, this will happen : The script exits with Fatal error and Autoscript console shows : $o_SortData = A2,2,B2,5,C2,4,D,D2,0,E2,3,FF2,1 ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $o_Index[$iRow][$j] = $o_array[$o_SortArry[$i + 1]][$j] ^ ERROR There is now an extra element in the returned string and the pic above reflects it : 13 elements instead of 12 [i.e. 6*2 pairs] To avoid this, we could use array.join() instead of array.toString() and choose the separator we want. I think Chr(1) is not a bad choice (it shouldn't be found in usual strings) and JS will again return a string, inserting a Chr(1) at the end of each row of the array. This is a pic of the string returned : $o_SortData = A2,2�B2,5�C2,4�D,D2,0�E2,3�FF2,1 Then in AutoIt, we'll do same and use StringSplit with Chr(1), leading to these new pics : Now the results are correct, but the new pics need explanations : The commas found in the middle pic (for example "A2,2") seem to be always generated by JS to separate the "columns of our 2D pseudo-Array" though there aren't real 2D arrays in JS (after what I read) What is important for us is the LAST comma of each row, to catch the old index of the element placed after the last comma, for example : * "A2,2" had a row of 2 (after the last comma) * "D,D2,0" had a row of 0 (after the last comma) So we'll retrieve the old indexes in a new way, using StringInStr() to determine where is the last comma of each string. Here is the new AutoIt code based on Chr(1) separator : #cs #include <Array.au3> Opt("MustDeclareVars", 1) __Example1() Func __Example1() Local $arry[] = [6, 4, 1, 5, 3, 2] _ArrayDisplay($arry, "UNsorted") Local $x_Result = __ArraySortJs($arry, 0, True, True) ; col 0, numeric (True), ascending (True) _ArrayDisplay($x_Result, "sorted") Local $arry[] = ['D,0','F0','A0','E0','C0','B0'] _ArrayDisplay($arry, "UNsorted") Local $x_Result = __ArraySortJs($arry, 0, False, False) ; col 0, string, descending _ArrayDisplay($x_Result, "sorted") Local $arry[][] = [['D0',6,'D,D2'],['F0',4,'FF2'],['A0',1,'A2'],['E0',5,'E2'],['C0',3,'C2'],['B0',2,'B2']] Local $iCol_Sort = 2 _ArrayDisplay($arry, "UNsorted (col " & $iCol_Sort & ")") Local $x_Result = __ArraySortJs($arry, $iCol_Sort, False, True) ; string, ascending _ArrayDisplay($x_Result, "sorted (col " & $iCol_Sort & ")") EndFunc #ce #include <Array.au3> #include "RandomArray.au3" ; LarsJ Opt("MustDeclareVars", 1) Global $g_iRows = 10000, $g_iCols = 6, $g_aArray __Example2() Func __Example2() _Generate_All($g_aArray) _ArrayDisplay($g_aArray, "UNsorted", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*") Local $hTimer2 = TimerInit() Local $iCol_Sort = 0 Local $x_Result2 = __ArraySortJs($g_aArray, $iCol_Sort, False, True) ; string (False), ascending (True) If @error Then Exit Msgbox(0, "__ArraySortJs", "error " & @error) ConsoleWrite("JScript: sorted in = " & Int(TimerDiff($htimer2)) & " ms" & @crlf) _ArrayDisplay($x_Result2, "sorted (col " & $iCol_Sort & ")", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*") EndFunc ;=========================================== Func _Generate_All(ByRef $g_aArray) ; LarsJ ConsoleWrite("$g_iRows = " & $g_iRows & " $g_iCols = " & $g_iCols & @CRLF) $g_aArray = FAS_Random2DArrayAu3($g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz") EndFunc ;==>_Generate_All ; #FUNCTION# ============================================================================= ; Name...........: __ArraySortJs ; ======================================================================================== Func __ArraySortJs($o_array, $o_Column = 0, $o_Numeric = True, $o_ascending = True) ;==== If Not IsArray($o_array) Then Return SetError(1, 0, -1) Local $iNb_Cols = Ubound($o_array, 2) If ($iNb_Cols = 1) And ($o_Column > 0) Then Return SetError(1, 0, -1) If ($iNb_Cols > 1) And ($o_Column > $iNb_Cols - 1) Then Return SetError(1, 0, -1) ;==== ;==== Local $o_CBlock = _ 'function GetArray(arr){' & @CRLF & _ 'var oArray = new VBArray(arr)' & @CRLF & _ 'return oArray.toArray()' & @CRLF & _ '}' & @CRLF & _ 'function NumSort1D(a, b){' & @CRLF & _ 'return a - b' & @CRLF & _ '}' & @CRLF & _ 'function NumSort2D(a, b){' & @CRLF & _ 'return a[0] - b[0]' & @CRLF & _ ; always [0] +++ '}' & @CRLF & _ 'function StringSort1D(a, b){' & @CRLF & _ 'if (a === b) {' & @CRLF & _ 'return 0' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return (a < b) ? -1 : 1' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function StringSort2D(a, b){' & @CRLF & _ 'if (a[0] === b[0]) {' & @CRLF & _ ; always [0] +++ 'return 0' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return (a[0] < b[0]) ? -1 : 1' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function ArraySorting1D(arr, oNumeric, oascending){' & @CRLF & _ 'var JsArray = GetArray(arr)' & @CRLF & _ 'if (oNumeric) {' & @CRLF & _ 'JsArray.sort(NumSort1D)' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'JsArray.sort(StringSort1D)' & @CRLF & _ '}' & @CRLF & _ 'if (oascending) {' & @CRLF & _ 'return JsArray.join(String.fromCharCode(1))' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return JsArray.reverse().join(String.fromCharCode(1))' & @CRLF & _ '}' & @CRLF & _ '}' & @CRLF & _ 'function ArraySorting2D(arr, oNumeric, oascending){' & @CRLF & _ 'var JsArray = GetArray(arr)' & @CRLF & _ 'var JsArr2 = []' & @CRLF & _ 'for (var i=0; i<JsArray.length; i++) {' & @CRLF & _ 'JsArr2[i] = []' & @CRLF & _ 'JsArr2[i][0] = JsArray[i]' & @CRLF & _ 'JsArr2[i][1] = i' & @CRLF & _ '}' & @CRLF & _ 'if (oNumeric) {' & @CRLF & _ 'JsArr2.sort(NumSort2D)' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'JsArr2.sort(StringSort2D)' & @CRLF & _ '}' & @CRLF & _ 'if (oascending) {' & @CRLF & _ 'return JsArr2.join(String.fromCharCode(1))' & @CRLF & _ '}' & @CRLF & _ 'else {' & @CRLF & _ 'return JsArr2.reverse().join(String.fromCharCode(1))' & @CRLF & _ '}' & @CRLF & _ '}' ;==== ;==== Local $ObjErr = ObjEvent("AutoIt.Error", "_ErrorHandler") Local $o_Obj = 0 $o_Obj = ObjCreate("ScriptControl") $o_Obj.Language = "JScript" $o_Obj.AddCode($o_CBlock) ;==== ;==== If $iNb_Cols = 0 Then ; when original array is 1D Local $o_SortData = $o_Obj.run("ArraySorting1D", $o_array, $o_Numeric, $o_ascending) $o_Obj = 0 Local $o_SortArry = StringSplit($o_SortData, Chr(1), 2) ; same separator used in JsArray.join() Return $o_SortArry EndIf ;==== ; original array is 2D from now on ;==== Local $o_ExtColmn[UBound($o_array)] ; 1D array of UNsorted elements For $i = 0 To UBound($o_array) - 1 $o_ExtColmn[$i] = $o_array[$i][$o_Column] Next Local $o_SortData = $o_Obj.run("ArraySorting2D", $o_ExtColmn, $o_Numeric, $o_ascending) $o_Obj = 0 ; ConsoleWrite("$o_SortData = " & $o_SortData & @lf) ;==== ;==== Local $o_SortArry = StringSplit($o_SortData, Chr(1), 2) ; 1D array of sorted elements (+ indexes b4 sort) ; _ArrayDisplay($o_SortArry, "$o_SortArry") Local $o_Index[Ubound($o_array)][$iNb_Cols] ; empty 2D array to be filled Local $iIndex_Old For $i = 0 To Ubound($o_SortArry) - 1 $iIndex_Old = StringMid($o_SortArry[$i], _ 1 + StringInStr($o_SortArry[$i], ',', 0, -1)) ; search LAST comma (from the right) For $j = 0 To $iNb_Cols - 1 $o_Index[$i][$j] = $o_array[$iIndex_Old][$j] Next Next Return $o_Index ;==== EndFunc Func _ErrorHandler($oError) EndFunc Credits : JavaScript Bible 7th Edition (Goodman-Morrison-Novitski-Rayl) array.toString() page 353 array.join(separatorString) pages 337-3381 point -
@lee321987 you can use : #include <WinAPIFiles.au3> _EnumFiles("D:\op\") Func _EnumFiles($dir = "") Global $prev, $prev_o = "on" While 1 Global $aData = _WinAPI_EnumFiles($dir, 1, '*.*;') For $i = 1 To $aData[0][0] if $prev_o = "on" Then for $i2 = 1 To $aData[0][0] $prev = $prev & $aData[$i2][0] & @CRLF Next $prev_o = "off" EndIf if StringInStr($prev, $aData[$i][0]) Then Else MsgBox(0, '', $aData[$i][0]) $prev = "" $prev_o = "on" EndIf Next Sleep(50) WEnd EndFunc ;==>_EnumFiles1 point
-
Instead of creating 2 scripts you can use ReadDirectoryChangesW API in async mode (overlapped). It is a bit more complicated but, you get to have way more control on your program. I believe there is an example on this forum using this API. Search for it, if you cannot find it, I think I have an example somewhere. LMK.1 point
-
_WinAPI_ReadDirectoryChanges blocks until a change is made. (Or the directory handle is closed, I think) Depending what you're aiming to achieve, the solution may be to create two scripts. The second script could be called when _WinAPI_ReadDirectoryChanges detects a change maybe? You could use HotKeySet in the second script to kill the process of the first script as well. Edit: In this case, you'd want to start both scripts at the same time otherwise HotKeySet wouldn't be functional until _WinAPI_ReadDirectoryChanges detects a change.1 point
-
HotKey does not work (HotKeySet), and can't click tray icon to exit
lee321987 reacted to SOLVE-SMART for a topic
Hi @lee321987, I reproduced your behavior on two Win10 machines. @AutoItExe: C:\Program Files (x86)\AutoIt3\autoit3_x64.exe @AutoItVersion: 3.3.14.2 @CPUArch: X64 @OSArch: X64 @OSVersion: WIN_10 A tray icon is displayed but I can not use it either 🙁 . In a non deterministic way I get the _ArrayDisplay() output shown (in case I create/delete a file in the folder), but sometimes the script just exits 🥴 . By the way - the only change I had to do, to run your script is: ;~ #include <WinAPIMem.au3> #include <WinAPIDiag.au3> #include <WinAPISys.au3> Over all it seems to me pretty buggy, but I believe you will handle the situation by doing this kind of "watch dog job" on your own, am I possibly right? Best regards Sven ________________ Stay innovative!1 point -
Check whether the PID you are checking is running at the same Credentials level as your script as it might be you need Adminlevel access for it to check.1 point
-
I just check all files which was available here, collect them and post them to this download link/section: REMARK / WARNING: Some of them are little refactored. Each have add links to post and files. Only @Tlem version is changed. - 06-05-2021 updated by mLipok: * Added: _7Zip_GetDLLPath() * Refactored: _7ZipStartup() * Changed: _7ZipStartup() - If Not FileExists($s_DLL_path) And (Not FileInstall ..... * Changed: _7ZipStartup() - using @AutoItX64 instead of @OSArch - as DLL version is related not to OS but to program architecture * Changed: _7ZipShutdown() - Delete dll in temporary directory - not related to @compiled but to StringInStr($s_DLL_path, @TempDir) * Refactored: Examples Let me know if something goes wrong with this versions. EDIT: So far I have a problem with the FileInstall() function, which on the one hand I want to keep FileInstall() feature for compatibility with the current UDF, and on the other hand I do not want to use FileInstall() as the UDF should not force the user to do so. For example, I prefer to download missing files from HTTP. Work in progress.1 point
-
In case you're feeling lost, here's a little helper function that lists up all accessible items // based on ward's cool stuff. Cheers #include "JSMN.au3" #include <array.au3> #include <file.au3> Local $filelist = _FileListToArray(@ScriptDir, "*.json") Local $i, $json, $obj For $i = 1 To $filelist[0] ConsoleWrite("-----------" & $filelist[$i] & "----------------" & @CRLF) $json = FileRead($filelist[$i]) $obj = Jsmn_Decode($json) Jsmn_Iterate($obj, '', $filelist[$i]) Next Func Jsmn_Iterate($obj, $string, $pre = "") Local $temp, $i, $b If ($pre <> "") Then ConsoleWrite($pre & ": ") $a = Jsmn_Get_ShowResult($obj, $string) If IsArray($a) Then For $i = 0 To UBound($a) - 1 Jsmn_Iterate($obj, $string & '[' & $i & ']', $pre) Next ElseIf IsObj($a) Then $b = Jsmn_ObjGetKeys($a) For $temp In $b Jsmn_Iterate($obj, $string & '["' & $temp & '"]', $pre) Next EndIf Return EndFunc ;==>Jsmn_Iterate Func Jsmn_Get_ShowResult($Var, $Key) Local $Ret = Jsmn_Get($Var, $Key) If @error Then Switch @error Case 1 ConsoleWrite("Error 1: key not exists" & @LF) Case 2 ConsoleWrite("Error 2: syntax error" & @LF) EndSwitch Else ConsoleWrite($Key & " => " & VarGetType($Ret) & ": " & $Ret & @LF) EndIf Return $Ret EndFunc ;==>Jsmn_Get_ShowResult Func Jsmn_Get($Var, $Key) If Not $Key Then Return $Var Local $Match = StringRegExp($Key, "(^\[([^\]]+)\])", 3) If IsArray($Match) Then Local $Index = Jsmn_Decode($Match[1]) $Key = StringTrimLeft($Key, StringLen($Match[0])) If IsString($Index) And Jsmn_IsObject($Var) And Jsmn_ObjExists($Var, $Index) Then Local $Ret = Jsmn_Get(Jsmn_ObjGet($Var, $Index), $Key) Return SetError(@error, 0, $Ret) ElseIf IsNumber($Index) And IsArray($Var) And $Index >= 0 And $Index < UBound($Var) Then Local $Ret = Jsmn_Get($Var[$Index], $Key) Return SetError(@error, 0, $Ret) Else Return SetError(1, 0, "") EndIf EndIf Return SetError(2, 0, "") EndFunc ;==>Jsmn_Get1 point