Jump to content

skysel

Active Members
  • Posts

    163
  • Joined

  • Last visited

Everything posted by skysel

  1. Wow Melba23, many thanks for your generous help! I am constantly trying to improve in AutoIT, but since logic isn't my strong attribute, I am struggling with programming :-) That's why so many "errors" in the script, sometimes I don't understand how specific functions work exactly (like loops, ...) Thank you for commenting on the code as it will improve my understanding :-)
  2. Hello everyone, Below is a modified script, which I use to create folder names based on file names and then move each file in folder created. Which works good. However, the modification below I'm trying to achieve now is: - search for files, create folders based on that files (filename is xxxxxx_001.ext, so stringtrim takes care of _001.ext so it isn't included in folder name) - this works ok - function KopirajDatoteke() should now move the files, starting with xxxxxx_***.*** to folder xxxxxx. I am not sure how to achieve this, I would like some pointers. Basically, if part of filename matches folder name, then it should move to the folder that it matches with. Since I need to get Arrays of folders and files, I'm guessing both array functions should stay. I was looking at StringCompare for example, but I think its wrong direction. thanks. #include <File.au3> #include <Array.au3> #include <RecFileListToArray.au3> $DIR = "C:\1" $TIFF = "C:\1" KreirajMape() KopirajDatoteke() Func KreirajMape() $FileArray = _RecFileListToArray($DIR, "*", 1, 0, 1, 0) For $i = 1 to UBound($FileArray) - 1 ;need -1 or you'll go out of range $FileArray[$i] = StringTrimRight(StringRegExpReplace($FileArray[$i], '[^\_]+$', ''), 1) ;Use this just in case the extension is more than 3 letters like "Video.dvr-ms" Next _ArrayDelete($FileArray,0) For $i = 0 to Ubound($FileArray) - 1 DirCreate($DIR & "\" & $FileArray[$i]) Next EndFunc Func KopirajDatoteke() $FileArray = _RecFileListToArray($DIR, "*", 1, 0, 0, 2) $FolderArray = _RecFileListToArray($DIR, "*", 2, 0, 1, 2) For $i = 1 To $FileArray[0] Next For $i = 1 To $FolderArray[0] FileMove($FileArray[$i],$FolderArray[$i],8) Next ;_ArrayDisplay($FileArray) ;_ArrayDisplay($FolderArray) EndFunc
  3. I don't think it's possible - unless if you try MouseClick() or ControlClick() function. You might want to setup your lan card using this: http://technet.microsoft.com/en-us/library/cc732869%28v=ws.10%29.aspx same goes for wlan..
  4. http://msdn.microsoft.com/en-us/library/windows/desktop/cc144191%28v=vs.85%29.aspx maybe this? Define what "control panel" is for you..
  5. Too much unnecessary quotes. This should be better + looks cleaner: Run(@ScriptDir & 'setup.exe' & ' /adminfile' & @ScriptDir & '\profiles\MAK-Passive.msp') I am not sure if .msp will run with Run command, if it doesn't, use ShellExecute instead.
  6. You should use function ShellExecute, Run only works on executables... ShellExecute(@DesktopDir & 'HM-rasphone.pbk')
  7. Just a thought - maybe try connecting as .Username? . stands for whatever the remote computer name is and is used when you try to connect as local user on the machine.
  8. You were right. After I removed the arraydelete function, the script did its magic :-) Thanks!
  9. I have tried changing $i to $j as you provided with $i2 and it didn't work. Edit: Ah I see you've placed Next statements differently - I will try and tell how it goes :-) I am only deleting the first row, since it includes count of files and thats interfering with my actions (since I don't have a folder named e.g. 9 (9 files in folder) and file 9.tif does not exist, obviously) :-) What is your purposed solution? I am still trying to wrap my head around loops... Thank you both for your effort so far!
  10. Hi there, _ArrayDisplay shows me FULL path to files and FULL path to folders, so I think that's not what's wrong (I have tried various combinations on parameters for _RecFileListToArray, can't remember now if I've set it back or not here on OP).. What I'm trying to achieve is to get list of all files and folders in 1 folder (e.g. c:1) and copy them accordingly to subfolders. Folders are named by filenames, for which I use another function and it works well. For example, the structure looks like this: Folders: c:100000001 c:100000002 c:100000003 c:100000004 Files: c:100000001.tif c:100000002.tif c:100000003.tif c:100000004.tif Desired FileCopy operation should copy files to those folders, I have both sorted with parameter within _RecFileListToArray, so it would always match since both are same name: c:10000000100000001.tif c:10000000100000002.tif c:10000000100000003.tif c:10000000100000004.tif I have also tried to put the FileCopy operation in the second loop, right before Next statement, however files are still not copied. I hope I made it bit clearer now on my desired output ;-)
  11. So I'm using _RecFileListToArray by Melba23, I've added _ArrayDisplay to the function, to make sure values returned are normal - which they are. $DIR is the directory where the script is searching for files / folders. What bugs me, is, that when I preform FileCopy operation (according to array that would be - c:1filename.tif -> c:1filenamefilename.tif) but it only copies file from row 1 in the array! other folders are left blank :-( I can't seem to find the error below... help appreciated! Func KopirajDatoteke() $FileArray = _RecFileListToArray($DIR, "*", 1, 0, 0, 2) _ArrayDelete($FileArray,0) $FolderArray = _RecFileListToArray($DIR, "*", 2, 0, 1, 2) _ArrayDelete($FolderArray,0) For $i = 1 To $FileArray[0] Next For $i = 1 To $FolderArray[0] Next FileCopy($FileArray[$i],$FolderArray[$i],8) _ArrayDisplay($FileArray) _ArrayDisplay($FolderArray) EndFunc
  12. Thank you @water, I will look into it today/tomorrow and come back if I'll have more questions (which I'm sure I'll have :-)). @kylomas, I googled for Kiwi syslog API, but it throws me to the CatTools page which is not the same product as the syslog. And as I stated previous, their website and documentation is really badly scattered..
  13. I've contacted their technical support if they have any solution for monthly / yearly reports, but they answered that there isn't an option yet and that they might add it in future releases. I checked out example scripts on it, but figured it would be much less hassle doing it in AutoIT than in Syslog server. Documentation and website are poorly constructed on their side...
  14. So the situation is as following: - The kind of email I get is report (daily statistics) - I want to extract relevant data into DB or Excel, so later I can generate monthly/yearly report based on it. - I would like extracted table Breakdown of Syslog messages by severity and Kiwi Syslog Server Statistics, I would let Breakdown by sending host out of parsing. - I am aware of Outlook UDF and ability to read email body with it The trouble is, I am unsure how to parse data below to suit my needs / what kind of approach to use for that. My guess would be to first read date from the 3rd line, so we know for what day statistics apply. Secondly, I would go with matching text i.e. "Messages received - Total:" and match it with Excel row. Table would be designed: - 1st column Messages received total, messages received - last 24 hours, etc... - 2nd column would be "Date", 2nd row of column 2 would be the numbers according to below.. That's how much I figured that it should be. Any more pointers / examples would be highly appreciated. The body of email appears like this: /// Kiwi Syslog Server Statistics /// --------------------------------------------------- 24 hour period ending on: Mon, 25 Mar 2013 00:00:02 Syslog Server started on: Thu, 07 Mar 2013 07:48:35 Syslog Server uptime: 17 days, 16 hours, 10 minutes --------------------------------------------------- + Messages received - Total: 5199162 + Messages received - Last 24 hours: 246856 Messages received - Since + Midnight: 244632 + Messages received - Last hour: 10015 + Message queue overflow - Last hour: 0 + Messages received - This hour: 1900 + Message queue overflow - This hour: 0 + Messages per hour - Average: 10207 + Messages forwarded: 0 + Messages logged to disk: 244760 + Errors - Logging to disk: 0 + Errors - Invalid priority tag: 0 + Errors - No priority tag: 0 + Errors - Oversize message: 91096 + Disk space remaining on drive E: 31727 MB --------------------------------------------------- Breakdown of Syslog messages by sending host +--------------------------+------------+------------+ | Top 20 Hosts | Messages | Percentage | +--------------------------+------------+------------+ | server1.domain.local| 79238 | 32,39% | | server2.domain.local| 60212 | 24,61% | | server3.domain.local| 18084 | 7,39% | | server4.domain.local| 17341 | 7,09% | | 10.10.10.1 | 12223 | 5,00% | | 10.10.10.2 | 11869 | 4,85% | | server5.domain.local| 8093 | 3,31% | | server6.domain.local| 4945 | 2,02% | | server7.domain.local| 4001 | 1,64% | | server8.domain.local| 3952 | 1,62% | | server9.domain.local| 3872 | 1,58% | | server10.domain.local| 3520 | 1,44% | | server11.domain.local| 3413 | 1,40% | | server12.domain.local| 2936 | 1,20% | | server13.domain.local| 2908 | 1,19% | | server14.domain.local| 2737 | 1,12% | | server15.domain.local| 1777 | 0,73% | | server16.domain.local| 1164 | 0,48% | | server17.domain.local| 1085 | 0,44% | | server18.domain.local| 1007 | 0,41% | | All others (4) | 255 | 0,10% | +--------------------------+------------+------------+ Breakdown of Syslog messages by severity +--------------------+------------+------------+ | Message Level | Messages | Percentage | +--------------------+------------+------------+ | 0 - Emerg | 0 | 0,00% | | 1 - Alert | 0 | 0,00% | | 2 - Critical | 208 | 0,09% | | 3 - Error | 198 | 0,08% | | 4 - Warning | 697 | 0,28% | | 5 - Notice | 216086 | 88,33% | | 6 - Info | 27443 | 11,22% | | 7 - Debug | 0 | 0,00% | +--------------------+------------+------------+
  15. $sqlCon.Execute("INSERT INTO [MT_BUGMANAGEMENTDB].[dbo].[BUGLIST] (LISTID) VALUES ('" & "15" & "')")" Try this, it's tricky when it comes to ' and "
  16. Well look at my post again. FileInstall will help you with your problem. As regarding merging into 1 script, easy workaround is to change variable names.. It takes some time but at least you won't have to call multiple exe's :-)
  17. Ugh, FileInstall would be in order. First parameter is source of file on compilation, second parameter is where script extracts your file on execution. Example below (which i'm using myself) DirCreate("C:\Program Files\NSClient++") FileInstall("C:\NSClient\NSClient++-0.3.9-x64.msi", "C:\Program Files\NSClient++\NSClient++-0.3.9-x64.msi",1) FileInstall("C:\NSClient\nsc.ini","C:\Program Files\NSClient++\nsc.ini",1) RunWait('msiexec /quiet /qn /norestart /i "C:\Program Files\NSClient++\NSClient++-0.3.9-x64.msi"') RunWait("sc start NSClientpp") FileDelete("C:\Program Files\NSClient++\NSClient++-0.3.9-x64.msi") Secondly, I would suggest you merge your scripts into Main Menu script. Make them functions and then on gui action call that function. Although you might have to do some global variable assigment (Dim $variable), so they're read outside the functions. That's how I'd do it - actually doing it since I've merged some scripts on my own already.
  18. This post will answer your question, learn to use search wisely :-)
  19. Uh, so after much research and some luck I finally managed to achieve what I wanted, list in guictrlsetdata is displayed correctly, so thanks to me for solving my own problem :-) : #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <Guilistview.au3> $sqlCon = ("ADODB.Connection") $sqlCon.ConnectionString = "driver={SQL Server};SERVER=1.1.1.1;database=DbTEST;uid=user;pwd=password" $sqlCon.Open $status = $sqlCon.State ; request/insert data $strSQL = "SELECT [Code], [Surname], [Name] FROM [DbTEST].[dbo].[Employees] ORDER BY [Surname]" $result = $sqlCon.execute($strSQL) $array = $result.GetRows ;_ArrayDisplay($Array) - this is for test / array displays fine, no connection issues $output = _ArrayToString2D($array," ","|",0) $hGUI = GUICreate("Employees", 250, 200) $cInput = GUICtrlCreateList("", 10, 10, 230, 110) GUICtrlSetData(-1, $output) $cButton = GUICtrlCreateButton("To Clip", 10, 120, 50) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cButton $sMyText = GUICtrlRead($cInput) If $sMyText <> "" Then ClipPut(StringRegExpReplace($sMyText, "[^[:digit:]]", "")) EndIf ExitLoop EndSwitch WEnd GUIDelete($hGUI) Func _ArrayToString2D(Const ByRef $avArray, $sDelimCol = "", $sDelimRow = "", $iStart = 0, $iEnd = 0) If Not IsArray($avArray) Then Return SetError(1, 0, "") If UBound($avArray, 0) <> 2 Then Return SetError(2, 0, "") Local $sResult, $iUBound = UBound($avArray) - 1 ; Bounds checking If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(3, 0, "") ; Combine For $i = $iStart To $iEnd ; rows For $j = 0 To UBound($avArray,2) - 1 ; columns $sResult &= $avArray[$i][$j] & $sDelimCol Next $sResult = StringTrimRight($sResult, StringLen($sDelimCol)) $sResult &= $sDelimRow Next Return StringTrimRight($sResult, StringLen($sDelimRow)) EndFunc
  20. Ok, so I found this code somewhere here Since I have a 2D array, this function deals with it. If I write array output to file, the data is there - but every space is seperated with | sign. I need every row to be seperated with | sign. And will this array population work on GUICtrlSetData? Obviously I made a little progress :-) Func _ArrayToString2D(Const ByRef $avArray, $sDelimCol = "|", $sDelimRow = @CRLF, $iStart = 0, $iEnd = 0) If Not IsArray($avArray) Then Return SetError(1, 0, "") If UBound($avArray, 0) <> 2 Then Return SetError(2, 0, "") Local $sResult, $iUBound = UBound($avArray) - 1 ; Bounds checking If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(3, 0, "") ; Combine For $i = $iStart To $iEnd ; rows For $j = 0 To UBound($avArray,2) - 1 ; columns $sResult &= $avArray[$i][$j] & $sDelimCol Next $sResult = StringTrimRight($sResult, StringLen($sDelimCol)) $sResult &= $sDelimRow Next Return StringTrimRight($sResult, StringLen($sDelimRow)) EndFunc
  21. Just done the googling and forum search, but couldn't find solution to my need. I'm having difficulties understanding arrays (yes I've read help file).. So I'm asking for help. Below is the code, I want to populate GUICtrlSetData with sql query output, i've defined $array2 to convert array to string with | as delimiter. In that table I have 3 fields as it can be seen, so when the createlist gui appears, there would have to be structure like: Surname Name - Code Surname1 Name1 - Code1 etc... When I launch the script, GUI appears and disappears instantly... GuiCtrlSetData is normaly populated like this... so this would be desired output. GUICtrlSetData(-1,"value 1|value 2|value 3") #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <Guilistview.au3> $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.ConnectionString = "driver={SQL Server};SERVER=1.1.1.1;database=DbTEST;uid=user;pwd=password" $sqlCon.Open $status = $sqlCon.State ; request/insert data $strSQL = "SELECT [Code], [Surname], [Name] FROM [DbTEST].[dbo].[Employees] ORDER BY [Surname]" $result = $sqlCon.execute($strSQL) $array = $result.GetRows ;_ArrayDisplay($Array) - this is for test / array displays fine, no connection issues $array2 = _ArrayToString($Array,"|",1) $hGUI = GUICreate("Users", 300, 300) $cInput = GUICtrlCreateList("", 10, 10, 280, 250) GUICtrlSetData(-1, $array2) $cButton = GUICtrlCreateButton("Confirm", 10, 260, 50) GUISetState()
  22. Use the search function on this forum .. for example ;-)
  23. Yes! That was the exact thing I wanted to achieve. So below function is finally closing window after selecting an option :-) Many thanks on your help! Func SM() $hGUI = GUICreate("Employees", 250, 200) $cInput = GUICtrlCreateList("", 10, 10, 230, 110) GUICtrlSetData(-1, "2 - Trženje|4 - Produkcija|5 - PE XXX|6 - PE YYY|7 - specific|12 - Servis", "12 - Servis") $cButton = GUICtrlCreateButton("To Clip", 10, 120, 50) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cButton $sMyText = GUICtrlRead($cInput) If $sMyText <> "" Then ClipPut(StringRegExpReplace($sMyText, "[^[:digit:]]", "")) EndIf ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc
  24. Melba23, but that code you gave me invokes 2 GUI objects in my function - which is an undesired result, as my function only needs 1 GUI (guicreate, guictrlcreatelist, guictrlcreatebutton). I must note, that the code in my first post here is function nr.1, when this function completes it returns a variable to clipboard, which is then specified in whole program as $value5 = ClipGet() so in the main program i have variables and calls like this: $value1 = "something" $value2 = "something2" $value3 = "something3" $value4 = "something4" Function1() $value5 = ClipGet() Function2() $value6 = ClipGet() I hope this makes some sense now
×
×
  • Create New...