Leaderboard
Popular Content
Showing content with the highest reputation on 04/09/2018 in all areas
-
; ;################################## ; Include ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $SmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED $FromName = "Name" ; name from who the email was sent $FromAddress = "your@Email.Address.com" ; address from where the mail should come $ToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED $Subject = "Userinfo" ; subject from the email - can be anything you want it to be $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed $BccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "******" ; username for the account used from where the mail gets sent - REQUIRED $Password = "********" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required ;~ $SmtpServer = "smtp.gmail.com" ; GMAIL address for the smtp-server to use - REQUIRED ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAIL enables/disables secure socket layer sending - put to 1 if using https ;~ $SmtpServer = "smtp.office365.com" ; O365 address for the smtp-server to use - REQUIRED ;~ $IPPort=25 ; O365 port used for sending the mail ;~ $ssl=1 ; O365 enables/disables secure socket layer sending - put to 1 if using https ;~ SmtpServer = "smtp.mail.yahoo.com" ; Yahoo address for the smtp-server to use - REQUIRED ;~ $IPPort = 465 ; Yahoo port used for sending the mail ;~ $ssl = 1 ; Yahoo enables/disables secure socket layer sending - put to 1 if using https ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; ; The UDF Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0, $tls = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc Edit: Fixed Bcc ... Edit: Added support for different port and SLL which are used by GMail (Port 465) Edit: Added Importance support (10/2008) EDIT: Added $TLS option (07/2020 Some interesting Info from the thread:1 point
-
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.7z1 point
-
nhockm4v, _ArraySort and the internal ListView sort algorithms are not the same, which is why you get different results. I suggest using leading zeroes like this: #include <Array.au3> local $array = ['10c','6b','6c','6d','10b','7b','8a','9d','2c','5a','ab','bb'] ; Add leading zero to all elements that start with a digit For $i = 0 To UBound($array) - 1 If Number($array[$i]) Then $array[$i] = StringFormat("%03s", $array[$i]) EndIf Next ; And here they are _ArrayDisplay($array) ; Now sort the array _ArraySort($array) ; And then remove any leading zeros For $i = 0 To UBound($array) - 1 If StringLeft($array[$i], 1) = "0" Then $array[$i] = StringtrimLeft($array[$i], 1) EndIf Next ; Et voila! _ArrayDisplay($array) M23 Edit: Search the forum for "natural sort" and you will find quite a few implementations which will sort as you require.1 point
-
1 point
-
ProcessExists stops working?
Earthshine reacted to BrewManNH for a topic
I can't duplicate the problem, but I rewrote your code to avoid the Globals that you were using. Plus, you redeclared the $PID variable inside the function, which wasn't needed or desired. #include <AutoItConstants.au3> _Main() Func _Main() Local $iRelaunchTrack, $iRelaunchMax = 5 Local $sStdout Local $PID = _Launch() While 1 If Not ProcessExists($PID) Then ConsoleWrite('Process lost (' & $PID & ')' & @LF) If $iRelaunchTrack < $iRelaunchMax Then $iRelaunchTrack += 1 ConsoleWrite('Relaunch attempt #' & $iRelaunchTrack & @LF) $PID = _Launch() Else ConsoleWrite('Relaunch has been attempted over ' & $iRelaunchTrack & ' times. Exiting for safety.' & @CRLF) ExitLoop EndIf Else $sStdout = StdoutRead($PID) If Not @error And $sStdout Then ConsoleWrite('<Server> ' & $sStdout & @LF) EndIf EndIf WEnd EndFunc ;==>_Main Func _Launch() $Temp = Run(@ComSpec, @MyDocumentsDir, @SW_SHOW, BitOR($STDIN_CHILD, $STDERR_MERGED)) ConsoleWrite('Process has been launched (' & $Temp & ')' & @LF) Return $Temp EndFunc ;==>_Launch1 point -
Add some error checking. Each of these commands should return a value indicating either success or failure. You could also try using ControlSend.1 point
-
Not sure that you can use the ID number from AU3Info like that. Instead I would use the info under advanced mode, Also, there seems to be some syntax issues in your code. Have you tried either of these methods? -- ControlSetText("FILES NOTES", "", "[CLASS:Edit, INSTANCE:1]", $acno) or ControlFocus("FILES NOTES", "", "[CLASS:Edit, INSTANCE:1]") ControlCommand("FILES NOTES", "", "[CLASS:Edit, INSTANCE:1]", "EditPaste", $acno) ; paste acno1 point
-
@nhockm4v Same Question was asked 3 posts above yours, and the answer is just 2 post above yours Cheers /Rex1 point
-
Read text file from web
coffeeturtle reacted to Danyfirex for a topic
Hello. this should work. Local $sText=BinaryToString(InetRead("https://drive.google.com/uc?id=1Cmk5-Mr10CwDcie37sb4AmhHj6D8S9C5&export=download")) ConsoleWrite($sText & @CRLF) Saludos1 point -
@JohnOne, You, my sir, are a champion. I have no idea why DPI scaling would cause this issue. My screen was set to 125%. It seems the pixels stay as they are in the software, but my screen shifts the pixels before displaying them on the screen. It works fine now.1 point
-
TAMIRI, I would have thought this better - you quit the For...Next loop immediately, whereas your version runs the loop for 1000 times regardless: For $x = 1 to 1000 If $bInterrupt Then ExitLoop Else Sleep(500) ConsoleWrite("again " & $x & @CRLF) EndIf Next M231 point
-
Sounds like a dpi issue, seeing a lot of this lately. Worth a search. Would make sense for the dpi issue to be dealt with internally, in my worthless opinion (IMWO)1 point
-
LBS_DISABLENOSCROLL => LB = ListBox not LV = ListView Not interchangeable1 point