
Icarus
Members-
Posts
17 -
Joined
-
Last visited
Icarus's Achievements

Seeker (1/7)
0
Reputation
-
I have a remote WMI query working for bytes sent, but want to check for ports opened.. Is this any use or interest to you? #include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate("Based on Lod3n's Bandwidth Monitor:",220,100,0,0,-1,$WS_EX_TOOLWINDOW) $label1 = GUICtrlCreateLabel ( "Waiting for data...", 10, 5,200,20) $label2 = GUICtrlCreateLabel ( "Waiting for data...", 10, 50,200,20) GUISetState () $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" ;$strComputer = "localhost" $strComputer = "remotehost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") while 1 $colItems = $objWMIService.ExecQuery("SELECT BytesReceivedPersec,BytesSentPersec FROM Win32_PerfRawData_Tcpip_NetworkInterface", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems ToolTip($objItem.Name, 0, 0) ; sleep (1000) ; If $objItem.Name = "ADAPTER NAME HERE" Then ;MUST PUT ADAPTER NAME HERE $in = $objItem.BytesReceivedPersec $out = $objItem.BytesSentPersec $intext = "Bytes In: " & $in & @CRLF $outtext = "Bytes Out: " & $out &@CRLF GUICtrlSetData ($label1,$intext) GUICtrlSetData ($label2,$outtext) ; EndIf Next EndIf sleep(100) If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop WEnd
-
This is excellent work. Would it be possible to query a *remote* machine for this information? Icarus.
-
Go faster (more efficient) stripes needed
Icarus replied to Icarus's topic in AutoIt General Help and Support
Using both suggestions (global array check and sleep timer before the WEND) the code now runs at ZERO %!!! It peaks at 1.5% CPU for one second when it detects a new Window, then goes back to zero %. When it does the work it needs (logging etc) it peaks a little higher, but essentially its fixed!!! I did say you guru guys are awesome...!! Love it! Love the app, love coding, and love these forums!!!! Thank you a million times over people..!! Icarus -
Go faster (more efficient) stripes needed
Icarus replied to Icarus's topic in AutoIt General Help and Support
A Sleep (100) before the WEND causes processor utilisation of ~50% on a 20-window session.... Its important to get the balance of checking (almost) all the time quickly, whilst not using much CPU, hence the need for a quick way to check for new windows. Off to try Brett's suggestion.. Much appreciated.. -
Go faster (more efficient) stripes needed
Icarus replied to Icarus's topic in AutoIt General Help and Support
Thanks for the quick response!! I've tried the SLEEP (nn) in various places, but what happens then is that I miss some windows. As I'm trying to catch error messages, they may only be on screen for a couple of seconds... Brett - I'll try and incorporate your idea - nice one - and report back... Any other suggestions..?? Is this the best way?? -
Hello! The code below is using 10-12% processor utilisation, and uses more and more depending on the number of windows open. Is there a more efficient way of detecting a new window without checking each one in turn every time? AIM : - If {there's a new window that we haven't seen before} then {do something} - without using loads of cycles to find out!! Cheers gurus - you rock!! Icarus CODEWhile 1 ; Get the list of Window titles $avWinListCurrent = WinList() For $n = $avWinListCurrent[0][0] To 1 Step -1 ; Check has title and visible If ($avWinListCurrent[$n][0] <> "") And BitAND(WinGetState($avWinListCurrent[$n][1]), 2) Then ; Have we seen this window before? $fFound = False For $i = 1 To $avWinListPrevious[0][0] If $avWinListCurrent[$n][1] = $avWinListPrevious[$i][1] Then $fFound = True ExitLoop EndIf Next ; No we haven't - its a new Window, let's do something with it..... If Not $fFound Then ;{do something...blah blah }
-
_Service_UDF v4 : Build your own service with autoit code
Icarus replied to arcker's topic in AutoIt Example Scripts
I've been using a compiled Autoit .exe with the SRVANY resource kit utility, and it works fine. When I use this module, it installs OK, and starts up, but doesn't interact with the desktop (I'm using WINLIST()) even if the service is tickets to "interact". Is there a way to emulate what SRVANY does and allow it to interact with the desktop? Thanks, Icarus -
Cumulative Window lists (no duplicates)
Icarus replied to Icarus's topic in AutoIt General Help and Support
Final thanks to everyone. I now have a small application that when running, sits in the background waiting for error messages (in error.txt). When these are found, it takes a snapshot of the window for future investigation. It can be any words in error.txt ("error", "unable", "failed" etc.) Many many thanks to all who helped. Final code here for anyone who might find it helpful: #include <File.au3> #include <Array.au3> #include <ScreenCapture.au3> Global $Error = @ScriptDir & "\Error.txt" $WinError = FileRead($Error) Dim $aRecords If Not _FileReadToArray($Error,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon HotKeySet("^!q", "_Quit");Control+Alt+Q to exit the program ; Initialize log file, make sure it's writeable Global $sLogFile = "C:\Temp\WinLog.log" Global $hLogFile = FileOpen($sLogFile, 1); Write, append If $hLogFile = -1 Then MsgBox(16, "Error", "Failed to open file for write: " & $sLogFile) Exit EndIf FileWriteLine($hLogFile, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & _ " : Started window monitor script."); Timestamp matches _FileWriteLog format FileClose($hLogFile) ; Initialize tracking arrays Global $avWinListPrevious[1][2] = [[0, ""]], $avWinListCurrent ; Initialize error tracking array ; Monitor unique window handles While 1 $avWinListCurrent = WinList() For $n = $avWinListCurrent[0][0] To 1 Step -1 ; Check has title and visible If ($avWinListCurrent[$n][0] <> "") And BitAND(WinGetState($avWinListCurrent[$n][1]), 2) Then ; Check for already seen $fFound = False For $i = 1 To $avWinListPrevious[0][0] If $avWinListCurrent[$n][1] = $avWinListPrevious[$i][1] Then $fFound = True ExitLoop EndIf Next ; New window found If Not $fFound Then _FileWriteLog($sLogFile, "New window detected: hWnd: " & $avWinListCurrent[$n][1] & _ " Title: " & $avWinListCurrent[$n][0]) _FileWriteLog ($sLogfile,"Debug: " & $avWinListCurrent[$n][0]) ; Check for error window titles, and if found, capture window If CompareError($avWinListCurrent[$n][0]) Then _ScreenCapture_CaptureWnd (@MyDocumentsDir & $avWinListCurrent[$n][0] & ".jpg", $avWinListCurrent[$n][1]) EndIf Else _ArrayDelete($avWinListCurrent, $n) EndIf Next $avWinListCurrent[0][0] = UBound($avWinListCurrent) - 1 $avWinListPrevious = $avWinListCurrent Sleep(500) WEnd Func _Quit() Exit EndFunc ;==>_Quit Func CompareError($sText) ;Return False For $x = 1 to $aRecords[0] ;ConsoleWrite ($aRecords[$x] & @LF) If StringInStr($sText, $aRecords[$x]) Then Return True Next EndFunc -
Cumulative Window lists (no duplicates)
Icarus replied to Icarus's topic in AutoIt General Help and Support
I've tried to break this down into just reading the list of error codes into the array, and passing it a dummy window handle ($sText): Global $Error = @ScriptDir & "\Error.txt" #Include <Array.au3> #include <file.au3> Dim $aRecords ;Read the file into an array If Not _FileReadToArray($Error,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf ;Function to compare each word in Error.txt with the current window title and return TRUE if any match Func CompareError($sText) For $x = 1 to $aRecords[0] ConsoleWrite ($aRecords[$x] & @LF) If StringInStr($aRecords[$x], $sText) Then Return True Return False Next EndFunc ;Dummy window title $sText="Windows Task Manager" If CompareError($sText) then ConsoleWrite ("Matched" & $sText & @LF) This code doesn't return anything, even when there is only one word, "Task", in error.txt Icarus -
Cumulative Window lists (no duplicates)
Icarus replied to Icarus's topic in AutoIt General Help and Support
OK. Still struggling with finding the errors from the error file (error.txt) in the window lists. It works if I put an EXACT copy of a window title in. I've switched the parameters round to help highlight this: Global $Error = @ScriptDir & "\Error.txt" $WinError = FileRead($Error) Func CompareError($sText) If StringInStr($WinError, $sText) Then Return True Return False EndFunc Do {any of the words in this text file : error.txt} match {any part of the current window title, $stext) Please can I ask for a little more input? Cheers.... -
Cumulative Window lists (no duplicates)
Icarus replied to Icarus's topic in AutoIt General Help and Support
...just realised that komalo has got some error checking in that code example - hadn't spotted that. Checking that out now.. cheers again... -
Cumulative Window lists (no duplicates)
Icarus replied to Icarus's topic in AutoIt General Help and Support
Thankx to you all - Weaponx - nice, and simple - I can understand that. Cheers. Komalo - Thanks for both your post too - especially the shell hook stuff. That was a little over my head, but I'm reading through it slowly to try and understand.. PsaltyDS - WOW! - Your code example is great. The handle grabbing is just what I was after, as now when a new handle is found, I can grab a screenshot using: ; Capture window _ScreenCapture_CaptureWnd (@MyDocumentsDir & $avWinListCurrent[$n][0] & ".jpg", $avWinListCurrent[$n][1]) As this stands, my project is nearly there. It is capturing window titles, and logging them with date / time stamps. When a new window is found it takes a screenshot of that window. The final piece of the jigsaw is to have it screen grab specific windows based on a list of key words. I was thinking that I would pre-load an array of words like this: Global $avErrorlist[1]=["error"] And then do a comparison of the window title: if $avWinListCurrent[$n][0] = $avErrorlist[1] then ;Capture window. Since I want to compile this to a .exe for deployment, it probably not a good idea to have hard-coded error lists within the app. Any suggestions of where to store / add these would be very welcome, or a better way to do the window comparison. Finally, I'd like to ensure I can compare long text names with spaces too, eg : "Task Manager". Once again, a HUGE thank you to the skills and coding examples shown here. You guys are amazing.. Icarus. -
Cumulative Window lists (no duplicates)
Icarus replied to Icarus's topic in AutoIt General Help and Support
Aim of project - To gradually build up a list of uinique window titles, including the date and time stamp when they first appear, and to optionally do something if one of the window titles matches a list of error words (in errors.txt) such as "not responding". Here is my code so far: Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon #include <Array.au3> Local $avArray[1] ;Open a file for writing: $file = FileOpen("windows.txt", 2) $file2 = FileOpen("errors.txt", 0) ; Check if file opened for reading OK If $file2 = -1 Then ConsoleWrite ("Error", "Unable to open file.") Exit EndIf ; Check if file opened for writing OK If $file = -1 Then ConsoleWrite ("Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file2) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $errors) ;Get window list $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then ;dump these window titles to a file (Windows.txt) $iIndex = _ArraySearch($avArray, $var[$i][0], 0, 0, 0, 1) If @error Then _ArrayAdd($avArray, $var[$i][0]) FileWriteLine($file, $var[$i][0] & @CRLF) Else ;MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ".") EndIf ;if an error string is found, then do something here: $found=(StringRegExp($var[$i][0], $line)) if ($found >0) Then ;ConsoleWrite ($var[$i][0] & @LF) EndIf EndIf Next Wend ;_ArrayDisplay($avArray, "$avArray AFTER _ArrayAdd()") FileClose($file) FileClose($file2) ;Sleep(1000) Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc -
Cumulative Window lists (no duplicates)
Icarus replied to Icarus's topic in AutoIt General Help and Support
Komalo, This is spot on, thank you, as I really need the date and time, just as you've done it. The only problem I have now, is that when I run it again and again, I end up with Windows.txt getting bigger and bigger. I need it to grow with each UNIQUE window title. If I read back the contents of Windows.txt, and compare it to the WINLIST () array, every line is unique because of the date and time stamp. Is it possible to 1) Read the WINDOWS.TXT file and COMPARE this to the current window list (without the date / time stamp) 2) Output unique Window lists Its getting at the Window title in the WINDOWS.TXT file that I can't do, as its bringing back the date / time stamp too. Thanks so much. Its really really helpful. Icarus.