Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/07/2017 in all areas

  1. This project implements data display functions based on _ArrayDisplay and _ArrayDisplayEx (virtual listview). Four functions are planned and maybe there’ll also come a fifth function. First post contains documentation common to all functions. In order to avoid first post being too long, posts 2 - 5 are reserved for documentation that's specific to the four planned functions. The first two functions _ArrayDisplayEx and CSVfileDisplay are presented below. The other functions will be presented in the coming weeks. Data display functions: _ArrayDisplayEx - Displays a 1D or 2D array in a virtual ListView CSVfileDisplay - Displays a CSV file in a virtual ListView _SQLite_Display - Displays data from a table, view or SELECT statement in a virtual ListView SafeArrayDisplay - Displays a 1D/2D safearray of variants (equivalent to an AutoIt array) in a virtual ListView The functions are mainly intended for large amounts of data with a large number of rows. The GUI and listview are implemented for this purpose. Thus, the left column in the listview is a row-number column. This is convenient when there are many rows. Through an input control at bottom of the GUI, you can focus on a specific row. When there are many rows it's difficult to scroll to a specific row with the mouse. The primary purpose of the functions is testing and debugging. Secondary to display data for end users. Therefore, features that are directly available in the function definition through parameters and flags are reduced to a minimum, while additional features that are especially interesting for end users must be specified in a single parameter which is the last parameter in the function definition. The definition of _ArrayDisplayEx looks like this: ; Displays a 1D or 2D array in a virtual ListView Func _ArrayDisplayEx( _ $aArray, _ ; 1D/2D array eg. StringSplit("Mo,Tu,We,Th,Fr,Sa,Su", ",") $sTitle = "", _ ; GUI title bar text, default title is set to "ArrayDisplayEx" $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0000, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs All functions uses a virtual listview to display data. A normal listview has two main features: Data storage and data display. A virtual listview has only one main feature: Data display. Data is stored in a data source outside the listview. Because data does not have to be inserted into the rows of a virtual listview, the listview shows up instantly. The number of rows is limited only to the data source. Data display in the virtual listview is implemented through subclassing. This means that the code will not interfere with WM_NOTIFY message handlers in your own code. And because there are a lot of messages involved in updating the cell texts in a virtual listview, the subclassing technique is also performance optimizing. The first parameter in the function definition is the data source. The data source is the main difference between the display functions. Depending on the function more than one parameter can be used to support the data source. After one or more data source parameters follows title, header and flag parameters. The last parameter is an array of additional features. It's discussed in a section below. These four parameters are common to all display functions. Flag values ; $iFlags values ; Add required values together ; 0x0000 => Left aligned text ; 0x0002 => Right aligned text ; 0x0004 => Centered text ; 0x0008 => Verbose mode ; 0x0010 => Half-height ListView ; 0x0020 => No grid lines in ListView ; 0x0040 => No bottom controls Not all flags can be used in all functions. See documentation for the actual function just below the function definition. Embedded controls (2018-04-14) Instead of creating the listview in a stand-alone main GUI, it's possible to create the listview in a child window of a user GUI, thereby creating an embedded control. A separate function is used to create the embedded control. This is the definition for _ArrayDisplayCtrl (the embedded control corresponding to _ArrayDisplayEx): ; Displays a 1D or 2D array in a virtual ListView as an embedded GUI control Func _ArrayDisplayCtrl( $hUserGui, $x, $y, $w, $h, _ $aArray, _ ; 1D/2D array eg. StringSplit("Mo,Tu,We,Th,Fr,Sa,Su", ",") $sTitle = "", _ ; GUI title bar text, default title is set to "ArrayDisplayEx" ; <<<< Not used >>>> $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0000, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs The embedded control is created with the code in Common\4)CreateAutoItGUICtrl.au3. Handle messages Messages from the embedded control must be identified in the user GUI. For this purpose, _ArrayDisplayCtrl (the embedded control corresponding to _ArrayDisplayEx) returns an array of information. The information and usage of the information is shown here through a part of the code in Examples\ArrayDisplayCtrl\1) Simple.au3: ; Create GUI Local $hGui = GUICreate( "Simple", 820, 660 ) ; Create ArrayDisplay control Local $aDisplay = _ArrayDisplayCtrl( $hGui, 10, 10, 800, 600, $aArray ) ; Get info about ArrayDisplay control Local $hDisplay = $aDisplay[0] ; Elem 0: Child window handle to show and resize window Local $idDisplay_FirstCtrl = $aDisplay[1] ; Elem 1: First controlID in child window (ListView control) Local $idDisplay_LastCtrl = $aDisplay[2] ; Elem 2: Last controlID in child window (last bottom ctrl) Local $hDisplay_MsgHandler = $aDisplay[3] ; Elem 3: Message handler for AutoIt events in child window Local $iDisplay_MsgHandlerIdx = $aDisplay[4] ; Elem 4: Message handler index GUISetState() GUISetState( @SW_SHOWNOACTIVATE, $hDisplay ) ; Show ArrayDisplay control Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg ; Handle messages for AutoIt events in ArrayDisplay control Case $idDisplay_FirstCtrl To $idDisplay_LastCtrl $hDisplay_MsgHandler( $iMsg, $iDisplay_MsgHandlerIdx ) You can use a shorter notation this way: ; Create GUI Local $hGui = GUICreate( "Simple", 820, 660 ) ; Create ArrayDisplay control Local $aDisplay = _ArrayDisplayCtrl( $hGui, 10, 10, 800, 600, $aArray ) GUISetState() GUISetState( @SW_SHOWNOACTIVATE, $aDisplay[0] ) ; Show ArrayDisplay control Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg ; Handle messages for AutoIt events in ArrayDisplay control Case $aDisplay[1] To $aDisplay[2] $aDisplay[3]( $iMsg, $aDisplay[4] ) As can be seen from the two Case statements, it's only tested if a message corresponds to a control in the range from the first controlId to the last controlId. A prerequisite for this to work is that the controlIds is an uninterrupted continuous sequence of integers. This is tested at the bottom of Common\4)CreateAutoItGUICtrl.au3. If the requirement is not met, @error is set to 5. The issue is demonstrated in an example: "a) Demonstration of @error = 5.au3". The message handler function $hDisplay_MsgHandler or $aDisplay[3] is implemented in Functions\ArrayDisplayEx\Internal\9)MessageLoopCtrl.au3 (for _ArrayDisplayCtrl). What happens if you forget to implement message handler code for the embedded control in your user GUI? Nothing. The embedded control will work anyway. However, you do not get any response to events that generate messages in the embedded control. Cleanup and release memory If the script with the embedded display function exits when the GUI closes, you do not have to worry about cleanup. It's done automatically by AutoIt. However, if you want to run more code after the GUI is closed, it may be useful to clean up and release memory used by the display function. Especially if it's a large data source. To release memory, take into account 3 types of variables: Variables created in your own script Variables passed to display function and stored as globals Variables passed to display function and stored as statics In order to release memory used by the last two types of variables, a new element has been added to the array returned from the display function (illustrated for _ArrayDisplayCtrl): $aDisplay[4] = $iIdx: Index in global array $aDataDisplay_Info (existing element) $aDisplay[5] = ArrayDisplay_Cleanup(): Performs cleanup, takes $iIdx and $hNotifyFunc as input parameters ArrayDisplay_Cleanup() that performs cleanup and releases memory is coded this way: ; Cleanup and release memory Func ArrayDisplay_Cleanup( $iIdx ) ; Remove $WM_COMMAND and $WM_SYSCOMMAND event handler If $aDataDisplay_Info[$iIdx][15] = 3 Then _ ; Remove WM_COMMAND, WM_SYSCOMMAND message handler (DataDisplayMult_MsgHandler) used to handle events from multiple concurrent and responsive GUIs DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aDataDisplay_Info[$iIdx][21], "ptr", $aDataDisplay_Info[$iIdx][40], "uint_ptr", $iIdx ) ; WM_COMMAND, WM_SYSCOMMAND ; Remove $WM_COMMAND event handler If $aDataDisplay_Info[$iIdx][15] = 2 Then _ ; Remove WM_COMMAND message handler (DataDisplayCtrl_WM_COMMAND) used to handle events from embedded GUI controls DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aDataDisplay_Info[$iIdx][21], "ptr", $aDataDisplay_Info[$iIdx][18], "uint_ptr", $iIdx ) ; WM_COMMAND ; Remove WM_NOTIFY message handler used to fill the virtual listview DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aDataDisplay_Info[$iIdx][21], "ptr", $aDataDisplay_Info[$iIdx][2], "uint_ptr", $iIdx ) ; WM_NOTIFY ; Delete ListView header background color resources If IsArray( $aDataDisplay_Info[$iIdx][16] ) Then Local $aTmp = $aDataDisplay_Info[$iIdx][16] ; [ $hListView, $pHeaderColor, $oHdr_Colors_Dict ] ; Remove WM_NOTIFY message handler (DataDisplay_HeaderColor) used to draw colors in listview header items DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aTmp[0], "ptr", $aTmp[1], "uint_ptr", 9999 ) For $hBrush In $aTmp[2].Items() DllCall( "gdi32.dll", "bool", "DeleteObject", "handle", $hBrush ) ; _WinAPI_DeleteObject Next $aDataDisplay_Info[$iIdx][16] = 0 EndIf ; Delete AutoIt GUI If $aDataDisplay_Info[$iIdx][15] <> 2 Then _ GUIDelete( $aDataDisplay_Info[$iIdx][21] ) ; Release memory $aDataDisplay_Info[$iIdx][0] = 0 $aDataDisplay_Info[$iIdx][3] = 0 $aDataDisplay_Info[$iIdx][4] = 0 $aDataDisplay_Info[$iIdx][5] = 0 $aDataDisplay_Info[$iIdx][6] = 0 ; Release local static memory $aDataDisplay_Info[$iIdx][1]( 0, 0x004E, 0, 0, $iIdx, 0 ) ; 0x004E = $WM_NOTIFY If $aDataDisplay_Info[$iIdx][15] = 2 Then DataDisplayCtrl_MsgHandler( 99999, $iIdx ) $aDataDisplay_Info[$iIdx][10] = 0 EndIf ; Release row in $aDataDisplay_Info $aDataDisplay_Info[$iIdx][20] = 0 ; $iIdx EndFunc And it's called this way: ; Cleanup and release memory $aDisplay[5]( $aDisplay[4] ) A new example, "b) Cleanup and release memory.au3", demonstrates the technique. Embedded control functions: _ArrayDisplayCtrl - Displays a 1D or 2D array in a virtual ListView as an embedded GUI control CSVfileDisplayCtrl - Displays a CSV file in a virtual ListView as an embedded GUI control _SQLite_DisplayCtrl - Displays data from a table, view or SELECT statement in a virtual ListView as an embedded GUI control SafeArrayDisplayCtrl - Displays a 1D/2D safearray of variants (equivalent to an AutoIt array) in a virtual ListView as an embedded GUI control Four new folders are created under Examples\ with similar examples. Multiple GUIs (2018-05-21) Both in the official _ArrayDisplay and in the data display functions here, it's possible to open multiple GUIs at the same time via user supplied functions and "Run User Func" buttons. An unfortunate consequence of this technique is that the message loop in the last created GUI blocks the message loop in a previously created GUI. This means that only the last created GUI is responsive to AutoIt messages eg. mouse clicks (all listviews are, however, fully functional because they are not depending on any AutoIt messages). As demonstrated in Unblocking a Blocked Message Handler and in Way to close AU3 Script with a button? it's possible to detect Windows messages (not AutoIt messages) in such blocked message loops by using window subclassing or GUIRegisterMsg functions. In case of _ArrayDisplay and the data display functions, it's enough to detect $WM_COMMAND messages for button click events and $WM_SYSCOMMAND messages for window close events. In the data display functions $WM_COMMAND messages are also used to detect input control events and keyboard accelerator events. By using these methods, four new data display functions are implemented with a new message handler, so that multiple simultaneous open GUIs are all responsive: _ArrayDisplayMult - Displays a 1D or 2D array in a virtual ListView, support for multiple GUIs CSVfileDisplayMult - Displays a CSV file in a virtual ListView, support for multiple GUIs _SQLite_DisplayMult - Displays data from a table, view or SELECT statement in a virtual ListView, support for multiple GUIs SafeArrayDisplayMult - Displays a 1D/2D safearray of variants (equivalent to an AutoIt array) in a virtual ListView, support for multiple GUIs Four new folders are created under Examples\ with similar examples. Note that at the top of Common\0)GlobalArray.au3, the number of simultaneous open data display GUIs is limited to 10: $aDataDisplay_Info[0][21] = 10 ; Max number of data display GUIs You can change the number to the value you want. Additional features Only basic functionality used for testing and debugging is implemented directly in the display functions. It's possible to use a wide range of additional features that are especially interesting when the display functions are used to display data for end users. Usually only a few features are used at a time. To avoid adding a lot of parameters to each display function of which only a few are used, additional features must be specified through a single $aFeatures parameter, which is the last parameter in the function definition. Also in order to avoid adding a lot of extra code to the functions that are rarely used, most of the features are implemented in separate include files. These files must be included in order to use the features. $aFeatures parameter is checked for errors under function initializing. In most cases, an error just means that the feature is skipped. Only in case of serious mistakes eg. a missing include file the function will return with an error code in @error. If verbose mode is turned on ($iFlags = 8), the error will be displayed in a MsgBox. The following additional features can be used: Features implemented through Common\ files (always usable) End user features: "ColAlign" - Column alignment "ColWidthMin" - Min. column width "ColWidthMax" - Max. column width "BackColor" - Listview background color "HdrColors" - Listview header background colors "UserFunc" - User supplied function Features implemented through include files End user features: Include file: "ColFormats" - Column text formats <Display function>_ColumnFormats.au3 "ColColors" - Column background colors <Display function>_ColumnColors.au3 "SortRows" - Sort rows in data source by index <Display function>_SortFuncs.au3 "SortCols" - Sort columns in data source by index <Display function>_SortFuncs.au3 "SortByCols" - Sort rows by multiple columns <Display function>_SortFuncs.au3 Debugging features: "DataTypes" - Data types info <Display function>_DataTypesInfo.au3 Not all features can be used in all functions. See documentation for the actual function just below the function definition. See HelpFiles\DisplayFeatures.txt in zip-file for documentation of each feature. See Examples\ for examples. Missing features Compared to the official _ArrayDisplay and the old version of _ArrayDisplayEx some features are omitted in the new functions. It's not possible to specify a data range to only display a small section of data. But rows and columns can be sorted by row and column indices which can replace the range feature. This is demonstrated in examples. Data copying that could be performed through two GUI buttons is omitted. Because the listviews are virtual listviews, potentially millions of cells can be selected and copied. Copying such large amounts of data can take a long time. Since data may in any case be copied directly from the data source, the copying functionality is omitted to avoid long-term copying. It's also not possible to change rows and columns. No transpose functionality. Function examples The zip-file is organized this way: DataDisplay\ - Top folder Common\ - Code common to all functions Examples\ - Examples for each function Functions\ - Implements the functions HelpFiles\ - Docu of additional features Resources\ - Resources used in examples Common\ and Functions\ contains all the code used to implement the display functions. Common\ is used to implement functionality and features. Functions\ is further divided into subfolders for each display function. The subfolders contains WM_NOTIFY message handlers that handles LVN_GETDISPINFOW, LVN_ODCACHEHINT, and NM_CUSTOMDRAW notifications, and displays data in the virtual list view. These functions are critical in terms of performance. Examples\ is also divided into subfolders for each display function. For each function the features are demonstrated one by one. If more parameters are used in relation to the data source, the utilization of the parameters is demonstrated in "Examples\<Display function>\0) Data source\". For most examples the data source is created on the fly. For this purpose, a few small UDFs are used. These UDFs are stored in Resources\. Using functions To use a display function in your own project copy the entire DataDisplay\ to the project folder. You can rename DataDisplay to Display or similar if you want a shorter name. You can delete Examples\, HelpFiles\ and Resources\. You can also delete display functions in Functions\ that you're not using. Then include the function you need in your code. Usage of the display functions is demonstrated in "Examples\<Display function>\3) Using function\". Here the code in "Examples\ArrayDisplayEx\3) Using function\My Project\Script1.au3": #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "Display\Functions\ArrayDisplayEx\ArrayDisplayEx.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $iRows = 10000, $iCols = 10 Local $aArray[$iRows][$iCols] For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aArray[$i][$j] = $i & "/" & $j Next Next _ArrayDisplayEx( $aArray ) EndFunc And in "Examples\ArrayDisplayEx\3) Using function\My Project\Script2.au3": #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "Display\Display.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $iRows = 10000, $iCols = 10 Local $aArray[$iRows][$iCols] For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aArray[$i][$j] = $i & "/" & $j Next Next _ArrayDisplayEx( $aArray, "", "", 0, GetDisplayFeatures() ) EndFunc Display\Display.au3: #include-once #include "Functions\ArrayDisplayEx\ArrayDisplayEx.au3" #include "Functions\ArrayDisplayEx\ArrayDisplayEx_ColumnColors.au3" Func GetDisplayFeatures() ; ArrayDisplayEx features Local $aAlignment = [ [ -1, "R" ], [ 0, "C" ], [ 1, "L" ] ] Local $aColColors = [ [ 1, 0xCCFFCC ], [ 3, 0xFFFFCC ] ] Local $aFeatures = [ [ "ColAlign", $aAlignment ], _ [ "ColColors", $aColColors ] ] Return $aFeatures EndFunc v3.3.10.2 If you're using this UDF in AutoIt v3.3.10.2 you should be aware of an Au3Check issue as described in this post. Zip-file The organization of the zip-file is described in the section above. You need AutoIt 3.3.10 or later. Tested on Windows 10, Windows 7 and Windows XP. Comments are welcome. Let me know if there are any issues. DataDisplay.7z
    4 points
  2. @hemichallenger In order to get this running you need to use the .NET CLR.au3 Udf from here : Like this : #AutoIt3Wrapper_UseX64=y #include "..\Includes\CLR.Au3" #include <FileConstants.au3> ; ***************************************************** ; PARAMETERS : (Output mode ) ; OUTPUT : 0 = Console, 1 = GRID, 2 = Printer, 3 = File, , 4 = Null ; ***************************************************** _Run_PSHost_Script('Get-Process -ComputerName "." | select -Property * | where name -like Name* ',3) Func _Run_PSHost_Script($PSScript, $iOutput = 0) Local $oAssembly = _CLR_LoadLibrary("System.Management.Automation") ConsoleWrite("!$oAssembly: " & IsObj($oAssembly) & @CRLF) ; Create Object Local $pAssemblyType = 0 $oAssembly.GetType_2("System.Management.Automation.PowerShell", $pAssemblyType) ConsoleWrite("$pAssemblyType = " & Ptr($pAssemblyType) & @CRLF) Local $oActivatorType = ObjCreateInterface($pAssemblyType, $sIID_IType, $sTag_IType) ConsoleWrite("IsObj( $oAssemblyType ) = " & IsObj($oActivatorType) & @TAB & @CRLF) ; Create Object Local $pObjectPS = 0 $oActivatorType.InvokeMember_3("Create", 0x158, 0, 0, 0, $pObjectPS) ConsoleWrite("IsObject: " & IsObj($pObjectPS) & @TAB & "$pObject: " & ObjName($pObjectPS) & @CRLF) ; <<<<<<<<<<<<<<<<<<< PS COMMAND HERE >>>>>>>>>>>>>>>>>>>> $pObjectPS.AddScript($PSScript) ; Add Script here ; <<<<<<<<<<<<<<<<<<< Output >>>>>>>>>>>>>>>>>>>> Switch $iOutput Case 0 ;~ $pObjectPS.AddCommand("Out-Host") ;~ $pObjectPS.AddCommand("Out-String") ;~ $pObjectPS.AddCommand("Write-Host") Msgbox(16,"Error","This Output method '0' is not working yet :-( " & @CRLF & "choose another one") Exit Case 1 $pObjectPS.AddCommand("Out-GridView") Case 2 $pObjectPS.AddCommand("Out-Printer") Case 3 $pObjectPS.AddCommand("Out-File") $sFile = @DesktopDir & "\PShost.txt" ConsoleWrite("> " & $sFile & @CRLF) $pObjectPS.AddArgument($sFile) Case 4 $pObjectPS.AddCommand("Out-Null") Case Else MsgBox(0,"PSHost","Wrong Output Choice ?") EndSwitch $objAsync = $pObjectPS.BeginInvoke() ConsoleWrite("$objAsync " & IsObj($objAsync & @TAB & "$pObject: " & ObjName($objAsync) ) & @CRLF) While $objAsync.IsCompleted = False ;~ ConsoleWrite($objAsync.IsCompleted & @CRLF) ContinueLoop WEnd $objPsCollection = $pObjectPS.EndInvoke($objAsync) Switch $iOutput Case 0 ;~ ConsoleWrite( $objPsCollection & @CRLF) MsgBox(16,"PSHost","Output To Console is not working yet :-( ?" & @CRLF & @CRLF & " Best make a different OUTPUT option.") Case 1 Sleep(10000) ;~ WinWaitClose("") Case 3 MsgBox(0,"PSHost","File Output Ready on Desktop.") EndSwitch EndFunc Enjoy!
    2 points
  3. CSVfileDisplay This is copied from the top of CSVfileDisplay.au3: ; Displays a CSV file in a virtual ListView Func CSVfileDisplay( _ $sCSVfile, _ ; Name of CSV file (plain text file) $iEncoding = 128, _ ; File encoding, default is UTF-8 with BOM $cSeparator = "|", _ ; Field separator character, default is "|" $iMax_Fields = 0, _ ; Max. number of data fields in a line in the CSV file $sTitle = "", _ ; GUI title bar text, default title is set to "CSVfileDisplay" $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0100, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs ; $iFlags values ; Add required values together ; 0x0000 => Left aligned text ; 0x0002 => Right aligned text ; 0x0004 => Centered text ; 0x0008 => Verbose mode ; 0x0010 => Half-height ListView ; 0x0020 => No grid lines in ListView ; 0x0100 => Calculate $iMax_Fields from first line ; 0x0200 => Calculate $iMax_Fields from first 10 lines ; 0x0400 => Calculate $iMax_Fields from first 100 lines ; $aFeatures parameter ; Features available in CSVfileDisplay: ; ; Features implemented through Common\ files (always usable): ; "ColAlign" => Column alignment ; "ColWidthMin" => Min. column width ; "ColWidthMax" => Max. column width ; "BackColor" => Listview background color ; "HdrColors" => Listview header background colors ; "UserFunc" => User supplied function ; ; Features implemented through include files ; End user features: ; Include file: ; "ColFormats" => Column text formats ; <Display function>_ColumnFormats.au3 ; "ColColors" => Column background colors ; <Display function>_ColumnColors.au3 ; "SortRows" => Sort rows in data source by index ; <Display function>_SortFuncs.au3 ; "SortCols" => Sort columns in data source by index ; <Display function>_SortFuncs.au3 ; "SortByCols" => Sort rows by multiple columns ; <Display function>_SortFuncs.au3 ; ; See DisplayFeatures.txt for docu of features ; Error codes in @error ; 1 => CSV file does not exist ; 2 => Invalid CSV file passed to function ; 3 => Missing include file ; 4 => Unsupported feature ; 6 => Too many GUIs The first four function parameters are related to the data source, the CSV file. $sCSVfile is the file name, $iEncoding is the file encoding, $sSeparator is the field separator character and $iMax_Fields is the maximum number of data fields in a line in the CSV file. The default value of $iMax_Fields is zero which means that the number of data fields is calculated automatically by inspecting the lines in top of the CSV file. How many lines that are inspected is decided through three flag values 0x0100, 0x0200, and 0x0400 which means that 1, 10 and 100 lines in top of the file are inspected. Because this inspection takes time it's limited to 100 lines. If the lines from number 101 to the end of file contains more fields than the first 100 lines you have to set $iMax_Fields manually. If the lines in the file contains 10 fields but you only want to display 7 fields you can set $iMax_Fields = 7. CSVfileDisplay main code The CSV file is loaded into a 1D array, $aCSVfile, with FileReadToArray(). Through $iFrom and $iTo parameters of the caching mechanism in the virtual listview a range of rows in $aCSVfile are split into single fields by the separator character and stored in a 2D array, $aDisplay. The visible listview cells can now be filled with data from $aDisplay. CSVfileDisplay examples Usage of $iMax_Fields and 0x0100, 0x0200, and 0x0400 flags is demonstrated in Examples\CSVfileDisplay\0) Data source\. Usage of additional features is demonstrated in Examples\CSVfileDisplay\1) Single features\. How to use CSVfileDisplay in your own project is demonstrated in Examples\CSVfileDisplay\3) Using function\. Wrapper function In most examples, the parameters $iEncoding, $sSeparator and $iMax_Fields are the same. Therefore, it's convenient to use a wrapper function to execute CSVfileDisplay(). Examples\CSVfileDisplay\CSVfileDisplayWrapper.au3 contains the wrapper function CSVfileDisplayWr() that's used in most of the examples: #include-once #include "..\..\Functions\CSVfileDisplay\CSVfileDisplay.au3" #include "..\..\Resources\CSVfileDisplay\Conv2DArray.au3" #include "..\..\Resources\CSVfileDisplay\Save1DArray.au3" Func CSVfileDisplayWr( _ $sCSVfile, _ ; Name of CSV file (plain text file) $sTitle = "", _ ; GUI title bar text, default title is set to "CSVfileDisplay" $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0100, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs CSVfileDisplay( $sCSVfile, 128, "|", 0, $sTitle, $sHeader, $iFlags, $aFeatures ) EndFunc Note that CSVfileDisplayWr() is very similar to _ArrayDisplayEx(). CSVfileDisplayWrapper.au3 also includes a couple of UDFs that are used to create CSV files on the fly.
    2 points
  4. _ArrayDisplayEx This is copied from the top of ArrayDisplayEx.au3: ; Displays a 1D or 2D array in a virtual ListView Func _ArrayDisplayEx( _ $aArray, _ ; 1D/2D array eg. StringSplit("Mo,Tu,We,Th,Fr,Sa,Su", ",") $sTitle = "", _ ; GUI title bar text, default title is set to "ArrayDisplayEx" $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0000, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs ; $iFlags values ; Add required values together ; 0x0000 => Left aligned text ; 0x0002 => Right aligned text ; 0x0004 => Centered text ; 0x0008 => Verbose mode ; 0x0010 => Half-height ListView ; 0x0020 => No grid lines in ListView ; $aFeatures parameter ; Features available in _ArrayDisplayEx: ; ; Features implemented through Common\ files (always usable): ; "ColAlign" => Column alignment ; "ColWidthMin" => Min. column width ; "ColWidthMax" => Max. column width ; "BackColor" => Listview background color ; "HdrColors" => Listview header background colors ; "UserFunc" => User supplied function ; ; Features implemented through include files ; End user features: ; Include file: ; "ColFormats" => Column text formats ; <Display function>_ColumnFormats.au3 ; "ColColors" => Column background colors ; <Display function>_ColumnColors.au3 ; "SortRows" => Sort rows in data source by index ; <Display function>_SortFuncs.au3 ; "SortCols" => Sort columns in data source by index ; <Display function>_SortFuncs.au3 ; "SortByCols" => Sort rows by multiple columns ; <Display function>_SortFuncs.au3 ; ; Debugging features: ; Include file: ; "DataTypes" => Data types info ; <Display function>_DataTypesInfo.au3 ; ; See DisplayFeatures.txt for docu of features ; Error codes in @error ; 1 => No array variable passed to function ; 2 => Larger than 2D array passed to function ; 3 => Missing include file ; 4 => Unsupported feature ; 6 => Too many GUIs Usage of additional features is demonstrated in Examples\ArrayDisplayEx\1) Single features\. How to use _ArrayDisplayEx in your own project is demonstrated in Examples\ArrayDisplayEx\3) Using function\.
    2 points
  5. Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip
    1 point
  6. No. Use this instead
    1 point
  7. $str = 'transform="translate(30) rotate(45 50 50) matrix(1,2,3,4,5,6)"' $array = stringsplit(stringtrimleft($str , 10) , ") " , 3) msgbox(0, '' , '[' & $array[0] & ')", "' & $array[1] & ')", "' & $array[2] & ']')
    1 point
  8. Use a counter (e.g. $i) that starts with 0 and is incremented each time before you write new values. Set the target cell to write to like this: "A" & $i
    1 point
  9. The URL's are listed as an array. Ignore the StringReplace if you didn't want http changed to https. #include <Array.au3> Local $iMax = 10 Local $arr[$iMax] = [3, "autoitscript.com", "test.com/", "http://test.com"] For $i = 1 To $arr[0] $a = $arr[$i] $b = StringReplace($a, "http://", "") If Not StringInStr($b, "https") Then $aAddHttp = "https://" & $b ConsoleWrite($aAddHttp & @LF) EndIf Next
    1 point
  10. Danp2

    get element collection

    The site uses IFrames. You will need to use _IEFrameGetObjByName to get a reference to the correct frame. Once you have that, then you can use the standard _IE* commands to interact with the form and it's elements. Come back with some code showing what you've tried and the outcome.
    1 point
  11. Danp2

    Read page Iexplorer

    That page contains multiple forms, so you'll need to make sure that you get a reference to the correct one. Here's how I would try to do this -- #include <IE.au3> Local $oIE = _IECreate("https://www.agenziadoganemonopoli.gov.it/portale/login") Local $oForm = _IEGetObjById($oIE, "_58_INSTANCE_XbJk5yMmHuZl_fm") Local $oElm = _IEFormElementGetObjByName($oForm, "_58_INSTANCE_XbJk5yMmHuZl_login") _IEFormElementSetValue($oElm, "xxxxx") $oElm = _IEFormElementGetObjByName($oForm, "_58_INSTANCE_XbJk5yMmHuZl_password") _IEFormElementSetValue($oElm, "yyyyy") _IEFormSubmit($oForm)
    1 point
  12. 1. Remove "Urgent" from your topic 2. Stop making us work so hard to help you. Provide all information in one place.
    1 point
  13. Version 1.0.0

    1,560 downloads

    Function for enabling Aero-like blur effect in Windows 10.
    1 point
  14. uhhhhhh... Limits???? In autoit? Yea, right... I for one also thought there were limits in autoit, nah man there's no limits, I believe someone smart once said :" you get out of autoit what put into autoit" and that's undeniably true, for one it might not use asp.net development environment but there's a huge library of pretty much everything you need to create about anything, it's solely up to you. I'm a newbie developer and I am developing software used by meduim to large sized companies, like a databasis for a university that needs to have all their students' information on record, Guesthouse managing software for our local Guesthouses and GuestLodges... and autoit has proven itself a more than worthy development programming language... JUST LOOK AT ALL PROGRAMMERS ON THIS FORUM NEWBIE OR NOT... it's all up to you, it was a lesson I had to learn myself and the bonus is, autoit is waaaaaaaaaaayyyyyy easy unlike other languages you dont need to go for courses to be able to develop in autoit thats a +100 to autoit...
    1 point
×
×
  • Create New...