Hallo erst mal...
Ich versuche mich gerade etwas an Autoit.Gerne würde ich mit Autoit die CPU Temperatur auslesen.Hab mich durch einige Beitrag/Foren durch gelesen und hab festgestellt... so einfach geht es wohl nicht.
Bin jetzt auf das Programm CoreTemp gestoßen, was eine CSV Log Datei anlegt.Da würde ich jetzt gerne ein paar Daten auslesen.
Klappt auch alles soweit, nur wenn ich mit dem Script an mein Notebook gehe, ließt es nicht mehr die High Temp aus.Da die CSV Log Datei, die CoreTemp anlegt sich geändert hat.
Starten man CoreTemp auf einem anderem System mit einer CPU der mehr oder weniger Kerne hat, ändert sich die Zeile im CSV File.
Die Reihe kann ich mit ArraySearch ermitteln, wie kann ich aber die Zeile ermitteln?
Spoiler anzeigen
#include <array.au3>
; Automatisches Erkennen der *.CSV datei in @ScriptDir&\coreTemp64\
$FileFind = FileFindFirstFile("coreTemp64\ct-log*.csv")
If @error > 0 Then
ConsoleWrite("FileFindFirstFile Error: Fehler beim suchen der Datei!"&@Crlf)
Else
ConsoleWrite("FileFindFirstFile: File gefunden"&@Crlf)
EndIf
$Fp = FileFindNextFile($FileFind)
If @error = 1 Then
ConsoleWrite("FileFindNextFile Error: Fehler beim suchen der Datei!"&@Crlf)
Else
ConsoleWrite("FileFindNextFile: "&$Fp&" weiter geleitet"&@crlf)
EndIf
Local $sAdr = @ScriptDir&"\coretemp64\"
Local $h = FileOpen($sAdr&$Fp, 0)
ConsoleWrite("FileOpen "&$h&@CRLF&@CRLF)
Local $aRet = _CSV2Array($h, ",", True, 1)
ConsoleWrite($aRet&@CRLF)
FileClose($h)
;**********ENDE********* Automatisches Erkennen der *.CSV datei
;~ _ArrayDisplay($aRet)
;Sucht nach der Reihe
$Find0=_ArraySearch($aRet,"Processor",0,0,0,1,1)
ConsoleWrite("Processor gefunden in Reihe "&$Find0&@CRLF)
$Find1=_ArraySearch($aRet,"Revision",0,0,0,1,1)
ConsoleWrite("Revision gefunden in Reihe "&$Find1&@CRLF)
$Find2=_ArraySearch($aRet,"Lithography",0,0,0,1,1)
ConsoleWrite("Lithography gefunden in Reihe "&$Find2&@CRLF&@CRLF)
$Find3=_ArraySearch($aRet,"Core 0 temp.",0,0,0,1,1)
ConsoleWrite("Core 0 Temp. gefunden in Reihe "&$Find3&@CRLF)
$Find4=_ArraySearch($aRet,"High temp.",0,0,0,1,1) ;hier findet man zwar die Reihe, aber wie kann ich die Zeile ermitteln?
ConsoleWrite("High Temp. gefunden in Reihe "&$Find4&@CRLF&@CRLF)
for $i =0 To Ubound($aRet)-1
For $k = 0 To UBound($aRet,2)-1
$test0 = ($aRet[$find0][1]); find0 - find2 stehten immer in der selben Zeile
$test1 = ($aRet[$find1][1])
$test2 = ($aRet[$find2][1])
$test3 = ($aRet[$i][1])
$test4 = ($aRet[$i][6]) ;die High Temp steht je nachdem wie viele Cores die Cpu hat, in unterschiedlichen Zeilen
Next
Next
MsgBox(0,"CoreTemp","CPU: "&$test0&@CRLF&"Revision: "&$test1&@CRLF&"Lithography: "&$test2&@CRLF&"CPU Temp: "&$test3&" °C"&@CRLF&"CPU High Temp: "&$test4&" °C"&@CRLF)
;~ ConsoleWrite("CPU: "&$test0&@CRLF&"Revision: "&$test1&@CRLF&"Lithography: "&$test2&@CRLF&@CRLF)
; #FUNCTION# ===================================================================
; Name ..........: _CSV2Array
; Description ...:
; AutoIt Version : V3.3.0.0
; Syntax ........: _CSV2Array($hFile[, $cSeperator = "auto"[, $bFilterString = True[, $iColumnMode = 0]]])
; Parameter(s): .: $hFile - Handle for the CSV file to Read
; $cSeperator - Optional: (Default = "auto") : Tries to find the separator char or , or TAB or | or space)
; | Data-seperator-char
; | Empty-string = Opt("GUIDataSeparatorChar")
; $bFilterString - Optional: (Default = True) : Removes leading and trailing " or '
; $iColumnMode - Optional: (Default = 0) :
; | 0: Sets error if lines have different columns and @extended to the csv-line number
; | 1: returns lines with different columns numbers comparing to the first line, too
; | 2: removing all columns > column numbers in the first line
; Return Value ..: Success - 2-dim Array
; Failure - 0
; @ERROR - 1: error file read
; @ERROR - 2: different number of columns / @EXTENDED = CSV-line
; - 3: parameter error
; Author(s) .....: Thorsten Willert
; Date ..........: Mon Dec 07 18:54:35 CET 2009
; ==============================================================================
Func _CSV2Array($hFile, $cSeperator = "auto", $bFilterString = True, $iColumnMode = 0)
Local $s = FileRead($hFile)
If @error Then Return SetError(1)
If $cSeperator = Default Then $cSeperator = "auto"
If Not $cSeperator Then $cSeperator = Opt("GUIDataSeparatorChar")
; searching the line-seperator and splitting the lines into an array
Local $aLines
If StringInStr($s, @CRLF) Then
$aLines = StringSplit($s, @CRLF, 1)
ElseIf StringInStr($s, @CR) Then
$aLines = StringSplit($s, @CR)
Else
$aLines = StringSplit($s, @LF)
EndIf
; searching the delimiter in the first line
Local $aTMP
If $cSeperator = "auto" Then
Local $iMax = 0
Local $iC[5] = [0, 0, 0, 0, 0]
Local $sC[5] = [";", ",", @TAB, "|", " "]
$aTMP = StringRegExp($aLines[1], ";", 3)
If Not @error Then $iC[0] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], ",", 3)
If Not @error Then $iC[1] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], "\t", 3)
If Not @error Then $iC[2] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], "\|", 3)
If Not @error Then $iC[3] = UBound($aTMP)
$aTMP = StringRegExp($aLines[1], "[ ]", 3)
If Not @error Then $iC[4] = UBound($aTMP)
For $i = 0 To UBound($sC) - 1
If $iC[$i] > $iMax Then
$iMax = $iC[$i]
$cSeperator = $sC[$i]
EndIf
Next
EndIf
; creating 2-dim array based on the number of data in the first line
$aTMP = StringSplit($aLines[5], $cSeperator)
Local $iCol = $aTMP[0]
Local $aRet[$aLines[0]][$iCol]
; splitting and filling the lines
For $i = 1 To $aLines[0]
$aTMP = StringSplit($aLines[$i], $cSeperator)
If @error Then ContinueLoop
If $aTMP[0] > $iCol Then
Switch $iColumnMode
Case 0
Return SetError(2, $i)
Case 1
ReDim $aRet[$aLines[0] - 1][$aTMP[0]]
Case 2
$aTMP[0] = $iCol
Case Else
Return SetError(3)
EndSwitch
EndIf
For $j = 1 To $aTMP[0]
$aTMP[$j] = StringStripWS($aTMP[$j], 3)
If $bFilterString Then ; removing leading and trailing " or '
$aTMP[$j] = StringRegExpReplace($aTMP[$j], '^("|'')(.*?)\1$', '$2')
EndIf
$aRet[$i - 1][$j - 1] = $aTMP[$j]
Next ; /cols
Next ; /lines
Return $aRet
EndFunc ;==>_CSV2Array