Hier noch ein Beispiel:
Source Code ist zu groß für die Code Box -> http://pastebin.com/KKqi3WBe
Gruß,
UEZ
Hier noch ein Beispiel:
Source Code ist zu groß für die Code Box -> http://pastebin.com/KKqi3WBe
Gruß,
UEZ
Probiere es mal damit:
[autoit]
#include <File.au3>
Global $aZahlen
_FileReadToArray(@ScriptDir & "\Zahlen.txt", $aZahlen)
For $i = 1 To $aZahlen[0]
$hFile = FileOpen(@ScriptDir & "\" & $aZahlen[$i] & ".txt", 2)
FileWrite($hFile, $aZahlen[$i])
FileClose($hFile)
Next
Zahlen.txt ist die Datei mit den 4 Zeilen an Zahlen.
Gruß,
UEZ
Guckst du hier:
[autoit]
#include <GUIConstantsEx.au3>
$hGUI = GUICreate("No Taskbar", 200, 200, -1, -1, Default, Default, WinGetHandle(AutoItWinGetTitle()))
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Gruß,
UEZ
"Nur" den Font in den Binärstring umwandeln reicht nicht. DU musst auch die Zeile
GUICtrlSetFont(-1, 20, 400, 0, <Fontname>")
anpassen, wobei der Fontname nicht der Dateiname ist, sondern der interne Name -> Eigenschatf TTF -> Title.
Gruß,
UEZ
Oder vielleicht hier: http://www.autoitscript.com/forum/topic/24342-form-snap oder hier: http://www.autoitscript.com/forum/topic/12…w-alignment-udf
Gruß,
UEZ
Probiere es mal damit:
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#Include <GuiMenu.au3>
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
Global Enum $idSave = 1000
$hFile = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem($hFile, 0, "&Speichern", $idSave)
$hMain = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem($hMain, 0, "&Datei", 0, $hFile)
_GUICtrlMenu_SetMenu($Form1, $hMain)
GUISetState()
Global Const $sFile = StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\Torus.png")
Global $hBMP_File_Save = _GUICtrlMenu_CreateBitmap($sFile, 0)
_GUICtrlMenu_SetItemBmp($hFile, 0, $hBMP_File_Save)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_WinAPI_DeleteObject($hBMP_File_Save)
Exit
EndSwitch
WEnd
Func _GUICtrlMenu_CreateBitmap($file, $iIndex = 0, $iW = 18, $iH = 18)
If FileExists($file) Then
Local $iStride = 0, $iPixelFormat = $GDIP_PXF32ARGB, $pScan0 = 0
Local $GDIp = True, $Ret, $hIcon, $hImage, $hBitmap, $hContext, $hIcon
If Not $ghGDIPDll Then
$GDIp = False
_GDIPlus_Startup()
EndIf
Local $fext = StringMid($file, StringLen($file) - 3)
Switch $fext
Case ".dll"
$Ret = DllCall("shell32", "long", "ExtractAssociatedIcon", "int", 0, "str", $file, "int*", $iIndex)
If @error Then Return SetError(2, @extended, 0)
$hIcon = $Ret[0]
$Ret = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromHICON", "ptr", $hIcon, "int*", 0)
If @error Then Return SetError(3, @extended, 0)
$hImage = $Ret[2]
_WinAPI_DestroyIcon($hIcon)
Case ".jpg", ".png", ".bmp", ".gif"
$hImage = _GDIPlus_ImageLoadFromFile($file)
If @error Then Return SetError(4, @extended, 0)
EndSwitch
$Ret = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
If @error Then Return SetError(5, @extended, 0)
$hBitmap = $Ret[6]
$hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iW, $iH)
$hIcon = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hImage)
If Not $GDIp Then _GDIPlus_Shutdown()
Return $hIcon
Else
Return SetError(1, 0, 0)
EndIf
EndFunc ;==>_GUICtrlMenu_CreateBitmap
Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap)
Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0
$Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
If (@error) Or ($Ret[0]) Then Return 0
$tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
$pBits = DllStructGetData($tData, 'Scan0')
If Not $pBits Then Return 0
$tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword')
DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR))
DllStructSetData($tBIHDR, 2, $Ret[2])
DllStructSetData($tBIHDR, 3, $Ret[3])
DllStructSetData($tBIHDR, 4, 1)
DllStructSetData($tBIHDR, 5, 32)
DllStructSetData($tBIHDR, 6, 0)
$hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
If (Not @error) And ($hResult[0]) Then
DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
$hResult = $hResult[0]
Else
$hResult = 0
EndIf
_GDIPlus_BitmapUnlockBits($hBitmap, $tData)
Return $hResult
EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap
Ich werde bei Gelegenheit die UDF anpassen, damit sie auch Bilderdateien laden kann.
Gruß,
UEZ
Hilft dir das hier vielleicht weiter? -> _GUICtrlMenu_CreateBitmap() v0.55 Build 2011-08-16 beta - Erstellt Icons für GUI Menüs
Gruß,
UEZ
Schaue mal hier nach -> File to Base64 String Code Generator v1.03 Build 2011-11-21
Gruß,
UEZ
Hilft dir das weiter:
[autoit]
#include <Array.au3>
$CPUTemp_Log = FileRead("CT-Log 2011-12-27 12-10-50.csv")
$aCPUTemp_Log = StringRegExp($CPUTemp_Log, "(\d+:\d+:\d+\s\d+/\d+/\d+),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),", 4)
$Anzahl_Messungen = UBound($aCPUTemp_Log)
;alle Messungen anzeigen
For $i = 0 To $Anzahl_Messungen - 1
_ArrayDisplay($aCPUTemp_Log[$i])
Next
;Core Load % der 8. Messung in Spalte 13 anzeigen
$aTemp = $aCPUTemp_Log[8]
MsgBox(0, "Test", "Core Load % der 8. Messung: " & $aTemp[13] & " %")
Gruß,
UEZ
Wo ist der CSV Anhang?
Gruß,
UEZ
Es kommt darauf an, was du im Gesamten machen willst.
Wenn du weißt, dass du viele GDI+ Funktionienen benutzt, macht es keinen Sinn in der Funktion _GDIPlus_Startup() und _GDIPlus_Shutdown() ständig zu benutzen, denn es kostet Zeit. Ein paar mal _GDIPlus_Startup() und _GDIPlus_Shutdown() aufrufen ist aber verkraftbar.
_GDIPlus_Startup() am Anfang aufrufen und _GDIPlus_Shutdown() beim Beenden ist wohl die beste Lösung, denn ich sehe keinen Nachteil, auch wenn du keine GDI+ Funktionienen benutzt.
Gruß,
UEZ
Ich habe den Code im Beitrag #6 modifiziert, so dass du das Bild in 90° Schritten drehen kannst.
Gruß,
UEZ
Natürlich muss man nicht 2x GuiCtrlCreatePic, aber ich hatte dich so verstanden.
Gruß,
UEZ
PS: viele Wege führen nach Rom...
Probiere es mal damit:
#region ;************ Includes ************
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#endregion ;************ Includes ************
Opt("GUIOnEventMode", 1) ; 0=ausgeschaltet, 1=OnEvent Modus aktiviert
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global Const $IMAGE_BITMAP = 0
Global Const $STM_SETIMAGE = 0x0172
Global $hPreviewBitmap
Global $datei1 = "C:\Windows\Web\Wallpaper\Windows\img0.jpg"
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup() ;Vorschau
[/autoit] [autoit][/autoit] [autoit]Global $hPreviewGui = GUICreate("Foto", 710, 350)
Global $idPreviewPic = GUICtrlCreatePic("", 10, 10, 300, 200)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $idPreviewPic2 = GUICtrlCreatePic("", 400, 10, 200, 300)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $idButtonLoad = GUICtrlCreateButton("Laden", 300, 250, 60, 40)
GUICtrlSetOnEvent(-1, "Load")
GUISetOnEvent($GUI_EVENT_CLOSE, "_beenden")
_PreviewLoadImage($datei1, $idPreviewPic, 300, 200)
GUISetState()
While 1
Sleep(10)
WEnd
Func _beenden()
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_beenden
Func Load()
Local $file = FileOpenDialog("Suche ein Bild aus", "", "Bilder (*.jpg;*png;*.bmp;*.gif)")
If @error Then Return
_PreviewLoadImage($file, $idPreviewPic2, 300, 200, 7, 1, 1)
EndFunc
; $iRotateFlipType - Type of rotation and flip:
; |0 - No rotation and no flipping (A 180-degree rotation, a horizontal flip and then a vertical flip)
; |1 - A 90-degree rotation without flipping (A 270-degree rotation, a horizontal flip and then a vertical flip)
; |2 - A 180-degree rotation without flipping (No rotation, a horizontal flip folow by a vertical flip)
; |3 - A 270-degree rotation without flipping (A 90-degree rotation, a horizontal flip and then a vertical flip)
; |4 - No rotation and a horizontal flip (A 180-degree rotation followed by a vertical flip)
; |5 - A 90-degree rotation followed by a horizontal flip (A 270-degree rotation followed by a vertical flip)
; |6 - A 180-degree rotation followed by a horizontal flip (No rotation and a vertical flip)
; |7 - A 270-degree rotation followed by a horizontal flip (A 90-degree rotation followed by a vertical flip)
Func _PreviewLoadImage($sImgFile, $CtrlID, $iW, $iH, $iInterpolationMode = 7, $iRotateFlipType = 0, $clear = 0)
If $clear Then GUICtrlSendMsg($CtrlID, $STM_SETIMAGE, $IMAGE_BITMAP, 0)
Local $hImage = _GDIPlus_ImageLoadFromFile($sImgFile)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
Local $hBitmap = $aResult[6]
Local $hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hGfxCtxt, "int", $iInterpolationMode)
_GDIPlus_GraphicsDrawImageRect($hGfxCtxt, $hImage, 0, 0, $iW, $iH)
If $iRotateFlipType Then DllCall($ghGDIPDll, "uint", "GdipImageRotateFlip", "hwnd", $hBitmap, "int", $iRotateFlipType)
Local $hHBitmap = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGfxCtxt)
_WinAPI_DeleteObject(GUICtrlSendMsg($CtrlID, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap))
EndFunc ;==>_PreviewLoadImage
Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap)
Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0
$Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
If (@error) Or ($Ret[0]) Then Return 0
$tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
$pBits = DllStructGetData($tData, 'Scan0')
If Not $pBits Then Return 0
$tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword')
DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR))
DllStructSetData($tBIHDR, 2, $Ret[2])
DllStructSetData($tBIHDR, 3, $Ret[3])
DllStructSetData($tBIHDR, 4, 1)
DllStructSetData($tBIHDR, 5, 32)
DllStructSetData($tBIHDR, 6, 0)
$hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
If (Not @error) And ($hResult[0]) Then
DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
$hResult = $hResult[0]
Else
$hResult = 0
EndIf
_GDIPlus_BitmapUnlockBits($hBitmap, $tData)
Return $hResult
EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap
Gruß,
UEZ
Ich meinte eher eine Art Animation. Ansonsten kannst du mehrere Bilder in verschiedene Picture Controls reinkopieren und fertig.
Gruß,
UEZ
Wenn du "nur" die Grafik anzeigen möchtest, würde ich das Bild eher in einem Picture Control darstellen.
Siehe hier: [ gelöst ] Png in GUI laden
Gruß,
UEZ
Wenn ich dein Testprojekt öffne, rechts auf die _Testfunc doppelt klicke und anschließend den AutoIt Syntax Check ausführe, bekomme ich spätestens beim zweiten Aufruf eine Fehlermeldung:
Error: Subscript used with non-Array variable.
Habe die Exe nur getestet!
Gruß,
UEZ
Du kannst auch die GetCoreTempInfo.dll anzapfen, wenn Core Temp läuft!
#cs
Shared memory implementation in Core Temp:
Core Temp shares the following structure:
[/autoit] [autoit][/autoit] [autoit]typedef struct core_temp_shared_data
{
unsigned int uiLoad[256];
unsigned int uiTjMax[128];
unsigned int uiCoreCnt;
unsigned int uiCPUCnt;
float fTemp[256];
float fVID;
float fCPUSpeed;
float fFSBSpeed;
float fMultipier;
char sCPUName[100];
unsigned char ucFahrenheit;
unsigned char ucDeltaToTjMax;
}CORE_TEMP_SHARED_DATA,*PCORE_TEMP_SHARED_DATA,**PPCORE_TEMP_SHARED_DATA;
unsigned int is a 32bit unsigned integer.
unsigned char is 8bit (1 byte) in size.
ucFahrenheit and ucDeltaToTjMax represent boolean values. 0 = false, 1 = true.
If ucFahrenheit is set, the temperature is reported in Fahrenheit.
If ucDeltaToTjMax is set, the temperature reported respresents the distance from TjMax.
Core Temp's shared area is named: "CoreTempMappingObject".
[/autoit] [autoit][/autoit] [autoit]C++ Dynamic Link Library:
[/autoit] [autoit][/autoit] [autoit]This DLL was written in C++, and it can be easily used with most programming languages.
There is only a single function. Here is the internal function declaration:
bool __declspec(dllimport) fnGetCoreTempInfo(CORE_TEMP_SHARED_DATA *&pData);
[/autoit] [autoit][/autoit] [autoit]You can declare it in your program in the following manner:
[/autoit] [autoit][/autoit] [autoit]typedef bool (*fnGetCoreTempInfo)(CORE_TEMP_SHARED_DATA *&pData);
fnGetCoreTempInfo GetCoreTempInfo;
For compatibility with some programming languages a function was added.
It uses Win32 API calling convention and is declared as follows:
bool WINAPI fnGetCoreTempInfoAlt(CORE_TEMP_SHARED_DATA *pData);
[/autoit] [autoit][/autoit] [autoit]typedef bool (*fnGetCoreTempInfoAlt)(CORE_TEMP_SHARED_DATA *pData);
fnGetCoreTempInfoAlt GetCoreTempInfo;
Usage:
[/autoit] [autoit][/autoit] [autoit]* Declare a pointer to CORE_TEMP_SHARED_DATA structure and allocate it.
It is also recommended to fill the allocated memory with NULL to avoid possible problems.
* Call the function using the pointer to CORE_TEMP_SHARED_DATA structure as an argument.
The function will fill the structure if the shared memory was successfully read.
* The function returns 'true' if succeeded and 'false' if it failed. You can use GetLastError() in case the function fails.
* In case the function fails due to an exception GetLastError() returns UNKNOWN_EXCEPTION (0x20000000)
#ce
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_After=upx.exe --ultra-brute "%out%"
#AutoIt3Wrapper_Run_After=del /f /q GetCoreTempInfo_Obfuscated.au3
If Not FileExists(@ScriptDir & "\GetCoreTempInfo.dll") Or Not ProcessExists("Core Temp.exe") Then
MsgBox(16,"Error", "Core Temp.exe läuft und/oder GetCoreTempInfo.dll existiert nicht", 20)
Exit
EndIf
$dll = DllOpen(@ScriptDir & "\GetCoreTempInfo.dll")
$CORE_TEMP_SHARED_DATA = DllStructCreate("uint uiLoad[256];" & _
"uint uiTjMax[128];" & _
"uint uiCoreCnt;" & _
"uint uiCPUCnt;" & _
"float fTemp[256];" & _
"float fVID;" & _
"float fCPUSpeed;" & _
"float fFSBSpeed;" & _
"float fMultipier;" & _
"char sCPUName[100];" & _
"ubyte ucFahrenheit;" & _
"ubyte ucDeltaToTjMax")
$call = DllCall($dll, "int", "fnGetCoreTempInfoAlt", "ptr", DllStructGetPtr($CORE_TEMP_SHARED_DATA))
[/autoit] [autoit][/autoit] [autoit]$CPU_Name = DllStructGetData($CORE_TEMP_SHARED_DATA, "sCPUName")
$CPU_Speed = Round(DllStructGetData($CORE_TEMP_SHARED_DATA, "fCPUSpeed"),0)
$CPU_Cores = DllStructGetData($CORE_TEMP_SHARED_DATA, "uiCoreCnt")
$CPU_FSB_Speed = Round(DllStructGetData($CORE_TEMP_SHARED_DATA, "fFSBSpeed"), 0)
$CPU_Multiplicator = DllStructGetData($CORE_TEMP_SHARED_DATA, "fMultipier")
$CPU_Temp = ""
For $i = 1 To DllStructGetData($CORE_TEMP_SHARED_DATA, 'uiCoreCnt')
$CPU_Temp &= DllStructGetData($CORE_TEMP_SHARED_DATA, "fTemp", $i) & ","
Next
$CPU_Temp = StringMid($CPU_Temp, 1 , StringLen($CPU_Temp) - 1)
MsgBox(0,"Core Temp", _
"CPU Name: " & $CPU_Name & @CRLF & _
"CPU Speed: " & $CPU_Speed & " MHz" & @CRLF & _
"CPU Cores: " & $CPU_Cores & @CRLF & _
"CPU FSB Speed: " & $CPU_FSB_Speed & " MHz" & @CRLF & _
"CPU Multiplicator: " & $CPU_Multiplicator & @CRLF & _
"CPU Temp: " & $CPU_Temp & " C", 30)
$CORE_TEMP_SHARED_DATA = 0
DllClose($dll)
Gruß,
UEZ