Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/26/2016 in all areas

  1. Hello Guys! I wanted to share all my knowledge on arrays! Hope may enjoy the article , Lets start! Declaring arrays! Declaring arrays is a little different than other variables: ; Rules to follow while declaring arrays: ; ; Rule #1: You must have a declarative keyword like Dim/Global/Local before the declaration unless the array is assigned a value from a functions return (Ex: StringSplit) ; Rule #2: You must declare the number of dimensions but not necessarily the size of the dimension if you are gonna assign the values at the time of declaration. #include <Array.au3> Local $aEmptyArray[0] ; Creates an Array with 0 elements (aka an Empty Array). Local $aArrayWithData[1] = ["Data"] _ArrayDisplay($aEmptyArray) _ArrayDisplay($aArrayWithData) That's it Resizing Arrays Its easy! Just like declaring an empty array! ReDim is our friend here: #include <Array.au3> Local $aArrayWithData[1] = ["Data1"] ReDim $aArrayWithData[2] ; Change the number of elements in the array, I have added an extra element! $aArrayWithData[1] = "Data2" _ArrayDisplay($aArrayWithData) Just make sure that you don't use ReDim too often (especially don't use it in loops!), it can slow down you program. Best practice of using "Enum" You might be wondering what they might be... Do you know the Const keyword which you use after Global/Local keyword? Global/Local are declarative keywords which are used to declare variables, of course, you would know that already by now , If you check the documentation for Global/Local there is a optional parameter called Const which willl allow you to "create a constant rather than a variable"... Enum is similar to Const, it declares Integers (ONLY Integers): Global Enum $ZERO, $ONE, $TWO, $THREE, $FOUR, $FIVE, $SIX, $SEVEN, $EIGHT, $NINE ; And so on... ; $ZERO will evaluate to 0 ; $ONE will evaluate to 1 ; You get the idea :P ; Enum is very useful to declare Constants each containing a number (starting from 0) This script will demonstrate the usefulness and neatness of Enums : ; We will create an array which will contain details of the OS Global Enum $ARCH, $TYPE, $LANG, $VERSION, $BUILD, $SERVICE_PACK Global $aOS[6] = [@OSArch, @OSType, @OSLang, @OSVersion, @OSBuild, @OSServicePack] ; Now, if you want to access anything related to the OS, you would do this: ConsoleWrite(@CRLF) ConsoleWrite('+>' & "Architecture: " & $aOS[$ARCH] & @CRLF) ConsoleWrite('+>' & "Type: " & $aOS[$TYPE] & @CRLF) ConsoleWrite('+>' & "Langauge: " & $aOS[$LANG] & @CRLF) ConsoleWrite('+>' & "Version: " & $aOS[$VERSION] & @CRLF) ConsoleWrite('+>' & "Build: " & $aOS[$BUILD] & @CRLF) ConsoleWrite('+>' & "Service Pack: " & $aOS[$SERVICE_PACK] & @CRLF) ConsoleWrite(@CRLF) ; Isn't it cool? XD You can use this in your UDF(s) or Program(s), it will look very neat! Looping through an Array Looping through an array is very easy! . There are 2 ways to loop an array in AutoIt! Simple Way: ; This is a very basic way to loop through an array ; In this way we use a For...In...Next Loop! Global $aArray[2] = ["Foo", "Bar"] ; Create an array ; This loop will loop 2 times because our $aArray contains 2 elements. For $vElement In $aArray ; $vElement will contain the value of the elements in the $aArray... one element at a time. ConsoleWrite($vElement & @CRLF) ; Prints the element out to the console Next ; And that's it! Advanced Way: ; This is an advanced way to loop through an array ; In this way we use a For...To...Next Loop! Global $aArray[4] = ["Foo", "Bar", "Baz", "Quack"] ; Create an array ; This loop will loop 2 times because our $aArray contains 2 elements. For $i = 0 To UBound($aArray) - 1 ; $i is automatically created and is set to zero, UBound($aArray) returns the no. of elements in the $aArray. ConsoleWrite($aArray[$i] & @CRLF) ; Prints the element out to the console. Next ; This is the advanced way, we use $i to access the elements! ; With the advanced method you can also use the Step keyword to increase the offset in each "step" of the loop: ; This will only print every 2nd element starting from 0 ConsoleWrite(@CRLF & "Every 2nd element: " & @CRLF) For $i = 0 To UBound($aArray) - 1 Step 2 ConsoleWrite($aArray[$i] & @CRLF) Next ; This will print the elements in reverse order! ConsoleWrite(@CRLF & "In reverse: " & @CRLF) For $i = UBound($aArray) - 1 To 0 Step -1 ConsoleWrite($aArray[$i] & @CRLF) Next ; And that ends this section! For some reason, many people use the advance way more than the simple way . For more examples of loops see this post by @FrancescoDiMuro! Interpreting Multi-Dimensional Arrays Yeah, its the most brain squeezing problem for newbies, Imagining an 3D Array... I will explain it in a very simple way for ya, so stop straining you brain now! . This way will work for any array regardless of its dimensions... Ok, Lets start... You can imagine an array as a (data) mine of information: ; Note that: ; Dimension = Level (except the ground level :P) ; Element in a Dimension = Path ; Level 2 ----------\ ; Level 1 -------\ | ; Level 0 ----\ | | ; v v v Local $aArray[2][2][2] ; \-----/ ; | ; v ; Ground Level ; As you can see that $aArray is the Ground Level ; All the elements start after the ground level, i.e from level 0 ; Level 0 Contains 2 different paths ; Level 1 Contains 4 different paths ; Level 2 Contains 8 different paths ; When you want too fill some data in the data mine, ; You can do that like this: $aArray[0][0][0] = 1 $aArray[0][0][1] = 2 $aArray[0][1][0] = 3 $aArray[0][1][1] = 4 $aArray[1][0][0] = 5 $aArray[1][0][1] = 6 $aArray[1][1][0] = 7 $aArray[1][1][1] = 8 ; Don't get confused with the 0s & 1s, Its just tracing the path! ; Try to trace the path of a number with the help of the image! Its super easy! :D I hope you might have understand how an array looks, Mapping your way through is the key in Multi-Dimensional arrays, You take the help of notepad if you want! Don't be shy! Frequently Asked Questions (FAQs) & Their answers Q #1. What are Arrays? A. An Array is an datatype of an variable (AutoIt has many datatypes of variables like "strings", "integers" etc. Array is one of them). An Array can store information in a orderly manner. An Array consist of elements, each element can be considered as a variable (and yes, each element has its own datatype!). AutoIt can handle 16,777,216 elements in an Array, If you have an Array with 16,777,217 elements then AutoIt crashes. Q #2. Help! I get an error while declaring an Array!? A. You tried to declare an array like this: $aArray[1] = ["Data"] That is not the right way, Array is a special datatype, since its elements can be considered as individual variables you must have an declarative keyword like Dim/Global/Local before the declaration, So this would work: Local $aArray[1] = ["Data"] Q #3. How can I calculate the no. of elements in an array? A. The UBound function is your answer, Its what exactly does! If you have an multi-dimensional Array you can calculate the total no. of elements in that dimension by specifying the dimension in the second parameter of UBound Q #4. Why is my For...Next loop throwing an error while processing an Array? A. You might have done something like this: #include <MsgBoxConstants.au3> Local $aArray[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Local $iMyNumber = 0 For $i = 0 To UBound($aArray) ; Concentrate here! $iMyNumber += $aArray[$i] Next MsgBox($MB_OK, "Sum of all Numbers!", $iMyNumber) Did you notice the mistake? UBound returns the no. of elements in an array with the index starting from 1! That's right, you need to remove 1 from the total no. of elements in order to process the array because the index of an array starts with 0! So append a simple - 1 to the statment: #include <MsgBoxConstants.au3> Local $aArray[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Local $iMyNumber = 0 For $i = 0 To UBound($aArray) - 1 $iMyNumber += $aArray[$i] Next MsgBox($MB_OK, "Sum of all Numbers!", $iMyNumber) Q #5. Can an Array contain an Array? How do I access an Array within an Array? A. Yes! It is possible that an Array can contain another Array! Here is an example of an Array within an Array: ; An Array can contain another Array in one of its elements ; Let me show you an example of what I mean ;) #include <Array.au3> Global $aArray[2] $aArray[0] = "Foo" Global $aChildArray[1] = ["Bar"] $aArray[1] = $aChildArray _ArrayDisplay($aArray) ; Did you see that!? The 2nd element is an {Array} :O ; But how do we access it??? ; You almost guessed it, like this: ; Just envolope the element which contains the {Array} (as shown in _ArrayDisplay) with brackets (or parentheses)! :D ConsoleWrite(($aArray[1])[0]) ; NOTE the brackets () around $aArray[1]!!! They are required or you would get an syntax error! ; So this: $aArray[1][0] wont work! More FAQs coming soon!
    1 point
  2. I've recently been uncovering the useful commandline tools that can be found natively in Windows, one of which was findstr (there is also a GUI interface available in SciTE4AutoIt3.) After coming across this little gem and implementing in >SciTE Jump, it felt only right that I should share this on the forums as a standalone UDF. Thanks Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FindInFile ; Description ...: Search for a string within files located in a specific directory. ; Syntax ........: _FindInFile($sSearch, $sFilePath[, $sMask = '*'[, $fRecursive = True[, $fLiteral = Default[, ; $fCaseSensitive = Default[, $fDetail = Default]]]]]) ; Parameters ....: $sSearch - The keyword to search for. ; $sFilePath - The folder location of where to search. ; $sMask - [optional] A list of filetype extensions separated with ';' e.g. '*.au3;*.txt'. Default is all files. ; $fRecursive - [optional] Search within subfolders. Default is True. ; $fLiteral - [optional] Use the string as a literal search string. Default is False. ; $fCaseSensitive - [optional] Use Search is case-sensitive searching. Default is False. ; $fDetail - [optional] Show filenames only. Default is False. ; Return values .: Success - Returns a one-dimensional and is made up as follows: ; $aArray[0] = Number of rows ; $aArray[1] = 1st file ; $aArray[n] = nth file ; Failure - Returns an empty array and sets @error to non-zero ; Author ........: guinness ; Remarks .......: For more details: http://ss64.com/nt/findstr.html ; Example .......: Yes ; =============================================================================================================================== Func _FindInFile($sSearch, $sFilePath, $sMask = '*', $fRecursive = True, $fLiteral = Default, $fCaseSensitive = Default, $fDetail = Default) Local $sCaseSensitive = $fCaseSensitive ? '' : '/i', $sDetail = $fDetail ? '/n' : '/m', $sRecursive = ($fRecursive Or $fRecursive = Default) ? '/s' : '' If $fLiteral Then $sSearch = ' /c:' & $sSearch EndIf If $sMask = Default Then $sMask = '*' EndIf $sFilePath = StringRegExpReplace($sFilePath, '[\\/]+$', '') & '\' Local Const $aMask = StringSplit($sMask, ';') Local $iPID = 0, $sOutput = '' For $i = 1 To $aMask[0] $iPID = Run(@ComSpec & ' /c ' & 'findstr ' & $sCaseSensitive & ' ' & $sDetail & ' ' & $sRecursive & ' "' & $sSearch & '" "' & $sFilePath & $aMask[$i] & '"', @SystemDir, @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput &= StdoutRead($iPID) Next Return StringSplit(StringStripWS(StringStripCR($sOutput), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)), @LF) EndFunc ;==>_FindInFileExample use of Function: #include <Array.au3> #include <Constants.au3> Example() Func Example() Local $hTimer = TimerInit() Local $aArray = _FindInFile('findinfile', @ScriptDir, '*.au3;*.txt') ; Search for 'findinfile' within the @ScripDir and only in .au3 & .txt files. ConsoleWrite(Ceiling(TimerDiff($hTimer) / 1000) & ' second(s)' & @CRLF) _ArrayDisplay($aArray) $hTimer = TimerInit() $aArray = _FindInFile('autoit', @ScriptDir, '*.au3') ; Search for 'autoit' within the @ScripDir and only in .au3 files. ConsoleWrite(Ceiling(TimerDiff($hTimer) / 1000) & ' second(s)' & @CRLF) _ArrayDisplay($aArray) EndFunc ;==>Example
    1 point
  3. I wrote this very simple functions to parse command line arguments. It can get: Simple key/value Example. The following code: #include "cmdline.au3" MsgBox(0, _CmdLine_Get('color')) Will return "white" if you run the script in one of these ways (quotes are optional but mandatory if you're going to use spaces): script.exe -color "white" script.exe --color white script.exe /color white Existence Example. The following code: #include "cmdline.au3" If _CmdLine_KeyExists('givemecoffee') Then ConsoleWrite('You want coffee.') Else ConsoleWrite('You do not want coffee.') EndIf Will return "You want coffee." if you run one of these: script.exe -givemecoffee script.exe --givemecoffee script.exe /givemecoffee And the following code: #include "cmdline.au3" If _CmdLine_ValueExists('givemecoffee') Then ConsoleWrite('You want coffee.') Else ConsoleWrite('You do not want coffee.') EndIf Will return "You want coffee." if you run one of these: script.exe givemecoffee script.exe "givemecoffee" Flags Example. This script: #include "cmdline.au3" ConsoleWrite("You want: ") If _CmdLine_FlagEnabled('C') Then ConsoleWrite("coffee ") EndIf If _CmdLine_FlagEnabled('B') Then ConsoleWrite("beer ") EndIf ConsoleWrite(" and you do not want: ") If _CmdLine_FlagDisabled('V') Then ConsoleWrite("vodka ") EndIf If _CmdLine_FlagDisabled('W') Then ConsoleWrite("wine ") EndIf ConsoleWrite(" but you did not tell me if you want: ") If Not _CmdLine_FlagExists('S') Then ConsoleWrite("soda ") EndIf If Not _CmdLine_FlagExists('J') Then ConsoleWrite("juice ") EndIf Will return "You want: coffee beer and you do not want: vodka wine but you did not tell me if you want: soda juice" if you run: script.exe +CB -VW Getting argument by its index You can also read the $CmdLine (1-based index) through this function. The advantage is that if the index does not exist (the user did not specify the argument), it won't break your script. It will just return the value you specify in the second function parameter. #include "cmdline.au3" $first_argument = _CmdLine_GetValByIndex(1, False) If Not $first_argument Then ConsoleWrite("You did not specify any argument.") Else ConsoleWrite("First argument is: " & $first_argument) EndIf Just a note: The second value of _CmdLine_GetValByIndex function can be an integer value, a string, a boolean value, an array or anything you want it to return if the index does not exist in $CmdLine array. This parameter is also available in _CmdLine_Get() function, also as a second function parameter. In this case, it will return this value if the key was not found. Example: #include "cmdline.au3" $user_wants = _CmdLine_Get("iwant", "nothing") ConsoleWrite("You want " & $user_wants) So, if you run: script.exe /iwant water It will return "You want water". But if you run just: script.exe It will return "You want nothing". Please note that, as these two are the only functions in this library meant to return strings, the second parameter is not available for the other functions. By default, if you do not specify any fallback value, it returns null if the wanted value could not be found. Also, please note that this UDF can NOT parse arguments in the format (key=value). Example: script.exe key=value IT WILL NOT WORK Here is the code: #include-once #comments-start CmdLine small UDF coder: Jefrey (jefrey[at]jefrey.ml) #comments-end Func _CmdLine_Get($sKey, $mDefault = Null) For $i = 1 To $CmdLine[0] If $CmdLine[$i] = "/" & $sKey OR $CmdLine[$i] = "-" & $sKey OR $CmdLine[$i] = "--" & $sKey Then If $CmdLine[0] >= $i+1 Then Return $CmdLine[$i+1] EndIf EndIf Next Return $mDefault EndFunc Func _CmdLine_KeyExists($sKey) For $i = 1 To $CmdLine[0] If $CmdLine[$i] = "/" & $sKey OR $CmdLine[$i] = "-" & $sKey OR $CmdLine[$i] = "--" & $sKey Then Return True EndIf Next Return False EndFunc Func _CmdLine_ValueExists($sValue) For $i = 1 To $CmdLine[0] If $CmdLine[$i] = $sValue Then Return True EndIf Next Return False EndFunc Func _CmdLine_FlagEnabled($sKey) For $i = 1 To $CmdLine[0] If StringRegExp($CmdLine[$i], "\+([a-zA-Z]*)" & $sKey & "([a-zA-Z]*)") Then Return True EndIf Next Return False EndFunc Func _CmdLine_FlagDisabled($sKey) For $i = 1 To $CmdLine[0] If StringRegExp($CmdLine[$i], "\-([a-zA-Z]*)" & $sKey & "([a-zA-Z]*)") Then Return True EndIf Next Return False EndFunc Func _CmdLine_FlagExists($sKey) For $i = 1 To $CmdLine[0] If StringRegExp($CmdLine[$i], "(\+|\-)([a-zA-Z]*)" & $sKey & "([a-zA-Z]*)") Then Return True EndIf Next Return False EndFunc Func _CmdLine_GetValByIndex($iIndex, $mDefault = Null) If $CmdLine[0] >= $iIndex Then Return $CmdLine[$iIndex] Else Return $mDefault EndIf EndFunc
    1 point
  4. Hobbyist, EOL's (CRLF, LF, CR) delimit each line unless the EOL is enclosed (for example in quotes). Czardas's code is acting according to accepted rules and splitting on all CRLF's in the file provided. In fact, when I open your file in Excel I get the same thing, 7 lines with the Credit/Debit column on it's own line. If this is a consistent file format then it can easily be dealt with, otherwise you may want to see if you can control the format from the source (whatever that is). kylomas
    1 point
  5. I still use this UDF a lot. I did find an issue.. not with the script per say. Anyways I thought I would share in case anyone is using this. a registry value was returning 0 when there was data. Apparently the registry key was created incorrectly (it was not null-terminated) The DllCall from line 83 was returning an odd number in ret[6] this was causing DllStructCreate in line 122 to fail, so the data return was 0. To fix this I added under line 93: If Mod($iLen, 2) = 1 Then  $iLen += 1  This allow the DllStructCreate to run and the data was return correctly.
    1 point
  6. Vivaed, This seems to be what you are trying to do. I would strongly encourage you to take JL's advice and understand what each function does by reading the Help file. #include <File.au3> #include <Array.au3> #NoTrayIcon #include <AutoItConstants.au3> #include <TrayConstants.au3> #include <FileConstants.au3> #include <Date.au3> #include <WinAPIFiles.au3> ; name of log file Global $fileLog = "C:\WB Resources\" & @ComputerName & "-WBLog.txt" ; name of output file Global $fileOutput = "C:\WB Resources\" & @ComputerName & "-FAILED-output.txt" ; open output file for write..erase previous content Global $file_output = FileOpen($fileOutput, 2) ; check that file opened If $file_output = -1 Then Exit MsgBox(17, 'Output file failed to open', 'File = ' & $fileOutput) $search = "FAILED" ; read log file to array Global $aFile = FileReadToArray($fileLog) If @error Then Exit MsgBox(17, 'Log file read to array failed', 'File = ' & $fileLog) ConsoleWrite("NOW CALC TIME " & @CRLF & _NowCalc() & @CRLF) ; iterate through array of log entries lokkiing for a "failed" entry withini the last 15 ; minutes. If found writye it to the output file For $i = 0 To UBound($aFile) - 1 If StringInStr($aFile[$i], $search) > 0 Then If _DateDiff('n', StringLeft($aFile[$i], 19), _NowCalcDate()) <= 15 Then FileWrite($file_output, $aFile[$i]) ConsoleWrite($aFile[$i] & @CRLF) EndIf EndIf Next FileClose($file_output) kylomas
    1 point
  7. Something like this? #Include <Array.au3> #Include <Constants.au3> $sSearch = "BR_Field_Auditor_Inventory_Threshold" $sFilePath = "O:\RFP" $sMask = "*.docx" $sResultsFile = @ScriptDir & "\Results.txt" $aFiles = _FindInFile($sSearch, $sFilePath, $sMask) ;_ArrayDisplay($aFiles) ;Uncomment to see results If FileExists($sResultsFile) Then FileDelete($sResultsFile) $hFile = FileOpen($sResultsFile, $FO_APPEND) FileWrite($hFile, "Scan Compiled On: " & @MON & "/" & @MDAY & "/" & @YEAR & @CRLF) FileWrite($hFile, "Result Files Containing String: " & $sSearch & @CRLF & @CRLF) For $i = 1 to $aFiles[0] FileWrite($hFile, $aFiles[$i] & @CRLF) Next FileClose($hFile) Func _FindInFile($sSearch, $sFilePath, $sMask = '*', $fRecursive = True, $fLiteral = Default, $fCaseSensitive = Default, $fDetail = Default) Local $sCaseSensitive = $fCaseSensitive ? '' : '/i', $sDetail = $fDetail ? '/n' : '/m', $sRecursive = ($fRecursive Or $fRecursive = Default) ? '/s' : '' If $fLiteral Then $sSearch = ' /c:' & $sSearch EndIf If $sMask = Default Then $sMask = '*' EndIf $sFilePath = StringRegExpReplace($sFilePath, '[\\/]+$', '') & '\' Local Const $aMask = StringSplit($sMask, ';') Local $iPID = 0, $sOutput = '' For $i = 1 To $aMask[0] $iPID = Run(@ComSpec & ' /c ' & 'findstr ' & $sCaseSensitive & ' ' & $sDetail & ' ' & $sRecursive & ' "' & $sSearch & '" "' & $sFilePath & $aMask[$i] & '"', @SystemDir, @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput &= StdoutRead($iPID) Next Return StringSplit(StringStripWS(StringStripCR($sOutput), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)), @LF) EndFunc ;==>_FindInFile
    1 point
  8. dickjones007, I cannot make head nor tail of that UDF so I have written a couple of new functions tailored to your particular ini file. They are at the bottom of this script, which works fine when I test it with a simple "test.ini" file in the same folder: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Ikone\glavna.ico #AutoIt3Wrapper_Outfile=twister evidencija.exe #AutoIt3Wrapper_Res_Fileversion=0.5.0.10 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** #include <ListViewConstants.au3> ; *** End added by AutoIt3Wrapper *** #include <DateTimeConstants.au3> #include <Timers.au3> #include <String.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <Array.au3> #include <File.au3> #include <GuiMenu.au3> #include <GuiListView.au3> #include "GUIListViewEx.au3" #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiComboBox.au3> ;#include "_GUICtrlListView_SaveHTML.au3" ;#include "IniToArray.au3" #include "RecFileListToArray.au3" Global $folder = @ScriptDir & "\Data\", $inifolder = @ScriptDir & "\Ini\", $folderslike = @ScriptDir & "\Slike\", $razlika, $novidatumrod, $line = FileReadLine($inifolder & "baza imena.txt", 1) Local $workingdir = @WorkingDir ; save Opt("GUIOnEventMode", 1) ;~ Opt("GuiCloseOnESC", 1) Opt("TrayIconHide", 1) Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Local $exititem = TrayCreateItem("Izlaz") ;~ Dim $zivotinja[46] = ["Alligator", "Ant", "Bat", "Bear", "Bee", "Bird", "Bull", "Bulldog", "Butterfly", "Cat", "Chicken", "Cow", "Crab", "Crocodile", "Deer", "Dog", "Donkey", "Duck", "Eagle", "Elephant", "Fish", "Fox", "Frog", "Giraffe", "Gorilla", "Hippo", "Horse", "Insect", "Lion", "Monkey", "Moose", "Mouse", "Owl", "Panda", "Penguin", "Pig", "Rabbit", "Rhino", "Rooster", "Shark", "Sheep", "Snake", "Tiger", "Turkey", "Turtle", "Wolf"] ;~ $imeziv = $zivotinja[Random(0, UBound($zivotinja) - 1, 1)] TraySetIcon(@ScriptDir & "\Ikone\glavna.ico") ;~ TraySetToolTip("Twister kartice" & @CRLF & "Twisted" & " " & $imeziv) #Region --- CodeWizard generated code Start --- ;SpashImage features: Title=No, Width=900, Height=400, Always On Top ;~ SplashImageOn("", $folderslike & "twisterfun.jpg", "900", "400", "-1", "-1", 1) ;~ Sleep(200) ;~ SplashOff() #EndRegion --- CodeWizard generated code Start --- #Region ### GUI section ### #Region MENU $Form1_1 = GUICreate("Twister evidencija", @DesktopWidth - 50, @DesktopHeight - 100, 25, 25, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU)) GUISetBkColor(0xFFCC66) Global $size = WinGetPos($Form1_1) $MenuItem1 = GUICtrlCreateMenu("&Izbornik") $MenuItem4 = GUICtrlCreateMenuItem("&Novi unos", $MenuItem1) GUICtrlSetOnEvent($MenuItem4, "svenovo1") $MenuItem12 = GUICtrlCreateMenuItem("&Otvori podatke", $MenuItem1) GUICtrlSetOnEvent($MenuItem12, "otvori1") $MenuItem9 = GUICtrlCreateMenuItem("&Svi podatci", $MenuItem1) GUICtrlSetOnEvent($MenuItem9, "izdane1") ;~ $MenuItem13 = GUICtrlCreateMenu("&Provjera podataka") ;~ $MenuItem14 = GUICtrlCreateMenuItem("&Provjeri vrijeme ulaza", $MenuItem13) ;~ GUICtrlSetOnEvent($MenuItem14, "provjera1") ;~ $MenuItem15 = GUICtrlCreateMenuItem("&Dnevna statistika", $MenuItem13) ;~ GUICtrlSetOnEvent($MenuItem15, "statistika1") $MenuItem6 = GUICtrlCreateMenu("&Traži") $MenuItem8 = GUICtrlCreateMenuItem("&Traži karticu", $MenuItem6) GUICtrlSetOnEvent($MenuItem8, "search1") $MenuItem7 = GUICtrlCreateMenu("&O programu") $MenuItem2 = GUICtrlCreateMenuItem("&Feedback", $MenuItem7) GUICtrlSetOnEvent($MenuItem2, "oprogramu1") $MenuItem3 = GUICtrlCreateMenuItem("---------------", $MenuItem1) $MenuItem5 = GUICtrlCreateMenuItem("I&zlaz (Ctrl+Shift+x)", $MenuItem1) GUICtrlSetOnEvent($MenuItem5, "izlaz1") Local $_AccelTable[1][2] = [["+^x", $MenuItem5]] GUISetAccelerators($_AccelTable) $cMenu = GUICtrlCreateMenu(_StringRepeat(" ", 10) & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)) _Timer_SetTimer($Form1_1, 1000, "_UpdateMenuClock"); create timer #EndRegion MENU $default = GUICtrlCreateButton("DEFAULT", 300, 0, 60, 15) GUICtrlSetOnEvent($default, "default1") ;~ GUICtrlCreateLabel("Djelatnik:", 20, 17, 60, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green ;~ $djelatnici = GUICtrlCreateCombo("", 100, 13, 119, 25) ;~ GUICtrlSetData($djelatnici, "Anita Tihi|Nikolina Matanovic", "Anita Tihi") $imeprezime = GUICtrlCreateInput("", 100, 40, 120, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_UPPERCASE)) GUICtrlCreateLabel("Ime i prezime:", 20, 43, 80, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green $datumrod = GUICtrlCreateDate("2001/01/01", 100, 66, 120, 20, $DTS_SHORTDATEFORMAT) GUICtrlCreateLabel("Datum rodenja:", 20, 69, 80, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green ;~ $brojorm = GUICtrlCreateInput("", 100, 40 + 52, 60, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) ;~ GUICtrlCreateLabel("Broj ormarica", 20, 43 + 52, 75, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green ;~ GUICtrlSetLimit($brojorm, 2, 2) #Region KONTAKT INFO $kontakt = GUICtrlCreateCombo("", 320, 40, 80, 21) GUICtrlSetData($kontakt, "Majka|Otac|Djed|Baka|Brat|Sestra|Prijatelj|Ocuh|Pomajka|Stric|Strina|Ujak|Ujna|Bratic|Sestricna", "Majka") GUICtrlCreateLabel("Kontakt osoba:", 243, 43, 77, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green $kontaktime = GUICtrlCreateInput("", 470, 40, 120, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_UPPERCASE)) GUICtrlCreateLabel("Ime:", 410, 43, 55, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green $kontaktel = GUICtrlCreateInput("", 470, 66, 120, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_UPPERCASE)) GUICtrlCreateLabel("Telefon:", 410, 69, 55, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green $kontakosobn = GUICtrlCreateInput("", 470, 66 + 26, 120, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_UPPERCASE)) GUICtrlCreateLabel("Br. osobne:", 410, 69 + 26, 55, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green $kontakmail = GUICtrlCreateInput("", 470, 66 + 52, 120, 21, $GUI_SS_DEFAULT_INPUT) GUICtrlCreateLabel("e-mail:", 410, 69 + 52, 55, 15) ;~ GUICtrlSetBkColor(-1, 0x00ff00) ; Green $dodaj = GUICtrlCreateButton("Dodaj kontakt", 607, 40, 80, 25) GUICtrlSetOnEvent($dodaj, "dodaj1") $listakontakt = GUICtrlCreateEdit("", 700, 40, 267, 200, BitOR($ES_READONLY, $WS_VSCROLL)) $obrisi = GUICtrlCreateButton("Obriši kontakte", 607, 80, 80, 25) GUICtrlSetOnEvent($obrisi, "obrisi1") #EndRegion KONTAKT INFO $spremi = GUICtrlCreateButton("Spremi podatke", 20, 150, 200, 60) GUICtrlSetOnEvent($spremi, "spremi1") $listime = GUICtrlCreateCombo("", 20, 320, $size[2] / 6, 21, $CBS_UPPERCASE) GUICtrlSetData($listime, $line) GUICtrlCreateLabel("Ime i prezime:", 20, 300, $size[2] / 6, 19) $ulazbutton = GUICtrlCreateButton("UNESI VRIJEME ULASKA", 20 + $size[2] / 6, 299, $size[2] / 8, 21) GUICtrlSetOnEvent($ulazbutton, "ulaznovrijeme1") $listulaz = GUICtrlCreateInput("", 20 + $size[2] / 6, 320, $size[2] / 8, 21, $ES_READONLY) $listorm = GUICtrlCreateInput("", 20 + $size[2] / 6 + $size[2] / 8 + $size[2] / 8, 320, $size[2] / 16, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_UPPERCASE)) GUICtrlCreateLabel("Broj ormarica:", 20 + $size[2] / 6 + $size[2] / 8 + $size[2] / 8, 300, $size[2] / 16, 19) GUICtrlSetLimit($listorm, 2, 2) $gratisda = GUICtrlCreateRadio("DA", 20 + $size[2] / 6 + $size[2] / 8 + $size[2] / 8 + $size[2] / 16 + 15, 312, 40, 20) $gratisne = GUICtrlCreateRadio("NE", 20 + $size[2] / 6 + $size[2] / 8 + $size[2] / 8 + $size[2] / 16 + 15, 330, 40, 20) GUICtrlSetState($gratisne, $GUI_CHECKED) $dodajlist = GUICtrlCreateButton("Dodaj u tablicu", 20 + $size[2] / 6 + $size[2] / 8 + $size[2] / 8 + $size[2] / 16 * 2, 320, $size[2] / 12, 21) GUICtrlSetOnEvent($dodajlist, "dodajlist1") $obrisilist = GUICtrlCreateButton("Obriši oznaceno", 20 + $size[2] / 6 + $size[2] / 8 + $size[2] / 8 + $size[2] / 16 * 2 + $size[2] / 12, 320, $size[2] / 12, 21) GUICtrlSetOnEvent($obrisilist, "obrisilist1") $spremilist = GUICtrlCreateButton("Spremi tablicu u HTML format", $size[2] - 205, 320, 180, 21) GUICtrlSetOnEvent($spremilist, "spremilist1") $hListView = _GUICtrlListView_Create($Form1_1, "Ime i prezime|Vrijeme ulaska|Vrijeme izlaska|Broj ormarica|GRATIS", 20, 350, $size[2] - 45, $size[3] - 350 - 60, BitOR($LVS_EDITLABELS, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES)) _GUICtrlListView_SetColumnWidth($hListView, 0, $size[2] / 6) _GUICtrlListView_SetColumnWidth($hListView, 1, $size[2] / 8) _GUICtrlListView_SetColumnWidth($hListView, 2, $size[2] / 8) _GUICtrlListView_SetColumnWidth($hListView, 3, $size[2] / 16) ; Initialise ListView - set for edit on DblClk $iLV_Index = _GUIListViewEx_Init($hListView, "", 0, 0, False, 3) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Register required handlers _GUIListViewEx_MsgRegister() ;~ MsgBox(0, "Active window stats (x,y,width,height):", $size[0] & " " & $size[1] & " " & $size[2] & " " & $size[3]) #EndRegion ### GUI section ### ; *** create these here and not over and over in a function ;~ $pic = GUICtrlCreatePic($folderslike & "backg.jpg", 240, 14 + 150, 364, 228) ; kod exit staviti pitanje jeste sigurni i snimati tablicu u toku i staviti obavjest da se snima dok se radi Local $aIniArray = _IniToArray("test.ini", "backup tablica") For $i = 0 To UBound($aIniArray) - 1 _GUIListViewEx_Insert($aIniArray[$i]) Next While 1 Local $msg = TrayGetMsg() If $msg = $exititem Then ExitLoop ; Wait for DblClk on ListView to edit _GUIListViewEx_EditOnClick() WEnd #cs If FileExists($inifolder) Then Sleep(100) Else DirCreate($inifolder) EndIf $IniNameFile = $inifolder & @MDAY & "_" & @MON & "_" & @YEAR & " backup dnevna tablica.ini" #ce Func dodajlist1() If $gratisne And BitAND(GUICtrlRead($gratisne), $GUI_CHECKED) = $GUI_CHECKED Then Global $listgratis = "NE" Else Global $listgratis = "DA" EndIf ; Activate ListView _GUIListViewEx_SetActive($iLV_Index) ; Create data string $sData = GUICtrlRead($listime) & "|" & GUICtrlRead($listulaz) & "|" & "" & "|" & GUICtrlRead($listorm) & "|" & $listgratis ; Add line to ListView _GUIListViewEx_Insert($sData) $aLV_Array = _GUIListViewEx_ReturnArray($iLV_Index) _ArrayToIni("test.ini", "backup tablica", $aLV_Array) $imena = FileOpen($inifolder & "baza imena.txt", 1) FileWrite($imena, "|" & GUICtrlRead($listime)) FileClose($imena) ;~ $procitajfile = FileRead($imena) $line = FileReadLine($inifolder & "baza imena.txt", 1) ;~ MsgBox(0, "", $line) GUICtrlSetData($listime, $line) EndFunc ;==>dodajlist1 Func obrisilist1() _GUIListViewEx_Delete() EndFunc ;==>obrisilist1 Func spremilist1() $lista = _GUIListViewEx_ReadToArray($hListView) $danasdatum = _NowCalcDate() $konvdanasdatum = StringSplit($danasdatum, "/") $novidanasdatum = Number($konvdanasdatum[3]) & "_" & Number($konvdanasdatum[2]) & "_" & StringRight($konvdanasdatum[1], 4) $brojredova = _GUICtrlListView_GetItemCount($hListView) $iGratis = 0 For $brojda = 0 To $brojredova - 1 If _GUICtrlListView_GetItemText($hListView, $brojda & ",", 4) = "DA" Then $iGratis += 1 EndIf Next ;_GUICtrlListView_SaveHTML($hListView, $folder & $novidanasdatum & ".html") EndFunc ;==>spremilist1 Func svenovo1() ;put empty values into fields GUICtrlSetData($imeprezime, "") GUICtrlSetData($kontaktime, "") GUICtrlSetData($kontaktel, "") GUICtrlSetData($kontakosobn, "") GUICtrlSetData($kontakmail, "") GUICtrlSetData($listakontakt, "") EndFunc ;==>svenovo1 Func default1() ;put default values into fields Dim $aWord[10] = ["Kruno", "Ilija", "Marko", "Filip", "Ivan", "Željka", "Marica", "Matilda", "Ana", "Anita"] $ime = $aWord[Random(0, UBound($aWord) - 1, 1)] Dim $bWord[10] = ["Majetic", "Krpic", "Markic", "Filipic", "Ivanovic", "Martic", "Klovic", "Zulic", "Ludic", "Varnic"] $prezime = $bWord[Random(0, UBound($bWord) - 1, 1)] GUICtrlSetData($imeprezime, $ime & " " & $prezime) ;ime prezime GUICtrlSetData($listime, $ime & " " & $prezime) Dim $cWord[10] = ["Marica", "Barica", "Ivica", "Karlo", "Pera", "Marijana", "Klara", "Maja", "Verica", "Ðuka"] $kontime = $cWord[Random(0, UBound($cWord) - 1, 1)] $testdatum = StringFormat("%04u", Random(1999, 2007, 1)) & "/" & StringFormat("%02u", Random(1, 12, 1)) & "/" & StringFormat("%02u", Random(1, 28, 1)) GUICtrlSetData($datumrod, $testdatum) ;ime kontakta GUICtrlSetData($kontaktime, $kontime) ;ime kontakta GUICtrlSetData($kontaktel, "035/212-055") ;telefon GUICtrlSetData($kontakosobn, "123456789") ;ulicu GUICtrlSetData($kontakmail, "mail@mail.com") ;postu GUICtrlSetData($listorm, StringFormat("%02u", Random(01, 100, 1))) GUICtrlSetData($listulaz, StringFormat("%02u", Random(09, 15, 1)) & ":" & StringFormat("%02u", Random(01, 30, 1))) EndFunc ;==>default1 Func dodaj1() If GUICtrlRead($listakontakt) = "" Then GUICtrlSetData($listakontakt, GUICtrlRead($kontakt) & ": " & GUICtrlRead($kontaktime) & @CRLF & "Kontakt broj: " & GUICtrlRead($kontaktel) & @CRLF & "Broj osobne iskaznice: " & GUICtrlRead($kontakosobn) & @CRLF & "e-mail: " & GUICtrlRead($kontakmail) & @CRLF & "------: ------", 1) Else GUICtrlSetData($listakontakt, @CRLF & GUICtrlRead($kontakt) & ": " & GUICtrlRead($kontaktime) & @CRLF & "Kontakt broj: " & GUICtrlRead($kontaktel) & @CRLF & "Broj osobne iskaznice: " & GUICtrlRead($kontakosobn) & @CRLF & "e-mail: " & GUICtrlRead($kontakmail) & @CRLF & "------: ------", 1) EndIf EndFunc ;==>dodaj1 Func obrisi1() If GUICtrlRead($listakontakt) = "" Then MsgBox(64, "Brisanje kontakt brojeva", "Nema dodanih kontakt brojeva") Else $return = MsgBox(4 + 32, "Brisanje kontakt brojeva", "Da li sigurno želite obrisati SVE kontakt brojeve?") If $return = 6 Then GUICtrlSetData($listakontakt, "") Else Sleep(100) EndIf EndIf EndFunc ;==>obrisi1 Func spremi1() If FileExists($folder) Then Sleep(100) Else DirCreate($folder) EndIf Global $imeprezimetxt = GUICtrlRead($imeprezime) Global $datumrodtxt = GUICtrlRead($datumrod) $konvdatumrod = StringSplit($datumrodtxt, ".") $novidatumrod = Number($konvdatumrod[1]) & "_" & Number($konvdatumrod[2]) & "_" & StringRight($konvdatumrod[3], 4) Global $kontakteltxt = GUICtrlRead($kontaktel) If $gratisne And BitAND(GUICtrlRead($gratisne), $GUI_CHECKED) = $GUI_CHECKED Then $placenotxt = "GOTOVINA" Else $placenotxt = "GRATIS" EndIf $brojormtxt = StringFormat("%02d", GUICtrlRead($listorm)) $vrstatxt = ControlGetText($Form1_1, "", "[CLASS:Edit; INSTANCE:10]") Global $listakontakttxt = GUICtrlRead($listakontakt) Global $avArray[3][3] = [["[IME I PREZIME]", $imeprezimetxt],["[DATUM ROÐENJA]", $datumrodtxt],["[KONTAKTI]", $listakontakttxt]] If GUICtrlRead($listakontakt) = "" Then $nemakontakt = MsgBox(4 + 64, "Spremanje podataka", "Nema dodanih kontakt brojeva." & @CRLF & "Da li sigurno želite nastaviti sa spremanjem?") If $nemakontakt = 6 Then filesavedialog1() Else MsgBox(4096, "", "Spremanje otkazano.") EndIf Else filesavedialog1() EndIf EndFunc ;==>spremi1 Func otvori1() $openfile = FileOpenDialog("Odaberite datoteku.", $folder, "Text files (*.txt)", 16) If @error Then MsgBox(4096, "", "Datoteka nije izabrana.") Else svenovo1() GUICtrlSetData($imeprezime, IniRead($openfile, "Podatci o djetetu", "Ime i prezime", "")) $novidatum = IniRead($openfile, "Podatci o djetetu", "Datum rodenja", "") $konvnovidatum = StringSplit($novidatum, ".") $novidatumx = StringRight($konvnovidatum[3], 4) & "/" & StringFormat("%02d", Number($konvnovidatum[2])) & "/" & StringFormat("%02d", Number($konvnovidatum[1])) ;~ MsgBox(0, "", $novidatumx) GUICtrlSetData($datumrod, $novidatumx) $var = IniReadSection($openfile, "Kontakt podatci") If @error Then MsgBox(4096, "", "Greška, vjerovatno TXT datoteka nije u ispravnom formatu.") Else For $i = 1 To $var[0][0] GUICtrlSetData($listakontakt, $var[$i][0] & "=" & $var[$i][1] & @CRLF, 1) Next EndIf EndIf FileClose($openfile) EndFunc ;==>otvori1 Func filesavedialog1() $listakontaktrep = StringReplace(GUICtrlRead($listakontakt), ": ", "=") $sFile = FileSaveDialog("Izaberite ime.", $folder, "Text files (*.txt)", 16, $imeprezimetxt & " " & $novidatumrod & "_.txt") IniWrite($sFile, "Podatci o djetetu", "Ime i prezime", $imeprezimetxt) IniWrite($sFile, "Podatci o djetetu", "Datum rodenja", $datumrodtxt) IniWriteSection($sFile, "Kontakt podatci", $listakontaktrep) EndFunc ;==>filesavedialog1 Func izdane1() If FileExists($folder) Then Sleep(100) Else DirCreate($folder) EndIf Run("Explorer.exe " & $folder) EndFunc ;==>izdane1 Func provjera1() $provjfile = FileOpenDialog("Odaberite datoteku.", $folder, "Text files (*.txt)", 16) If @error Then MsgBox(4096, "", "Datoteka nije izabrana.") Else Global $inputulaz = FileReadLine($provjfile, 11) If $inputulaz = "" Then MsgBox(0, "Vrijeme ulaska u igraonicu", "Vrijeme nije uneseno") Else razlika_u_provjeri_vremena() MsgBox(0, "Vrijeme ulaska u igraonicu", $inputulaz & @CRLF & "Prošlo je " & $razlika & " od ulaska u igraonicu") EndIf EndIf FileClose($provjfile) EndFunc ;==>provjera1 Func statistika1() $inputdatum = InputBox("Unesite datum", "Obavezan format datuma je 01_01_0001", @MDAY & "_" & @MON & "_" & @YEAR, " M10", 50, 140) If @error = 1 Then MsgBox(0, "Statistika ulazaka", "Prikaz statistike otkazan") Else If StringRegExp($inputdatum, "^\d{2}_\d{2}_\d{4}$") Then $datum = _NowCalcDate() ;~ $konvdatum = StringSplit($datum, "/") ;~ $novidatuma = Number($konvdatum[3]) & "." & Number($konvdatum[2]) & "." & StringRight($konvdatum[1], 4) ;~ $statsgotovina = _FileListToArray($folder, "*" & $inputdatum & "*GOTOVINA*", 1) ;~ $statsgratis = _FileListToArray($folder, "*" & $inputdatum & "*GRATIS*", 1) ;~ If $statsgratis = "" Then ;~ $statsgratis = "0" ;~ Else ;~ $statsgratis = $statsgratis[0] ;~ EndIf ;~ If $statsgotovina = "" Then ;~ $statsgotovina = "0" ;~ Else ;~ $statsgotovina = $statsgotovina[0] ;~ EndIf MsgBox(0, "Statistika ulazaka", "Statistika za dan " & $inputdatum & @CRLF & @CRLF & "Broj ulazaka placenih gotovinom: " & "" & @CRLF & "Broj ulazaka GRATIS :" & "") Else MsgBox(0, "Statistika ulazaka", "Krivi format datuma") EndIf EndIf EndFunc ;==>statistika1 Func razlika_u_provjeri_vremena() Local $sTime1 = $inputulaz, $sTime2 = _NowTime() Local $iTime1, $iTime2, $iTime24 Local $aTemp, $sHour, $sMinute, $sSecond $aTemp = StringSplit($sTime1, ":") $iTime1 = _TimeToTicks($aTemp[1], $aTemp[2], $aTemp[3]) $aTemp = StringSplit($sTime2, ":") $iTime2 = _TimeToTicks($aTemp[1], $aTemp[2], $aTemp[3]) _TicksToTime($iTime2 - $iTime1, $sHour, $sMinute, $sSecond) If Number(StringReplace($sTime1, ":", "")) < Number(StringReplace($sTime2, ":", "")) Then _TicksToTime($iTime2 - $iTime1, $sHour, $sMinute, $sSecond) ; No 24 hr rollover Else $iTime24 = _TimeToTicks("24", "00", "00") ; 24 hr rollover _TicksToTime($iTime2 + $iTime24 - $iTime1, $sHour, $sMinute, $sSecond) EndIf Global $razlika = StringRight("0" & $sHour, 2) & ":" & StringRight("0" & $sMinute, 2) & ":" & StringRight("0" & $sSecond, 2) EndFunc ;==>razlika_u_provjeri_vremena Func ulaznovrijeme1() GUICtrlSetData($listulaz, @HOUR & ":" & @MIN) EndFunc ;==>ulaznovrijeme1 Func oprogramu1() MsgBox(0, "Kontakt", "Vaše upite ili komentare možete slati na e-mail:" & @CRLF & @CRLF & "darkman@doctor.com") EndFunc ;==>oprogramu1 Func search1() Global $bezveze, $MenuItem10, $MenuItem11 If $bezveze = 9999 Then $pitanje = MsgBox(4 + 64, "", "Rezultati vaše prethodne pretrage biti ce obrisani." & @CRLF & "Želite li nastaviti dalje?") If $pitanje = 6 Then GUICtrlDelete($MenuItem10) GUICtrlDelete($MenuItem11) $searchtext = InputBox("Tekst", "Upisati traženi tekst:" & @CRLF & "(biti ce pretražena mapa" & " " & $folder & ")", "", " M", 500, 140) If @error = 1 Then Sleep(100) Else $aArray = _RecFileListToArray($folder, "*" & $searchtext & "*.txt", 1) $nadenifile = _ArrayToString($aArray, "", 1) $beztxt = StringReplace($nadenifile, ".txt", ".") $found = StringSplit($beztxt, ".") $MenuItem10 = GUICtrlCreateMenu("<---->", -1, 3) $MenuItem11 = GUICtrlCreateMenu("&Pronadene datoteke", -1, 4) $iJ = UBound($aArray, 1) For $i = 1 To $iJ - 1 ;Loop $nadjeno = GUICtrlCreateMenuItem($found[$i], $MenuItem11) GUICtrlSetOnEvent(Default, '_Menu') Next EndIf Else Sleep(88) EndIf Else $searchtext = InputBox("Tekst", "Upisati traženi tekst:" & @CRLF & "(biti ce pretražena mapa" & " " & $folder & ")", "", " M", 500, 140) If @error = 1 Then Sleep(100) Else $aArray = _RecFileListToArray($folder, "*" & $searchtext & "*.txt", 1) $nadenifile = _ArrayToString($aArray, "", 1) $beztxt = StringReplace($nadenifile, ".txt", ".") $found = StringSplit($beztxt, ".") $MenuItem10 = GUICtrlCreateMenu("<---->", -1, 3) $MenuItem11 = GUICtrlCreateMenu("&Pronadene datoteke", -1, 4) $iJ = UBound($aArray, 1) For $i = 1 To $iJ - 1 ;Loop $nadjeno = GUICtrlCreateMenuItem($found[$i], $MenuItem11) GUICtrlSetOnEvent(Default, '_Menu') Next $bezveze = 9999 EndIf EndIf EndFunc ;==>search1 Func _Menu() ; run the found entry $datoteka = ShellExecute($folder & GUICtrlRead(@GUI_CtrlId, 1) & ".txt", @SW_MAXIMIZE) EndFunc ;==>_Menu Func _UpdateMenuClock($hWnd, $msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime GUICtrlSetData($cMenu, _StringRepeat(" ", 10) & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)) EndFunc ;==>_UpdateMenuClock Func izlaz1() Exit EndFunc ;==>izlaz1 Func _Edit_Changed() _GUICtrlComboBox_AutoComplete($listime) EndFunc ;==>_Edit_Changed Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo If Not IsHWnd($listime) Then $hWndCombo = GUICtrlGetHandle($listime) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case $listime, $hWndCombo Switch $iCode Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box _Edit_Changed() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND ; ############################################################################ Func _IniToArray($sFile, $sSection) $aIni = IniReadSection($sFile, $sSection) Local $aArray[$aIni[0][0]] For $i = 1 To $aIni[0][0] $aArray[$i - 1] = $aIni[$i][1] Next Return $aArray EndFunc ;==>_IniToArray Func _ArrayToIni($sFile, $sSection, $aArray) IniDelete($sFile, $sSection) For $i = 0 To UBound($aArray) - 1 IniWrite($sFile, $sSection, $i, $aArray[$i]) Next EndFunc ;==>_ArrayToIni You will, of course, need to add code to set the required path and name for your actual ini file. M23
    1 point
  9. Try this: Local $sHex = '0xD790D799D79F20D79BD79ED79520D794D791D799D7AA' Local $sEscaped = StringRegExpReplace(StringMid($sHex, 3), '([[:xdigit:]]{2})', 'x$1') ConsoleWrite($sEscaped & @LF)
    1 point
×
×
  • Create New...