Schaue mal hier rein: AutoIt Windows Screenshooter v1.71 Build 2013-11-18 ![]()
Gruß,
UEZ
Schaue mal hier rein: AutoIt Windows Screenshooter v1.71 Build 2013-11-18 ![]()
Gruß,
UEZ
Hier die Version, die du ursprünglich geplant hattest (benötigt die aktuelle Beta!![]()
#AutoIt3Wrapper_Version=b
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
[/autoit][autoit][/autoit][autoit]Global $hImage, $hGUI, $hGrafics
[/autoit][autoit][/autoit][autoit]$hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("http://aut1.autoit-cdn.com/images/logo_autoit_210x72@2x.png"))
Global $iWidth = _GDIPlus_ImageGetWidth($hImage)
Global $iHeight = _GDIPlus_ImageGetHeight($hImage)
$hGUI = GUICreate("Mein Design", $iWidth, $iHeight, -1, -1)
GUISetBkColor(0x808090, $hGUI)
$iLabel = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight)
GUISetState()
$hGrafics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGrafics, $hImage, 0, 0, $iWidth, $iHeight)
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
[/autoit][autoit][/autoit][autoit]While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_GDIPlus_GraphicsDispose($hGrafics)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Exit
Case $iLabel
MsgBox(0, "Test", "Grafik wurde geklickt")
EndSwitch
WEnd
; Draw PNG image
Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImageRect($hGrafics, $hImage, 0, 0, $iWidth, $iHeight)
Return $GUI_RUNDEFMSG
EndFunc
Gruß,
UEZ
Andy: mir ging es mehr um das Speichern des Bildes direkt im Speicher, also ohne das Zwischenspeichern auf die Platte.
Gruß,
UEZ
Probiere es mal damit (benötigt die aktuelle Beta)!:
[autoit]
#AutoIt3Wrapper_Version=b
#include <Clipboard.au3>
#include <Crypt.au3>
#include <Screencapture.au3>
_GDIPlus_Startup()
$BILDinZWSPEICHER = _ScreenCapture_Capture("", 0, 0, 9, 9, 0) ; 10x10 an der Stelle 0,0
$bild = _GDIPlus_BitmapCreateFromHBITMAP($BILDinZWSPEICHER)
$sFile = _GDIPlus_StreamImage2BinaryString($bild, "PNG")
ConsoleWrite($sFile & @LF)
_WinAPI_DeleteObject($BILDinZWSPEICHER)
_GDIPlus_BitmapDispose($bild)
_Crypt_Startup()
$MD5 = _Crypt_HashData($sFile, $CALG_MD5)
MsgBox(0, 'Hash', "MD5: " & Hex($MD5))
_Crypt_Shutdown()
_GDIPlus_Shutdown()
Func _GDIPlus_StreamImage2BinaryString($hBitmap, $sFormat = "JPG", $iQuality = 80, $bSave = False, $sFilename = @ScriptDir & "\Converted.jpg") ;coded by UEZ 2013 build 2013-09-14
Local $sImgCLSID, $tGUID, $tParams
Switch $sFormat
Case "JPG"
$sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat)
$tGUID = _WinAPI_GUIDFromString($sImgCLSID)
Local $tData = DllStructCreate("int Quality")
DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100
Local $pData = DllStructGetPtr($tData)
$tParams = _GDIPlus_ParamInit(1)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
Case "PNG", "BMP", "GIF", "TIF"
$sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat)
$tGUID = _WinAPI_GUIDFromString($sImgCLSID)
Case Else
Return SetError(1, 0, 0)
EndSwitch
Local $hStream = _WinAPI_CreateStreamOnHGlobal() ;http://msdn.microsoft.com/en-us/library/ms864401.aspx
If @error Then Return SetError(2, 0, 0)
_GDIPlus_ImageSaveToStream($hBitmap, $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams))
If @error Then Return SetError(3, 0, 0)
_GDIPlus_BitmapDispose($hBitmap)
Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx
If @error Then Return SetError(4, 0, 0)
Local $iMemSize = _MemGlobalSize($hMemory)
If Not $iMemSize Then Return SetError(5, 0, 0)
Local $pMem = _MemGlobalLock($hMemory)
$tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem)
Local $bData = DllStructGetData($tData, 1)
_WinAPI_ReleaseStream($hStream) ;http://msdn.microsoft.com/en-us/library/…3(v=vs.85).aspx
_MemGlobalFree($hMemory)
If $bSave Then
Local $hFile = FileOpen($sFilename, 18)
If @error Then Return SetError(6, 0, $bData)
FileWrite($hFile, $bData)
FileClose($hFile)
EndIf
Return $bData
EndFunc ;==>_GDIPlus_StreamImage2BinaryString
Gruß,
UEZ
Na ja, ich würde es mehr Flexibilität nennen, anstatt Dynamik.
Anstatt das Glücksrad immer wieder neu zu berechnen, würde ich an deiner Stelle es nur einmal zeichnen und es nur noch rotieren lassen.
Wenn du was verändern möchtest, dann eben nur dann neuzeichnen.
Gruß,
UEZ
Welche Dynamik fehlt dir denn?
Meine Berechnung sieht etwas kompliziert aus, aber sollte nicht so schwer sein zu verstehen, da die Kalkulation sich im Prinzip auf 4 Zeilen beschränkt.
Im Prinzip werden die Rotationen zusammen gezählt und auf das Glücksrad übersetzt. Insgesamt sind es 24 Segmente zu je 15°. Ferner wird noch geprüft, ob der Zeiger auf der "Kippe" steht.
Gruß,
UEZ
Am besten das Icon in eine Bitmap umwandeln und den Button Control mit dem Style $BS_BITMAP verwenden.
Dann sollte es passen.
Gruß,
UEZ
Sollte auch mit $BS_ICON unter WinXP funzen.
Gruß,
UEZ
Ist geladen.
Gruß,
UEZ ![]()
...
wer sich über den Namen der BITMAPINFO-Struct wundert, der hat die neue Beta noch nicht mit "alten" BITMAPINFO-Funktionen verwendet. In der "neuen" Beta wurden die Namen der Datentypen ohne irgendwelche Veranlassung komplett umgeschrieben...*zu UEZ und eukalyptus rüberschiel*
Nicht alles, was in der GDIPlus verändert wurde, ist von uns initiiert worden. Warum man den Prefix "bi" zu den Struct Bezeichnungen hinzugefügt hat, weiß ich nicht.
Kann sein, dass jpm die Sachen komplett überarbeitet hat.
Gruß,
UEZ
Probiere es mal damit:
[autoit]
#include <GDIPlus.au3>
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test.png")
$hBmpScaled = _GDIPlus_BitmapScale($hImage)
_GDIPlus_ImageSaveToFile($hBmpScaled, @ScriptDir & "\Scaled.png")
_GDIPlus_BitmapDispose($hBmpScaled)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
ShellExecute(@ScriptDir & "\Scaled.png")
Func _GDIPlus_BitmapScale($hImage, $iFactor = 2) ;coded by UEZ 2013
Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0(_GDIPlus_ImageGetWidth($hImage) * $iFactor, _GDIPlus_ImageGetHeight($hImage) * $iFactor)
Local Const $hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetInterpolationMode($hGfxCtxt, 5)
_GDIPlus_GraphicsSetPixelOffsetMode($hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
_GDIPlus_GraphicsDrawImageRect($hGfxCtxt, $hImage, 0, 0, _GDIPlus_ImageGetWidth($hImage) * $iFactor, _GDIPlus_ImageGetHeight($hImage) * $iFactor)
Local Const $hBmpTexture = _GDIPlus_BitmapCreateFromScan0($iFactor, $iFactor)
Local Const $hTextureCtxt = _GDIPlus_ImageGetGraphicsContext($hBmpTexture)
_GDIPlus_GraphicsFillRect($hTextureCtxt, 0, 1, $iFactor, $iFactor)
_GDIPlus_GraphicsFillRect($hTextureCtxt, 1, 0, $iFactor, $iFactor)
Local Const $hTexture = _GDIPlus_TextureCreate($hBmpTexture)
_GDIPlus_GraphicsFillRect($hGfxCtxt, 0, 0, _GDIPlus_ImageGetWidth($hImage) * $iFactor, _GDIPlus_ImageGetHeight($hImage) * $iFactor, $hTexture)
_GDIPlus_BrushDispose($hTexture)
_GDIPlus_GraphicsDispose($hTextureCtxt)
_GDIPlus_GraphicsDispose($hGfxCtxt)
_GDIPlus_BitmapDispose($hBmpTexture)
Return $hBitmap
EndFunc
Die aktuelle Beta wird benötigt!
Das Resultat sollte das aus dem Screenshot entsprechen. Ich hoffe, dass das die Frage war.
Gruß,
UEZ
Ja, ich weiß, dass der Thread bereits 993 Tage alt ist.
Krass, wie schnell die Zeit verstrichen ist... ![]()
Hast' mit deiner Platte kein Glück gehabt... ![]()
Gruß,
UEZ
Hier eine ältere nicht WMI Version:
#include <Process.au3>
$appname = "Test.exe"
[/autoit] [autoit][/autoit] [autoit]If $CmdLine[0] = 0 Then
If _ProcessGetName(ProcessGetParent(@AutoItPID)) = "cmd.exe" Then
;Help() ;if no parameter is given from cmd.exe then call help
Else
WinSetState("[CLASS:ConsoleWindowClass]", "", @SW_HIDE)
MsgBox(16, "Wrong program call", "Program was not called from CMD!" & @CRLF & @CRLF & _ ;program called not from cmd.exe
"Please start " & $appname & " from cmd.exe!", 10)
Exit
EndIf
EndIf
Func ProcessGetParent($i_PID) ;get PID from parent process done by SmOke_N
Local $TH32CS_SNAPPROCESS = 0x00000002
Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_PID)
Local $tagPROCESSENTRY32 = _
DllStructCreate( _
"dword dwsize;" & _
"dword cntUsage;" & _
"dword th32ProcessID;" & _
"uint th32DefaultHeapID;" & _
"dword th32ModuleID;" & _
"dword cntThreads;" & _
"dword th32ParentProcessID;" & _
"long pcPriClassBase;" & _
"dword dwFlags;" & _
"char szExeFile[260]" _
)
DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))
Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)
Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_PID)
Local $a_pnext, $i_return = 0
If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then
$i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
If $i_return Then Return $i_return
Return $i_PID
EndIf
While @error = 0
$a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then
$i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
If $i_return Then ExitLoop
$i_return = $i_PID
ExitLoop
EndIf
WEnd
DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
Return $i_return
EndFunc ;==>ProcessGetParent
Kann sein, dass man sich auch von WinAPIEx.au3 bzw. in der letzten Beta bezgl. ProcessGetParent bedienen kann.
Gruß,
UEZ
Wie gesagt, ist das Ding ein Prototyp. Es soll nur als Ideengeber dienen, so dass Matricus was zum basteln hat.
Ich habe keine Lust ein komplettes Glücksrad Programm zu schreiben.
Gruß,
UEZ
Hier mal ein Prototyp.
;coded by UEZ 2013-10-24
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>
AutoItSetOption("GUIOnEventMode", 1)
_GDIPlus_Startup()
Global Const $iW = 600, $iH = 600, $iW2 = $iW / 2, $iH2 = $iH / 2
Global Const $hGUI = GUICreate("Glücksrad Prototyp", 800, 600)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH), $hPic = GUICtrlGetHandle($iPic)
Global Const $iBtn_Drehen = GUICtrlCreateButton("&Drehen", 650, 500, 110, 50)
GUICtrlSetFont(-1, 20, 400, 0, "Arial")
Global Const $iLbl_Gewinn = GUICtrlCreateLabel("Dein Gewinn:", 610, 20, 110, 30)
GUICtrlSetFont(-1, 14, 400, 0, "Arial")
Global Const $iLbl_Preis = GUICtrlCreateLabel("", 610, 50, 180, 50, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0xF0F0C0)
GUICtrlSetFont(-1, 14, 400, 0, "Arial")
GUICtrlSetOnEvent($iBtn_Drehen, "Btn_Drehen")
GUISetState()
Global Const $hGfx = _GDIPlus_GraphicsCreateFromHWND($hPic)
Global Const $hBmp = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGfx)
Global Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBmp)
_GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
_GDIPlus_GraphicsClear($hCtxt, 0xFF000000)
Global Const $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
[/autoit] [autoit][/autoit] [autoit]Global Const $hMatrix = _GDIPlus_MatrixCreate()
Global Const $hBmp_Hintergrund = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Glücksrad Scheibe.png")
Global Const $hBmp_Rotation = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Global Const $hCtxt_Rotation = _GDIPlus_ImageGetGraphicsContext($hBmp_Rotation)
Global $aPoints[4][2] = [[3, 0], [$iW2, $iH2 - 50], [$iW2, $iH2 + 50], [$iW2 + 180, $iH2]]
Global $aFelder[25] = ["Kippe", 600, 400, 200, 900, 200, 400, "Aussetzen", 450, 200, 700, 200, "Extra Dreh", _
200, 300, 400, 500, 1000, "SKL", 300, 750, 800, 350, "Bankrott", 250]
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
[/autoit] [autoit][/autoit] [autoit]Global $f, $ff, $iRunden
Drehen()
Do
Until False * Sleep(100000)
Func Btn_Drehen()
$f = Random(3, 15)
Do
If $f > 0 Then
Drehen($f)
$ff += $f
$f -= 0.1
Else
$iRunden = Floor($ff / 360)
$iSegment = Mod($iRunden + Ceiling($ff / 15), 25)
If Not $iSegment Then $iSegment += 1
If Mod($ff, 15) > 14.45 Or Mod($ff, 15) < 0.55 Then $iSegment = 0
GUICtrlSetData($iLbl_Preis, $aFelder[$iSegment])
$f = 0
ExitLoop
EndIf
Until False * Sleep(30)
EndFunc
Func _Exit()
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_GraphicsDispose($hCtxt)
_GDIPlus_GraphicsDispose($hCtxt_Rotation )
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_BitmapDispose($hBmp_Rotation)
_GDIPlus_BitmapDispose($hBmp_Hintergrund)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
Exit
EndFunc
Func Drehen($fGrad = 0)
_GDIPlus_GraphicsClear($hCtxt, 0xFF202020)
_GDIPlus_MatrixTranslate($hMatrix, $iW2, $iH2)
_GDIPlus_MatrixRotate($hMatrix, -$fGrad)
_GDIPlus_MatrixTranslate($hMatrix, -$iW2, -$iH2)
_GDIPlus_GraphicsSetTransform($hCtxt_Rotation, $hMatrix)
_GDIPlus_GraphicsDrawImageRect($hCtxt_Rotation, $hBmp_Hintergrund, 0, 0, $iW, $iH)
_GDIPlus_GraphicsDrawImageRect($hCtxt, $hBmp_Rotation, 0, 0, $iW, $iH)
_GDIPlus_GraphicsFillPolygon($hCtxt, $aPoints, $hBrush)
_GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp, 0, 0, $iW, $iH)
EndFunc
Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "handle*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aResult[0] Then Return SetError(10, $aResult[0], 0)
Return $aResult[6]
EndFunc ;==>_GDIPlus_BitmapCreateFromScan0
Im Anhang das Glücksrad Bild.
Gruß,
UEZ
Sehr schön minx. ![]()
Eigentlich hatte ich gerade mit C++ angefangen, aber ich werde einen Abstecher zu ASM machen.
Vielen Dank für das Gesamtpaket!
Gruß,
UEZ
Hat mit der Hilfe Datei gefunzt, aber arbeitet sehr gemütlich.
Vollautomatisch wäre, wie gesagt, die perfekte Lösung.
Gruß,
UEZ
Herzlichen Glückwunsch zum, ja zum wie vielten eigentlich
, und alles Gute und viel Gesundheit.
[Blockierte Grafik: http://4.bp.blogspot.com/-UG5-cllDXgY/UWxDtgQ6DuI/AAAAAAAAB74/JVWnK42Zjjc/s1600/Happy+Birthday+sms+wishes.jpg]
Gruß,
UEZ
_ScreenCapture_CaptureWnd () liefert dir ein GDI Bitmap zurück, wenn du nicht speicherst.
Anschließend das GDI Bitmap in GDI+ umwandeln (_GDIPlus_BitmapCreateFromHBITMAP) und du kannst es direkt benutzen!
Das freigeben der Ressourcen nicht vergessen!
Gruß,
UEZ