Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/17/2018 in all areas

  1. Barney

    A Connect 4 Game

    Hi guys, I just finished a Connect 4 game by using MiniMax with Alpha Beta Pruning. I haven't written a program for a long time, but writing an AI program is always funny! I have to learn how the algorithm works and try to optimize the code to run faster. Let's play and have fun! Oops, I lost the game ... Thanks guys! Download: Connect 4.zip
    2 points
  2. JohnOne

    Logout current user

    would it not be easier to just use passwords?
    2 points
  3. This is a printing UDF which allows you to print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images. Useful for labels, reports, graphs and standard forms. Can also print barcodes. It uses my printmg.dll. It is not intended to do the sorts of thing you can do with the Word UDF by big_daddy. Note the dll is 32 bit and so only works with 32 bit applications. printout from the code in the example in the download. Functions available are - Start using/Finish using the UDF _PrintDllStart _PrintDllClose _PrintVersion - Returns version of UDF or dll _PrintSetTitle Printer control _PrintStartPrint _PrintAbort _PrintEndPrint _PrintNewPage Printer selection, getting & setting parameters _PrintListPrinters - lists all installed printers _PrintSetPrinter - manual printer selection dialogue _PrintSelectPrinter - programmatically set the printer. _PrintGetPageWidth _PrintGetPaperWidth _PrintGetPageHeight _PrintGetPaperHeight _PrintGetHorRes _PrintGetVertRes _PrintGetXOffset _PrintGetYOffset _PrintPageOrientation - set portrait or landsacpe Text printing _PrintSetFont - Font, size, attributes and colour _PrintText - At x,y and angle. _PrintGetextWidth _PrintGetTextHeight Graphics _PrintSetLineCol _PrintSetLIneWid _PrintSetBrushCol - sets the colour used for filling _PrintLine _PrintEllipse - Filled ellipse or circle _PrintPie - for filled pie slice _PrintArc - Elliptical or circular arcs _PrintRectangle - filled rectangle _PrintRoundedRectangle _PrintImage - prints jpg, bmp and ico files (Has problems with some icons bigger than 64 x 64) _PrintImageFromDC Latest change = 25th February 2011 Added example to the download which was missing. Get the UDF, dll and example from here. ================================================================= See also these udf's for printing from AutoIt using the Windows API and not using a dll. by GRS - http://www.autoitscript.com/forum/topic/...m-autoit/page__view__findpost_ by Prog@ndy -http://www.autoitscript.com/forum/topic/...gdi-udfs/page__view__findpost_ and this one which embeds a dll in the script for creating pdf files. printing to a pdf by taietel see
    1 point
  4. Hi, the "struct" reserves some memory, and the "pointer" points to the first adress of this memory. Here an (not season related^^) example which demonstrates the usage of the so called "memory" (which belongs to NOTHING! (meaning the datatypes) ) ;create struct $struct =dllstructcreate("int;float[4];dword") ;fill struct with data dllstructsetdata($struct,1,123456);int dllstructsetdata($struct,2,4.80114160043301e+030,1);float dllstructsetdata($struct,2,3.68584191575527e+024,2);float dllstructsetdata($struct,2,7.71403089381636e+031,3);float dllstructsetdata($struct,2,8.24605444209785e-019,4);float dllstructsetdata($struct,3,0xDEADBEEF);dword ;read some data from struct at offset 4 $struct2=dllstructcreate("char[16]",dllstructgetptr($struct)+4) msgbox(0,":o)",dllstructgetdata($struct2,1))
    1 point
  5. basically you are giving a reference to an already created data structure you are just defining what it contains to AutoIt below is an entirely contrived example but it gives you the idea, typically the pointer would be returned from an API function $tInit = DllStructCreate("BYTE[8]") DllStructSetData($tInit, 1, 0xFF, 1) DllStructSetData($tInit, 1, 0xEE, 2) DllStructSetData($tInit, 1, 0xDD, 3) DllStructSetData($tInit, 1, 0xCC, 4) DllStructSetData($tInit, 1, 0x11, 5) DllStructSetData($tInit, 1, 0x22, 6) DllStructSetData($tInit, 1, 0x33, 7) DllStructSetData($tInit, 1, 0x44, 8) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit)) ; Using a pointer $tInit For $i = 1 To 4 ; Show Contents ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ; Setting the data here affects the original data DllStructSetData($tInitPtr, 1, 0xBB, 1) DllStructSetData($tInitPtr, 1, 0xAA, 2) DllStructSetData($tInitPtr, 1, 0x99, 3) DllStructSetData($tInitPtr, 1, 0x88, 4) ConsoleWrite(@CRLF) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInit, 1, $i)) & @CRLF) Next ;lets start at second element (DllStructGetPtr($tInit) + 0 ) is initial (first) element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 1) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ;lets start at third element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 2) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ;lets start at fourth element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 3) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next
    1 point
  6. You could FileInstall sqlite3.dll and sqlite3.exe files when you compile the exe, and extract them to the @TempDir directory for use. The files can be downloaded from here. You can just download sqlite3.exe and sqlite3.dll directly. Here is the updated example script using FileInstall and using the @TempDir. #include <Array.au3> #include <File.au3> #include <SQLite.au3> ;FileInstall needed to include SQLite files and place them in the @TempDir. Global $sWorkingDir = @TempDir & "\" FileInstall("sqlite3.exe", $sWorkingDir, $FC_OVERWRITE) ;Put sqlite3.exe in @ScriptDir. FileInstall("sqlite3.dll", $sWorkingDir, $FC_OVERWRITE) ;Put sqlite3.dll in @ScriptDir. FileChangeDir($sWorkingDir) ;Change @WorkingDir to @TempDir to work with files. Global $sOutFile = "test.csv" Global $sDir = @ScriptDir & "\Test" Global $aFileList = _FileListToArrayRec($sDir, "*.csv", $FLTAR_FILES, $FLTAR_RECUR) If @error Then Exit 1 ;~ _ArrayDisplay($aFileList) ;For testing. ;Use sqlite3.exe to import files. ;Make sure sqlite3.exe is in the @ScriptDir. ;Use CSV mode for importing and exporting data. Global $sSQLiteExeInput = ".mode csv" & @CRLF ;Table name must not contain spaces, use underscores. Global $sTableName = "Data" $sTableName = StringReplace($sTableName, " ", "_") $sSQLiteExeInput &= "CREATE TABLE " & $sTableName & "(Year,Month,Day,Time,Data);" & @CRLF ;Import files into SQLite table. For $i = 1 To $aFileList[0] $sSQLiteExeInput &= ".import '" & $sDir & "\" & $aFileList[$i] & "' " & $sTableName & @CRLF Next ;Remove NULL rows, if any from import. $sSQLiteExeInput &= 'DELETE FROM "' & $sTableName & '" WHERE "Data" IS NULL;' & @CRLF ;Add DateTime Column, and data to the column to allow for easier searching. $sSQLiteExeInput &= 'ALTER TABLE "' & $sTableName & '" ADD COLUMN "DateTime";' & @CRLF $sSQLiteExeInput &= 'UPDATE "' & $sTableName & '" SET "DateTime" = "Year" || ''-'' || "Month" || ''-'' || "Day" || '' '' || "Time";' & @CRLF $sSQLiteExeInput &= 'CREATE INDEX idxTS ON "' & $sTableName & '"(DateTime);' & @CRLF ;Quit SQLite3.exe $sSQLiteExeInput &= ".quit" & @CRLF Global $sOutFileDB = StringTrimRight($sOutFile, 3) & "db" Global $sSQLiteExeOutput ConsoleWrite($sSQLiteExeInput & @CRLF) ;For testing. ;Execute sqlite3.exe commands. _SQLite_SQLiteExe($sOutFileDB, $sSQLiteExeInput, $sSQLiteExeOutput) If @error Then If @error = 2 Then ConsoleWrite("ERROR: Sqlite3.exe file not found" & @CRLF) Else ConsoleWrite("ERROR: @error=" & @error & " when calling _SQLite_SQLiteExe" & @CRLF) EndIf Exit 1 EndIf ;Get data requested. ;Make sure sqlite3 DLL is in the @ScriptDir. Global $iRows, $iColumns, $aOutFile ConsoleWrite(_SQLite_Startup() & @CRLF) ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF) _SQLite_Open($sOutFileDB) Global $sSearchDateTime = "2018-2-1 1:00" ;Sum data values for date. Global $sSQLQuery = 'SELECT Year,Month,Day,Time,sum(Data) FROM "' & $sTableName & '" WHERE "DateTime" = ''' & $sSearchDateTime & '''' ConsoleWrite($sSQLQuery & @CRLF) ;For testing. _SQLite_GetTable2d(-1, $sSQLQuery, $aOutFile, $iRows, $iColumns) ConsoleWrite(@error & @CRLF) _ArrayDisplay($aOutFile, "Sum Data") ;For testing. MsgBox($MB_OK, "Sum Data", "Date: " & $aOutFile[1][1] & "-" & $aOutFile[1][2] & "-" & $aOutFile[1][0] & " " & $aOutFile[1][3] & @CRLF & "Value: " & $aOutFile[1][4]) ;Get max value for date. $sSQLQuery = 'SELECT Year,Month,Day,Time,max(Data) FROM "' & $sTableName & '" WHERE "DateTime" = ''' & $sSearchDateTime & '''' ConsoleWrite($sSQLQuery & @CRLF) ;For testing. _SQLite_GetTable2d(-1, $sSQLQuery, $aOutFile, $iRows, $iColumns) ConsoleWrite(@error & @CRLF) _ArrayDisplay($aOutFile, "Max Data for Date") ;For testing. MsgBox($MB_OK, "Max Data for Date", "Date: " & $aOutFile[1][1] & "-" & $aOutFile[1][2] & "-" & $aOutFile[1][0] & " " & $aOutFile[1][3] & @CRLF & "Value: " & $aOutFile[1][4]) ;Get max value for table. $sSQLQuery = 'SELECT Year,Month,Day,Time,max(Data) FROM "' & $sTableName & '"' ConsoleWrite($sSQLQuery & @CRLF) ;For testing. _SQLite_GetTable2d(-1, $sSQLQuery, $aOutFile, $iRows, $iColumns) ConsoleWrite(@error & @CRLF) _ArrayDisplay($aOutFile, "Max Data for Table") ;For testing. MsgBox($MB_OK, "Max Data for Table", "Date: " & $aOutFile[1][1] & "-" & $aOutFile[1][2] & "-" & $aOutFile[1][0] & " " & $aOutFile[1][3] & @CRLF & "Value: " & $aOutFile[1][4]) _SQLite_Close() _SQLite_Shutdown() ;Delete DB file. FileDelete($sOutFileDB) ;Delete SQLite files. FileDelete("sqlite3.exe") FileDelete("sqlite3.dll") Adam
    1 point
  7. Earthshine

    Logout current user

    Yeah. What I was thinking
    1 point
  8. The reason that you didn't get the expected result is because, by default, the StringRegExReplace() does a global replace. If you would have added a "1" for the count parameter, it would have worked as you expected. $preedit = "Cl K 0.0118 Wt % 7.91E-4 121.3 290.3 " $preedit = StringRegExpReplace($preedit, ".+?(?=\d)", "", 1) ; Delete Everything before numbers ConsoleWrite(StringFormat("$preedit = %s", $preedit) & @CRLF) Or you could have simply asserted that it should only look from the start. Then you wouldn't have needed to add a count parameter. It would have looked like this: $preedit = "Cl K 0.0118 Wt % 7.91E-4 121.3 290.3 " $preedit = StringRegExpReplace($preedit, "^.+?(?=\d)", "") ; Delete Everything before numbers ConsoleWrite(StringFormat("$preedit = %s", $preedit) & @CRLF)
    1 point
  9. If you want to delete everything from the beginning of the line until the first number, then this should work also: $preedit = "Cl K 0.0118 Wt % 7.91E-4 121.3 290.3 " $preedit = StringRegExpReplace($preedit, "^[^\d]*", "") ConsoleWrite(StringFormat("$preedit = %s", $preedit) & @CRLF)
    1 point
  10. Can you try the following: #include <Array.au3> #include <Excel.au3> #include <File.au3> Local $sTempName = "FileName.csv" Local $aFileList = _FileListToArray(@ScriptDir & "\CSV", "*.csv", 1, True) If @error Then Exit Local $aArray[0][6], $aFileName For $i = 1 To $aFileList[0] _FileReadToArray($aFileList[$i], $aFileName, 0, ",") _ArrayAdd($aArray, $aFileName) Next Local $hFileOpen = FileOpen($sTempName, 10) _FileWriteFromArray($hFileOpen, $aArray, Default, Default, ",") FileClose($hFileOpen) Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @TempDir & "\" & $sTempName) Local $oRange = $oWorkbook.ActiveSheet.Usedrange Local $iLastRow = $oWorkbook.ActiveSheet.Range("A1").SpecialCells($xlCellTypeLastCell).Row _Excel_RangeInsert($oWorkbook.ActiveSheet, "E:E", $xlShiftToRight) _Excel_RangeWrite($oWorkbook, Default, '=TEXT(DATE(A1,B1,C1), "yyyy-m-d ")&TEXT(D1,"h:mm:ss")', "E1:E" & $iLastRow, False) $oWorkbook.ActiveSheet.Range("I1").Select With $oExcel.Application.Selection .Consolidate("'" & @TempDir & "\[" & $sTempName & "]FileName'!C5:C6", -4157, False, True, False) EndWith _Excel_RangeSort($oWorkbook, Default, "$A:$F", "E:E", Default, Default, Default, False, Default, "F:F", Default) _Excel_RangeSort($oWorkbook, Default, "$I:$J", "J:J", Default, Default, Default, False, Default, "I:I", Default)
    1 point
  11. Its fine, you just only want to replace the first match with the blank string $preedit = "Cl K 0.0118 Wt % 7.91E-4 121.3 290.3 " msgbox(0, '' , StringRegExpReplace($preedit, ".+?(?=\d)", "" , 1)) You are really matching everything in groups of things up to the next number with that regex, so whether it is the best one for the job is debatable #include<array.au3> $preedit = "Cl K 0.0118 Wt % 7.91E-4 121.3 290.3 " _ArrayDisplay(StringRegExp($preedit, ".+?(?=\d)", 3))
    1 point
  12. 1 point
  13. Maybe something like: #include <Array.au3> #include <File.au3> RefineData() Func RefineData() Local $i, $i, $file, $csvArray, $FilePath = @ScriptDir & "\CSV" $aFileList = _FileListToArrayRec($FilePath, "*.csv", 1, 0, 0, 2) ;Create and array of all .csv files within folder Local $aFileData, $sFileData = "2000/1/1 12:00", $iFileData, $aFullData[0][6], $aSummary[0][2] ;=====Loop through the .csv files within the folder====== For $i = 1 To $aFileList[0] ;=====Create array based on csv file===== _FileReadToArray($aFileList[$i], $aFileData, 0, ",") For $j = 0 To UBound($aFileData) - 1 _ArrayAdd($aFullData, $aFileData[$j][0] & "/" & $aFileData[$j][1] & "/" & $aFileData[$j][2] & " " & $aFileData[$j][3] & "|" & $aFileData[$j][0] & "|" & $aFileData[$j][1] & "|" & $aFileData[$j][2] & "|" & $aFileData[$j][3] & "|" & $aFileData[$j][4]) Next _ArraySort($aFullData) Next For $i = 0 To UBound($aFullData) - 1 $iFileData = _ArraySearch($aSummary, $aFullData[$i][0], 0, 0, 0, 0, 1, 0) If @error Then _ArrayAdd($aSummary, $aFullData[$i][0] & "|" & $aFullData[$i][5]) Else $aSummary[$iFileData][1] += $aFullData[$i][5] EndIf Next _ArraySort($aSummary, 1, 0, 0, 1) _ArrayDisplay($aSummary) MsgBox(0,"", "Date: " & $aSummary[0][0] & @CRLF & "Value: " & $aSummary[0][1]) EndFunc
    1 point
  14. ZeroClock

    TrainerGame

    <snip> create you trainer game in C Win32
    1 point
  15. ZeroClock

    Autoit multi thread

    #include <Array.au3> Opt("MustDeclareVars", 1) Func Test_1($x) Local $Array = _STCBF_Struct($x) Local $At = '' For $i = 0 To (UBound($Array)-1) Step 1 $At &= $Array[$i] &' - ' ;ConsoleWrite("$Array["& $i &"] = "& $Array[$i] &@CRLF ) Next MsgBox(0x40, "Thread-1", "Added Thread #1" &@CRLF&@CRLF& StringLeft($At,(StringLen($At) -3)) ) EndFunc ;==> _Thread_Start Func Test_2($x) Local $Array = _STCBF_Struct($x) Local $At = '' For $i = 0 To (UBound($Array)-1) Step 1 $At &= $Array[$i] &' - ' ;ConsoleWrite("$Array["& $i &"] = "& $Array[$i] &@CRLF ) Next MsgBox(0x40, "Thread-2", "Added Thread #2" &@CRLF&@CRLF& StringLeft($At,(StringLen($At) -3)) ) EndFunc ;==> _Thread_Start Func Test_3($x) Local $Array = _STCBF_Struct($x) Local $At = '' For $i = 0 To (UBound($Array)-1) Step 1 $At &= $Array[$i] &' - ' ;ConsoleWrite("$Array["& $i &"] = "& $Array[$i] &@CRLF ) Next MsgBox(0x40, "Thread-3", "Added Thread #3" &@CRLF&@CRLF& StringLeft($At,(StringLen($At) -3)) ) EndFunc ;==> _Thread_Start Local $Ax[4] = [100, 'A', 200, 'B'] Local $N = 10 Local $Bx[4] = [300, 'C', 400, 'D'] _Sub_Thread_CallBack_Func("Test_1", $Ax) _Sub_Thread_CallBack_Func("Test_2", $N) _Sub_Thread_CallBack_Func("Test_3", $Bx) MsgBox(0x40, "Thread-0", "## Default_Thread ##") ;################################################################################################################################################# Func _Sub_Thread_CallBack_Func($F, ByRef $P) Local $Px = "", $L = StringLen($P) If IsArray($P) Then For $i = 0 To (UBound($P)-1) Step 1 $Px &= $P[$i] &"," Next $Px = StringLeft($Px, (StringLen($Px) -1) ) $L = StringLen($Px) $P = $Px EndIf Local $H = DllCallbackRegister($F, "int", "DWORD_PTR") Local $S = DllStructCreate("INT; Char["& $L &"]") DllStructSetData($S, 2, $P) DllStructSetData($S, 1, $L) Local $R = DllCall("kernel32.dll", "hwnd", "CreateThread", "ptr", 0, "dword", 0, _ "long", DllCallbackGetPtr($H), "ptr", DllStructGetPtr($S), "long", 0, "int*", 0) ;DllCallbackFree($H) ;Return $R Sleep(10) EndFunc Func _STCBF_Struct(ByRef $x) Local $y = DllStructGetData(DllStructCreate("INT; Char["& DllStructGetData(DllStructCreate("INT; Char[1]", $x), 1) &"]", $x), 2) Local $Ar = StringSplit($y, ',', 2) Return $Ar EndFunc ;################################################################################################################################################# creates a thread and already passes the data in a array.
    1 point
×
×
  • Create New...