Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/21/2018 in all areas

  1. Hi. The ASCII-ArrayDisplay returned to letters says „C:\zoek_results.log.txt“. Is it true? Maybe .txt is hidden by windows because it’s a known extension? Simpel
    2 points
  2. There are three ways you can posts scripts, these are: Inline code Attachments Download system Each has different advantages and disadvantages. In general you should use: Inline code - for short code snippets Attachments - for more complicated code larger than a page. Downloads system - for projects or complex libraries Inline Code Best for entering short snippets of code Easiest for other users to see May be accidentally modified by forum upgrades or when re-editing your post - it's happened before... Inline code is entered using the "Add Code" button in the toolbar and after posting appears with syntax highlighting like this: ; This is some AutoIt code MsgBox(4096, "Message", "Hello there!") Code over around 50 lines will appear in a scrollable box. At this point it becomes more difficult for other users to work with and you should consider an attachment instead. Attachments Best for long pieces of code, entire programs, or multiple files Unlikely to be accidentally lost or modified by forum upgrades or when re-editing your post Counts against your global attachment allocation Can be seen in the "username / My Attachments" part of your profile, along with the number of downloads Multiple attachments can be added to a post. As attachments are stored as complete files in the filesystem, they are more robust than inline code snippets. Downloads System Best for very long and complicated projects or libraries that are of significant use to the community Uses a different part of the forum that is optimised for file downloads and features screenshots, change logs, download counts, etc. Does not count against your global attachment allocation This can be accessed here: Downloads System.
    1 point
  3. @stick3r INI files are useful when you have to store some informations. Take a look at this: #include <MsgBoxConstants.au3> Global $strINIFile = @ScriptDir & "\INIFile.ini", _ ; INI in which you store the "save path" $strFileSavePath = "", _ ; Save path obtained from FileSaveDialog() $arrINISectionValues ; If a SavePath is set, show the SetPath set. $strFileSavePath = FileSaveDialog("Save file", @ScriptDir, "Text files (*.txt)") If @error = 1 Then MsgBox($MB_ICONERROR, "", "File selection failed." & @CRLF & _ "Error: " & @error) Exit ElseIf @error = 2 Then MsgBox($MB_ICONERROR, "", "Bad file filter." & @CRLF & _ "Error: " & @error) Exit Else IniWrite($strINIFile, "Options", "SavePath", $strFileSavePath) EndIf $arrINISectionValues = IniReadSection($strINIFile, "Options") If @error Then MsgBox($MB_ICONERROR, "", "Error while reading the section of the file '" & @CRLF & _ $strINIFile & "'." & @CRLF & _ "Error: " & @error) Else MsgBox($MB_ICONINFORMATION, "", "The file will be saved in '" & $arrINISectionValues[1][1] & "' folder.") EndIf Cheers
    1 point
  4. You can get the array rows deleted faster using the range option of ArrayDelete. Using this option, you can go forward through the array as well. Func _allfilesetdata() Local $aFiles = _FileListToArray(@ScriptDir, "*.txt", $FLTA_FILES, True) Local $aLines Local $sDeleteRows = "" For $i = 1 To $aFiles[0] _FileReadToArray($aFiles[$i], $aLines) If IsArray($aLines) Then For $j = 1 To $aLines[0] If $aLines[$j] = "" Then $sDeleteRows &= $j & ";" Next $sDeleteRows = StringTrimRight($sDeleteRows, 1) ;Remove last ";". _ArrayDelete($aLines, $sDeleteRows) ;Delete multiple rows. $aLines[0] = UBound($aLines) - 1 ;Change $aLines[0] to current array size. For $j = 1 To $aLines[0] GUICtrlSetData($Edit1, $aLines[$j] & @CRLF,1) Next EndIf Next EndFunc ;==>_allfilesetdata Adam
    1 point
  5. I know and fully understand the issue but simply want to tell the OP he needs to get his shit together before posting! ( don't tell him I told you ...ok? We keep this our secret )
    1 point
  6. No pictures please ... just the text is fine .... and I guess this error is something like:
    1 point
  7. When deleting in a array: Always from the end. The usual when deleting in a array from the begin. @youtuber When deleting in a array: Always from the end. Faster solution desc lieorder: Func _allfilesetdata() Local $aFiles = _FileListToArray(@ScriptDir, "*.txt", $FLTA_FILES, True) Local $aLines For $i = 1 To $aFiles[0] _FileReadToArray($aFiles[$i], $aLines) If IsArray($aLines) Then For $j = $aLines[0] To 1 Step -1 If $aLines[$j] = "" Then _ArrayDelete($aLines, $j) Else GUICtrlSetData($Edit1, $aLines[$j]) EndIf Next EndIf Next EndFunc ;==>_allfilesetdata if you want to have right lineorder must be: Func _allfilesetdata() Local $aFiles = _FileListToArray(@ScriptDir, "*.txt", $FLTA_FILES, True) Local $aLines For $i = 1 To $aFiles[0] _FileReadToArray($aFiles[$i], $aLines) If IsArray($aLines) Then For $j = $aLines[0] To 1 Step -1 If $aLines[$j] = "" Then _ArrayDelete($aLines, $j) Next For $j = 1 To $aLines[0] GUICtrlSetData($Edit1, $aLines[$j]) Next EndIf Next EndFunc ;==>_allfilesetdata
    1 point
  8. Based on your example, this modified example informs the user that one unicode character will be replaced with another unicode character. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AdlibRegister("check", 250) Local $msg GUICreate("Test", 300, 300) Global $input = GUICtrlCreateInput(" " & ChrW(0x03BC), 10, 10, 280, 40) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE AdlibUnRegister("check") ExitLoop EndSelect WEnd GUIDelete() Func check() If StringInStr(GUICtrlRead($input), ChrW(0x03BC)) Then ;~ This is the actual character "µ" that has the hexadecimal unicode code "0x03BC". MsgBox(0, "Illegal character entered.", 'Unicode character 0x03BC, "' & ChrW(0x03BC) & '"' & @CRLF & _ ' will be replaced with, ' & @CRLF & _ 'Unicode character 0x00B5, "' & ChrW(0x00B5) & '"') GUICtrlSetData($input, StringReplace(GUICtrlRead($input), ChrW(0x03BC), ChrW(0x00B5))) MsgBox(0, "", "Done", 1) EndIf EndFunc ;==>check
    1 point
  9. Actually the ArrayUnique will always return a one dimensional array for what ever column you selected, in your case Column 0. What I would do is use Excel to remove the duplicates prior to copying the range, for example add the top three lines above the _Excel_RangeRead function: Local $iRows = $oWorkbook.ActiveSheet.UsedRange.Rows.Count Local $aColumns[] = [1, 2, 3, 4, 5, 6, 7 , 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] $oWorkbook.ActiveSheet.Range("A1:Q" & $iRows).RemoveDuplicates($aColumns) ; Read the formulas of a cell range on sheet 2 of the specified workbook Local $aResult = _Excel_RangeRead($oWorkbook, 1, Default, 1) ....
    1 point
  10. Do you require _ArrayUnique() function? It would be throwing off the indexing in the array? For example if you had 10 Rows with 5 duplicates, when you use _ArrayUnique you only have 5 items showing in the list, however your array will still have 10. If you don't mind having duplicates than you can use something like, below, I also didn't know how you were saving your data from your array back into the database, the Savedb function would have just saved the same results, I've added in a way to save the results to a new file named @Year-@Mon-@Mday_@Hour@Min@Sec_Process.xlsx just to show how to save the data, otherwise you would need to clear all the existing data from the spreadsheet and add the $aResult to the sheet: Hope that makes sense. ; #INDEX# ================================================================================================= ; Name ..........: Process dB Manager ; Version Date ..: 2018-09-17 ; AutoIt Version : 3.3.8.1 ; Author(s) .....: Charles Wright ; Dll(s) ........: ; Error handling : ; ========================================================================================================= ; #Notes# ================================================================================================= ; Columns: 0 = Process - $Process - 21 9 = Gold Strike - $GoldStrike - 36 ; 1 = Rev - $Rev - 22 10 = Notes - $Edit1 - 37 ; 2 = Type - $Type - 23 11 = Drawing Control - $DrawingControl - 25 ; 3 = ROHS - $ROHS - 24 12 = Copper Reference - $CopperRef - 31 ; 4 = Copper - $Copper - 26 13 = Electroless Nickel Reference - $ElectrolessRef - 32 ; 5 = Electroless Nickel - $ElectrolessN - 27 14 = Electrolytic Nickel Reference - $ElectrolyticRef - 33 ; 6 = Electrolytic Nickel - $ElectrolyticN - 28 15 = Silver Reference - $SilverRef - 34 ; 7 = Silver - $SilverRef - 29 16 = Gold Ref - $GoldRef - 35 ; 8 = Gold - $Gold - 30 ; ========================================================================================================= ; Includes ================================================================================================ #include <Array.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <Excel.au3> #include "ExtMsgBox.au3" #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiListBox.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;========================================================================================================== ; Variables =============================================================================================== $idMsg = 0 $iIndex = "" ;========================================================================================================== ; Create application object Local $oExcel = _Excel_Open(False) _ExtMsgBoxSet(1,0,default, default, 10, "Consolas", 1000, 1000) ;========================================================================================================== ; Excel Process =========================================================================================== If @error Then Exit _ExtMsgBox(64,0, "Error", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Open an existing workbook and return its object identifier. Local $sSavebook = @ScriptDir & "\" & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & @SEC & "_Process.xlsx" Local $sWorkbook = @ScriptDir & "\Process.xlsx" _ExtMsgBox(64,0, "Directory", $sWorkbook) Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, False, False) If @error Then Exit _ExtMsgBox(64,0, "Process Opening", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _ExtMsgBox(64,0, "Process Opening", $sWorkbook & " has been opened successfully") ; Read the formulas of a cell range on sheet 2 of the specified workbook Local $aResult = _Excel_RangeRead($oWorkbook, 1, Default, 1) If @error Then Exit _ExtMsgBox(64,0, "Process Load Report", "Error loading Processes." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _ExtMsgBox(64,0, "Process Load Report", "Processes successfully loaded." & @CRLF & "Please click 'OK'") _Excel_BookClose($oWorkbook, False) If @error Then Exit _ExtMsgBox(16,0, "Process Close Report", "Error closing processes." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _ExtMsgBox(64,0, "Process Close Report", "Processes successfully closed.") $oWorkbook = _Excel_BookNew($oExcel) ;Array Debugging Code - Comment out after testing ;Local $iRows = UBound($aResult, $UBOUND_ROWS) ; Total number of rows. In this example it will be 10. ;Local $iCols = UBound($aResult, $UBOUND_COLUMNS) ; Total number of columns. In this example it will be 20. ;Local $iDimension = UBound($aResult, $UBOUND_DIMENSIONS) ; The dimension of the array e.g. 1/2/3 dimensional.; ; ;MsgBox($MB_SYSTEMMODAL, "", "The array is a " & $iDimension & " dimensional array with " & _ ; $iRows & " row(s) & " & $iCols & " column(s).") ; _ArrayInsert($aResult, 0, UBound($aResult) - 1) $sModel = _ArrayToString($aResult, "|", 0, -1, "|", 0, 0) ;$stlModel = StringTrimLeft($sModel, 12) ;_ArrayDisplay($aModel, "$aModel Array") ;_ArrayDisplay($aResult, "$aResult Array") ;MsgBox($MB_SYSTEMMODAL, "$sModel String", $sModel) ;MsgBox($MB_SYSTEMMODAL, "$stlModel String", $stlModel) ;========================================================================================================== ; Gui ===================================================================================================== $Form1_1 = GUICreate("Process dB Manager", 653, 543, 740, 105) GUISetBkColor(0xFFFBF0) $Label1 = GUICtrlCreateLabel("Process:", 136, 16, 57, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Rev:", 296, 16, 32, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("Type", 416, 16, 36, 20, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("ROHS:", 464, 72, 46, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label5 = GUICtrlCreateLabel("Copper:", 200, 112, 52, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label6 = GUICtrlCreateLabel("Electroless Nickel:", 136, 144, 115, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label7 = GUICtrlCreateLabel("Electrolytic Nickel:", 136, 176, 113, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label8 = GUICtrlCreateLabel("Silver:", 208, 208, 41, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label9 = GUICtrlCreateLabel("Gold:", 216, 240, 36, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label10 = GUICtrlCreateLabel("Drawing Control:", 152, 72, 101, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label11 = GUICtrlCreateLabel("Copper Ref:", 432, 112, 76, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label12 = GUICtrlCreateLabel("Electroless Ref:", 416, 144, 98, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label13 = GUICtrlCreateLabel("Electrolytic Ref:", 416, 176, 96, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label14 = GUICtrlCreateLabel("Silver Ref:", 440, 208, 65, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label15 = GUICtrlCreateLabel("Gold Ref:", 448, 240, 60, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label16 = GUICtrlCreateLabel("Gold Strike", 440, 272, 70, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label17 = GUICtrlCreateLabel("Notes:", 136, 304, 43, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $List1 = GUICtrlCreateList("", 8, 16, 113, 409, BitOr($WS_BORDER, $WS_VSCROLL)) ; 20 $iDummyStart = GUICtrlCreateDummy() $Process = GUICtrlCreateInput("", 200, 16, 65, 24) ; 21 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Rev = GUICtrlCreateInput("", 336, 16, 41, 24) ; 22 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Type = GUICtrlCreateInput("", 464, 16, 73, 24) ;23 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ROHS = GUICtrlCreateInput("", 512, 72, 25, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) ;24 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $DrawingControl = GUICtrlCreateInput("", 264, 72, 185, 24) ; 25 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Copper = GUICtrlCreateInput("", 264, 112, 121, 24) ;26 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ElectrolessN = GUICtrlCreateInput("", 264, 144, 121, 24) ;27 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ElectrolyticN = GUICtrlCreateInput("", 264, 176, 121, 24) ;28 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Silver = GUICtrlCreateInput("", 264, 208, 121, 24) ; 29 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Gold = GUICtrlCreateInput("", 264, 240, 121, 24) ; 30 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $CopperRef = GUICtrlCreateInput("", 520, 112, 121, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ElectrolessRef = GUICtrlCreateInput("", 520, 144, 121, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ElectrolyticRef = GUICtrlCreateInput("", 520, 176, 121, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $SilverRef = GUICtrlCreateInput("", 520, 208, 121, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $GoldRef = GUICtrlCreateInput("", 520, 240, 121, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $GoldStrike = GUICtrlCreateInput("", 520, 272, 25, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Edit1 = GUICtrlCreateEdit("", 184, 304, 457, 121) GUICtrlSetData(-1, "Edit1") $iDummyEnd = GUICtrlCreateDummy() $UpdateRecord = GUICtrlCreateButton("Update Record", 88, 448, 99, 25) ; 38 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $DeleteRecord = GUICtrlCreateButton("Delete Record", 264, 448, 107, 25) ; 39 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $SavedB = GUICtrlCreateButton("Save Database", 464, 448, 107, 25) ; 40 GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") ;========================================================================================================== ; GUICtrlSet ============================================================================================== GUISetState(@SW_SHOW) GUICtrlSetData($List1, $sModel) ;========================================================================================================== ; While Loop / Cases ====================================================================================== While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE _Excel_BookClose($oWorkbook, False) If @error Then Exit _ExtMsgBox(16,0, "Process Close Report", "Error closing processes." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _ExtMsgBox(64,0, "Process Close Report", "Processes successfully closed.") WinClose($oWorkbook, "Microsoft Excel") If Not @error Then _ExtMsgBox(64,0, "Excel", "Excel has been successfully closed.") Else _ExtMsgBox(16,0, "Excel", "Excel has failed to be closed.") EndIf ExitLoop Case $idMsg = $GUI_EVENT_MINIMIZE _ExtMsgBox(64,0, "", "Process Manager minimized", 2) Case $idMsg = $GUI_EVENT_MAXIMIZE _ExtMsgBox(64,0, "", "Process Manager restored", 2) Case $idMsg = $List1 _Select() Case $idMsg = $UpdateRecord _Update() Case $idMsg = $DeleteRecord _Delete() Case $idMsg = $SavedB _SavedB() EndSelect WEnd ;========================================================================================================== ; Functions =============================================================================================== Func _Select() ;$Combo1 - Selection of Process from Array to display in GUI $iIndex = _GUICtrlListBox_GetCurSel($List1) GUICtrlRead($Process, $aResult[$iIndex][0]) ;0 / 21 GUICtrlSetData($Process, $aResult[$iIndex][0]) ;0 / 21 GUICtrlSetData($Rev, $aResult[$iIndex][1]) ;1 / 22 GUICtrlSetData($Type, $aResult[$iIndex][2]) ;2 / 23 GUICtrlSetData($ROHS, $aResult[$iIndex][3]) ;3 / 24 GUICtrlSetData($Copper, $aResult[$iIndex][4]) ;4 / 26 GUICtrlSetData($ElectrolessN, $aResult[$iIndex][5]) ;5 / 27 GUICtrlSetData($ElectrolyticN, $aResult[$iIndex][6]) ;6 / 28 GUICtrlSetData($Silver, $aResult[$iIndex][7]) ;7 ; 29 GUICtrlSetData($Gold, $aResult[$iIndex][8]) ;8 / 30 GUICtrlSetData($GoldStrike, $aResult[$iIndex][9]) ;9 / 36 GUICtrlSetData($Edit1, $aResult[$iIndex][10]) ;10 / 37 GUICtrlSetData($DrawingControl, $aResult[$iIndex][11]) ;11 / 25 GUICtrlSetData($CopperRef, $aResult[$iIndex][12]) ;12 / 31 GUICtrlSetData($ElectrolessRef, $aResult[$iIndex][13]) ;13 / 32 GUICtrlSetData($ElectrolyticRef, $aResult[$iIndex][14]) ;14 / 33 GUICtrlSetData($SilverRef, $aResult[$iIndex][15]) ;15 / 34 GUICtrlSetData($GoldRef, $aResult[$iIndex][16]) ;16 / 35 EndFunc ;==>_Select Func _Update() ;$Combo1 - Selection of Process from Array to display in GUI $iIndex = _GUICtrlListBox_GetCurSel($List1) $aResult[$iIndex][0] = GUICtrlRead($Process) ;0 / 21 $aResult[$iIndex][1] = GUICtrlRead($Rev) ;1 / 22 $aResult[$iIndex][2] = GUICtrlRead($Type) ;2 / 23 $aResult[$iIndex][3] = GUICtrlRead($ROHS) ;3 / 24 $aResult[$iIndex][4] = GUICtrlRead($Copper) ;4 / 26 $aResult[$iIndex][5] = GUICtrlRead($ElectrolessN) ;5 / 27 $aResult[$iIndex][6] = GUICtrlRead($ElectrolyticN) ;6 / 28 $aResult[$iIndex][7] = GUICtrlRead($Silver) ;7 ; 29 $aResult[$iIndex][8] = GUICtrlRead($Gold) ;8 / 30 $aResult[$iIndex][9] = GUICtrlRead($GoldStrike) ;9 / 36 $aResult[$iIndex][10] = GUICtrlRead($Edit1) ;10 / 37 $aResult[$iIndex][11] = GUICtrlRead($DrawingControl) ;11 / 25 $aResult[$iIndex][12] = GUICtrlRead($CopperRef) ;12 / 31 $aResult[$iIndex][13] = GUICtrlRead($ElectrolessRef) ;13 / 32 $aResult[$iIndex][14] = GUICtrlRead($ElectrolyticRef) ;14 / 33 $aResult[$iIndex][15] = GUICtrlRead($SilverRef) ;15 / 34 $aResult[$iIndex][16] = GUICtrlRead($GoldRef) ;16 / 35 EndFunc ;==>_Select Func _Delete() ;~ Clear all fields For $i = $iDummyStart To $iDummyEnd GUICtrlSetData($i, "") Next $iIndex = _GUICtrlListBox_GetCurSel($List1) _ArrayDelete($aResult, $iIndex) $aResult[0][0] = UBound($aResult) - 1 _GUICtrlListBox_ReplaceString($List1, 0, $aResult[0][0]) _GUICtrlListBox_DeleteString($List1, $iIndex) $iListCount = _GUICtrlListBox_GetCount($List1) If $iIndex >= $iListCount Then _GUICtrlListBox_ClickItem($List1, $iListCount - 1) Else _GUICtrlListBox_ClickItem($List1, $iIndex) EndIf EndFunc Func _SavedB() _ArrayDelete($aResult, 0) _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aResult) _Excel_BookSaveAs($oWorkbook, $sSavebook, $xlWorkbookDefault, False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel Error", "Error saving workbook to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel Message", "Workbook successfully saved as '" & $sWorkbook & "'.") ShellExecute($sWorkbook) EndFunc
    1 point
  11. As the manual clearly states, you need to open a specified COM port at initialisation of the board. Something like this perhaps (untested!): $myCOMport = 1 $HOPPER_OPENCOM = DllCall($CashDLL,"LONG","HOPPER_OPENCOM", "long", $myCOMport) You can examine a dll for example with dependency walker.
    1 point
  12. Not sure you know but you can just use a similar method to your _Select() function except rather than use _ArraytoString just access the data directly, also you should try to keep your list and your array synchronized that way you can use the selected index in the Listbox as the index of the array. For the two functions below to work correctly you would need to change the following line from 0 to 1 meaning don't include the count since your array doesn't use a count. Hope that makes sense. $sModel = _ArrayToString($aTempModel, "|", 1) ; Functions =============================================================================================== Func _Select() ;$Combo1 - Selection of Process from Array to display in GUI $iIndex = _GUICtrlListBox_GetCurSel($List1) GUICtrlRead($Process, $aResult[$iIndex][0]) ;0 / 21 GUICtrlSetData($Rev, $aResult[$iIndex][1]) ;1 / 22 GUICtrlSetData($Type, $aResult[$iIndex][2]) ;2 / 23 GUICtrlSetData($ROHS, $aResult[$iIndex][3]) ;3 / 24 GUICtrlSetData($Copper, $aResult[$iIndex][4]) ;4 / 26 GUICtrlSetData($ElectrolessN, $aResult[$iIndex][5]) ;5 / 27 GUICtrlSetData($ElectrolyticN, $aResult[$iIndex][6]) ;6 / 28 GUICtrlSetData($Silver, $aResult[$iIndex][7]) ;7 ; 29 GUICtrlSetData($Gold, $aResult[$iIndex][8]) ;8 / 30 GUICtrlSetData($GoldStrike, $aResult[$iIndex][9]) ;9 / 36 GUICtrlSetData($Edit1, $aResult[$iIndex][10]) ;10 / 37 GUICtrlSetData($DrawingControl, $aResult[$iIndex][11]) ;11 / 25 GUICtrlSetData($CopperRef, $aResult[$iIndex][12]) ;12 / 31 GUICtrlSetData($ElectrolessRef, $aResult[$iIndex][13]) ;13 / 32 GUICtrlSetData($ElectrolyticRef, $aResult[$iIndex][14]) ;14 / 33 GUICtrlSetData($SilverRef, $aResult[$iIndex][15]) ;15 / 34 GUICtrlSetData($GoldRef, $aResult[$iIndex][16]) ;16 / 35 EndFunc ;==>_Select Func _Update() ;$Combo1 - Selection of Process from Array to display in GUI $iIndex = _GUICtrlListBox_GetCurSel($List1) $aResult[$iIndex][0] = GUICtrlRead($Process) ;0 / 21 $aResult[$iIndex][1] = GUICtrlRead($Rev) ;1 / 22 $aResult[$iIndex][2] = GUICtrlRead($Type) ;2 / 23 $aResult[$iIndex][3] = GUICtrlRead($ROHS) ;3 / 24 $aResult[$iIndex][4] = GUICtrlRead($Copper) ;4 / 26 $aResult[$iIndex][5] = GUICtrlRead($ElectrolessN) ;5 / 27 $aResult[$iIndex][6] = GUICtrlRead($ElectrolyticN) ;6 / 28 $aResult[$iIndex][7] = GUICtrlRead($Silver) ;7 ; 29 $aResult[$iIndex][8] = GUICtrlRead($Gold) ;8 / 30 $aResult[$iIndex][9] = GUICtrlRead($GoldStrike) ;9 / 36 $aResult[$iIndex][10] = GUICtrlRead($Edit1) ;10 / 37 $aResult[$iIndex][11] = GUICtrlRead($DrawingControl) ;11 / 25 $aResult[$iIndex][12] = GUICtrlRead($CopperRef) ;12 / 31 $aResult[$iIndex][13] = GUICtrlRead($ElectrolessRef) ;13 / 32 $aResult[$iIndex][14] = GUICtrlRead($ElectrolyticRef) ;14 / 33 $aResult[$iIndex][15] = GUICtrlRead($SilverRef) ;15 / 34 $aResult[$iIndex][16] = GUICtrlRead($GoldRef) ;16 / 35 EndFunc ;==>_Select
    1 point
  13. Redim $array[ubound($array)+1)][ubound ($array,2)] Then loop through that last row of the array and set the data.
    1 point
  14. Danp2

    Headless Chrome and AutoIt

    Have you reviewed this method? https://github.com/cyrus-and/chrome-remote-interface/issues/164
    1 point
  15. I've had this thing I wrote up laying around for a while now and decided I'd comment the heck out of it and post it here for others to enjoy as well. It's a multi-client TCP server "base" that has all the boilerplate code done, the only thing that one needs to do is just whip their protocol code in to it and it's ready to go. I've included a little few-line example bit in it (in the #region stuff) for a simple echo server. A quick way to see the example work is to just start this up and use a telnet client to connect to it on the port that you chose to have it bind (default in the one I'm posting is port 8080), typing a sentence, and pressing enter. This server makes use of setting the TCPTimeout option to 0, making it quite efficient when a high number of clients are connected and making it faster at accepting new connections. It does not use a fixed-size array for storing client connections, but instead dynamically re-sizes the client array when clients disconnect or connect (Setting $MaxClients to 0 makes the number of simultaneous clients only limited by RAM or AutoIt internal limits, whatever is reached first. I've tested this at 10,000 concurrent connections successfully, albeit with some slightly elevated CPU usage ). The server also implements a simple per-client packet buffer (as shown in the little echo example) which can come in handy for things such as large packets from file transferring and such. Instead of only relying on checking @error after a TCPRecv call to determine if a client disconnected (which can lie in certain cases), this uses a checking function which implements both that @error check and an idle timeout check that disconnects the client if they have not sent anything in a certain period of time. This is not really aimed at people who are unfamiliar with sockets work in AutoIt, as this provides no real application layer protocol, you must make that yourself. The only thing this does is do all the hard and/or tedious work of managing what happens when clients try connecting, how packet data should be buffered, and when a connection should be considered "dead". If you use this in a project, a simple little comment saying you used it would be nice #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 (Or greater) Author: Ken Piper Script Function: Template multi-client server base code. Use as a base for making an efficient server program. This base will just accept connections and echo back what it receives, and kill the connection if it is dead or inactive for x seconds. It will not do any other work, that must be added seperately! #ce ---------------------------------------------------------------------------- TCPStartup() Opt("TCPTimeout", 0) #region ;Safe-to-edit things are below Global $BindIP = "0.0.0.0" ;Listen on all addresses Global $BindPort = 8080 ;Listen on port 8080 Global $Timeout = 15000 ;Max idle time is 15 seconds before calling a connection "dead" Global $PacketSize = 2048 ;Max packet size per-check is 2KB Global $MaxClients = 50 ;Max simultaneous clients is 50 #endregion ;Stuff you shouldn't touch is below Global $Listen Global $Clients[1][4] ;[Index][Socket, IP, Timestamp, Buffer] Global $Ws2_32 = DllOpen("Ws2_32.dll") ;Open Ws2_32.dll, it might get used a lot Global $NTDLL = DllOpen("ntdll.dll") ;Open ntdll.dll, it WILL get used a lot Global $CleanupTimer = TimerInit() ;This is used to time when things should be cleaned up OnAutoItExitRegister("Close") ;Register this function to be called if the server needs to exit $Clients[0][0] = 0 $Listen = TCPListen($BindIP, $BindPort, $MaxClients) ;Start listening on the given IP/port If @error Then Exit 1 ;Exit with return code 1 if something was already bound to that IP and port While 1 USleep(5000, $NTDLL) ;This is needed because TCPTimeout is disabled. Without this it will run one core at ~100%. ;The USleep function takes MICROseconds, not milliseconds, so 1000 = 1ms delay. ;When working with this granularity, you have to take in to account the time it takes to complete USleep(). ;1000us (1ms) is about as fast as this should be set. If you need more performance, set this from 5000 to 1000, ;but doing so will make it consume a bit more CPU time to get that extra bit of performance. Check() ;Check recv buffers and do things If TimerDiff($CleanupTimer) > 1000 Then ;If it has been more than 1000ms since Cleanup() was last called, call it now $CleanupTimer = TimerInit() ;Reset $CleanupTimer, so it is ready to be called again Cleanup() ;Clean up the dead connections EndIf Local $iSock = TCPAccept($Listen) ;See if anything wants to connect If $iSock = -1 Then ContinueLoop ;If nothing wants to connect, restart at the top of the loop Local $iSize = UBound($Clients, 1) ;Something wants to connect, so get the number of people currently connected here If $iSize - 1 > $MaxClients And $MaxClients > 0 Then ;If $MaxClients is greater than 0 (meaning if there is a max connection limit) then check if that has been reached TCPCloseSocket($iSock) ;It has been reached, close the new connection and continue back at the top of the loop ContinueLoop EndIf ReDim $Clients[$iSize + 1][4] ;There is room for a new connection, allocate space for it here $Clients[0][0] = $iSize ;Update the number of connected clients $Clients[$iSize][0] = $iSock ;Set the socket ID of the connection $Clients[$iSize][1] = SocketToIP($iSock, $Ws2_32) ;Set the IP Address the connection is from $Clients[$iSize][2] = TimerInit() ;Set the timestamp for the last known activity timer $Clients[$iSize][3] = "" ;Blank the recv buffer WEnd Func Check() ;Function for processing If $Clients[0][0] < 1 Then Return ;If there are no clients connected, stop the function right now For $i = 1 To $Clients[0][0] ;Loop through all connected clients $sRecv = TCPRecv($Clients[$i][0], $PacketSize) ;Read $PacketSize bytes from the current client's buffer If $sRecv <> "" Then $Clients[$i][3] &= $sRecv ;If there was more data sent from the client, add it to the buffer If $Clients[$i][3] = "" Then ContinueLoop ;If the buffer is empty, stop right here and check more clients $Clients[$i][2] = TimerInit() ;If it got this far, there is data to be parsed, so update the activity timer #region ;Example packet processing stuff here. This is handling for a simple "echo" server with per-packet handling $sRecv = StringLeft($Clients[$i][3], StringInStr($Clients[$i][3], @CRLF, 0, -1)) ;Pull all data to the left of the last @CRLF in the buffer ;This does NOT pull the first complete packet, this pulls ALL complete packets, leaving only potentially incomplete packets in the buffer If $sRecv = "" Then ContinueLoop ;Check if there were any complete "packets" $Clients[$i][3] = StringTrimLeft($Clients[$i][3], StringLen($sRecv) + 1) ;remove what was just read from the client's buffer $sPacket = StringSplit($sRecv, @CRLF, 1) ;Split all complete packets up in to an array, so it is easy to work with them For $j = 1 To $sPacket[0] ;Loop through each complete packet; This is where any packet processing should be done TCPSend($Clients[$i][0], "Echoing line: " & $sPacket[$j] & @CRLF) ;Echo back the packet the client sent Next #endregion ;Example Next EndFunc Func Cleanup() ;Clean up any disconnected clients to regain resources If $Clients[0][0] < 1 Then Return ;If no clients are connected then return Local $iNewSize = 0 For $i = 1 To $Clients[0][0] ;Loop through all connected clients $Clients[$i][3] &= TCPRecv($Clients[$i][0], $PacketSize) ;Dump any data not-yet-seen in to their recv buffer If @error > 0 Or TimerDiff($Clients[$i][2]) > $Timeout Then ;Check to see if the connection has been inactive for a while or if there was an error TCPCloseSocket($Clients[$i][0]) ;If yes, close the connection $Clients[$i][0] = -1 ;Set the socket ID to an invalid socket Else $iNewSize += 1 EndIf Next If $iNewSize < $Clients[0][0] Then ;If any dead connections were found, drop them from the client array and resize the array Local $iSize = UBound($Clients, 2) - 1 Local $aTemp[$iNewSize + 1][$iSize + 1] Local $iCount = 1 For $i = 1 To $Clients[0][0] If $Clients[$i][0] = -1 Then ContinueLoop For $j = 0 To $iSize $aTemp[$iCount][$j] = $Clients[$i][$j] Next $iCount += 1 Next $aTemp[0][0] = $iNewSize $Clients = $aTemp EndIf EndFunc Func Close() DllClose($Ws2_32) ;Close the open handle to Ws2_32.dll DllClose($NTDLL) ;Close the open handle to ntdll.dll For $i = 1 To $Clients[0][0] ;Loop through the connected clients TCPCloseSocket($Clients[$i][0]) ;Force the client's connection closed Next TCPShutdown() ;Shut down networking stuff EndFunc Func SocketToIP($iSock, $hDLL = "Ws2_32.dll") ;A rewrite of that _SocketToIP function that has been floating around for ages Local $structName = DllStructCreate("short;ushort;uint;char[8]") Local $sRet = DllCall($hDLL, "int", "getpeername", "int", $iSock, "ptr", DllStructGetPtr($structName), "int*", DllStructGetSize($structName)) If Not @error Then $sRet = DllCall($hDLL, "str", "inet_ntoa", "int", DllStructGetData($structName, 3)) If Not @error Then Return $sRet[0] EndIf Return "0.0.0.0" ;Something went wrong, return an invalid IP EndFunc Func USleep($iUsec, $hDLL = "ntdll.dll") ;A rewrite of the _HighPrecisionSleep function made by monoceres (Thanks!) Local $hStruct = DllStructCreate("int64") DllStructSetData($hStruct, 1, -1 * ($iUsec * 10)) DllCall($hDLL, "dword", "ZwDelayExecution", "int", 0, "ptr", DllStructGetPtr($hStruct)) EndFunc Comments, questions, and criticisms are appreciated! Changelog: Cleared up formatting a bit in the [autoit] tags Fixed a bug in how it cleaned up the connection, and fixed a spelling error in the post Fixed a very rare corner-case that could cause a crash when getting many connections and disconnections in a short amount of time Changed a bit of code to fix issues with reading multiple buffered packets Fixed some spelling in the post and clean the code a bit; I try to keep this code up-to-date with the source file on my computer Fixed to add a massive performance increase when handling large numbers of connected clients and the client array needs to be trimmed. (I've seen up to a 500x speed increase on my computer!) Quick fix, apparently I forgot to set the max pending connections in TCPListen, leading for some pretty slow connection-accepting! Sorry about that. Fixed the problem of the latest AutoIt version causing "If @error Then" type statements to fail for TCPRecv, as TCPRecv now sets @error to -1 if the socket is alive but idle. This fixes the problem of clients getting instantly disconnected, sorry about not updating the code here with this sooner.
    1 point
×
×
  • Create New...