1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. UEZ

Beiträge von UEZ

  • Lautstärkeregler mit WindowSubclass

    • UEZ
    • 4. November 2015 um 22:30

    Soweit sieht es ganz gut aus, nur funktioniert nicht der Regler, wenn die Maustaste gedrückt ist und die Maus nach l/r bewegt wird (habe ich hinzugefügt).

    Scheint am Subclassing zu liegen, dass die Bitmap im Control solange nicht aktualisiert wird, bis die Maustaste losgelassen wird.

    Anstelle der If ... AND ... AND .. Then kann man auch dies verwenden:

    AutoIt
    If BitAND($iX > $aPos[0] + 2, $iX < $aPos[0] + 26, $iY > $aPos[1] + 2, $iY < $aPos[1] + 26) Then
  • Transparentes Label flackert über Hintergrundbild

    • UEZ
    • 28. Oktober 2015 um 19:46

    Zufällig ist auch parallel hier die gleiche Frage gestellt worden: https://www.autoitscript.com/forum/topic/178354-problem-with-flashing-label/?do=findComment&comment=1279824

  • Icon auf Button - schlechte Qualität

    • UEZ
    • 15. Oktober 2015 um 09:02

    Tweaky: oder zeichne doch einfach den Text auf das Bild und sende es anschließend in den Button.

    So was in er Art:

    AutoIt
    ;needs GDIPlus.au3 at least from AutoIt version 3.3.9.23
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    
    
    _GDIPlus_Startup()
    Global Const $STM_SETIMAGE = 0x0172
    Global Const $hGUI = GUICreate("GDI+ Test", 200, 100)
    GUISetBkColor(0x505050)
    Global Const $iPicBtn = GUICtrlCreatePic("", 60, 38, 80, 24)
    Global $aButtons = _GDIPlus_BitmapCreateButtonAndText("install", 80, 24)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0]))
    GUISetState()
    
    
    Global $aMouseInfo, $bShow = False, $bHide = False
    
    
    Do
    	If WinActive($hGUI) Then
    		$aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation
    		Switch $aMouseInfo[4]
    			Case $iPicBtn
    				_WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1]))
    				$bShow = True
    				$bHide = False
    			Case Else
    				_WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0]))
    				$bHide = True
    				$bShow = False
    		EndSwitch
    	EndIf
    	Switch GUIGetMsg()
    		Case $GUI_EVENT_CLOSE
    			_WinAPI_DeleteObject($aButtons[0])
    			_WinAPI_DeleteObject($aButtons[1])
    			_GDIPlus_Shutdown()
    
    
    			Exit
    		Case $iPicBtn
    			MsgBox(0, "Information", "Button pressed")
    	EndSwitch
    Until False
    
    
    
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GDIPlus_BitmapCreateButtonAndText
    ; Description ...: Draws via GDI+ a Windows 8 style button with text
    ; Syntax ........: _GDIPlus_BitmapCreateButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[,
    ;                  $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]])
    ; Parameters ....: $sString             - A string value.
    ;                  $iWidth              - An integer value.
    ;                  $iHeight             - An integer value.
    ;                  $iBgColor            - [optional] An integer value. Default is 0xFF1BA0E1.
    ;                  $iFontSize           - [optional] An integer value. Default is 16.
    ;                  $sFont               - [optional] A string value. Default is "Times New Roman".
    ;                  $iHoverColor         - [optional] An integer value. Default is 0xFFC9388C.
    ;                  $iFrameSize          - [optional] An integer value. Default is 2.
    ;                  $iFontFrameColor     - [optional] An integer value. Default is 0x408AD5EA.
    ;                  $iFontColor          - [optional] An integer value. Default is 0xFFFFFFFF.
    ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button
    ; Author ........: UEZ
    ; Version .......: 0.85 build 2014-05-08
    ; Modified ......:
    ; Remarks .......: Dispose returned GDI bitmap handles when done
    ; Example .......: Yes
    ; ===============================================================================================================================
    Func _GDIPlus_BitmapCreateButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $sFont = "Times New Roman", $iHoverColor = 0xFFFFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF)
    	;some checks
    	If $sString = "" Then Return SetError(1, 0, 0)
    	If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0)
    	If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0)
    
    
        ;create font objects
    	Local Const $hFormat = _GDIPlus_StringFormatCreate()
        Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
        Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight)
    	_GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis
    	_GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis
    
    
    	;create bitmap and graphics context handles
    	Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)]
    	Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])]
    
    
    	;set drawing quality
    	_GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    	_GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
    
    
    	;define brush and pen objects
    	Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor)
    	Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, 1), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize)
    
    
    	;create path object
    	Local Const $hPath = _GDIPlus_PathCreate()
    
    
    	;create cloned path object for string measurement
    	Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath)
    	_GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat)
    ;~ 	Local Const $aInfo = _GDIPlus_PathGetWorldBounds($hPath_Dummy)
    ;~ 	$tLayout.Y = ($iHeight - $aInfo[3]) / 2 - Ceiling($aInfo[1]) ;center string on Y axis
    
    
    	;add string to path
    	_GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat)
    
    
    	;clear bitmap and draw string
    	_GDIPlus_GraphicsClear($aGfxCtxt[0], $iBgColor)
        _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor)
        _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor)
    
    
    	;draw rectangle on cloned bitmap for hover effect
    	_GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight)
    	_GDIPlus_GraphicsDrawRect($aGfxCtxt[1], $iFrameSize / 2, $iFrameSize / 2, $iWidth - $iFrameSize, $iHeight - $iFrameSize, $hPenHoverColor)
    
    
    	;dispose object resources
    	_GDIPlus_FontFamilyDispose($hFamily)
    	_GDIPlus_StringFormatDispose($hFormat)
        _GDIPlus_PathDispose($hPath)
        _GDIPlus_PathDispose($hPath_Dummy)
    	_GDIPlus_GraphicsDispose($aGfxCtxt[0])
    	_GDIPlus_GraphicsDispose($aGfxCtxt[1])
    	_GDIPlus_BrushDispose($hBrushFontColor)
    	_GDIPlus_PenDispose($hPenFontFrameColor)
    	_GDIPlus_PenDispose($hPenHoverColor)
    
    
    	;create GDI bitmap for later usage
    	Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])]
    
    
    	;dispose GDI+ bitmaps
    	_GDIPlus_BitmapDispose($aBitmaps[0])
    	_GDIPlus_BitmapDispose($aBitmaps[1])
    	Return $aHBitmaps
    EndFunc
    Alles anzeigen
  • Icon auf Button - schlechte Qualität

    • UEZ
    • 12. Oktober 2015 um 09:40

    Probiere es mal hiermit:

    C
    #Region    ;************ Includes ************
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiButton.au3>
    #include <GDIPlus.au3>
    #include <WinAPIShellEx.au3>
    
    
    #EndRegion    ;************ Includes ************
    
    
    Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled
    
    
    $sIcon = @ScriptDir & "\icon.ico"
    _GDIPlus_Startup()
    $hGui = GUICreate("Test", 200, 400)
    GUICtrlCreateIcon($sIcon, 0, 10, 10, 128, 128)
    $hIcon = _WinAPI_ShellExtractIcon($sIcon, 0, 128, 128)
    $hBmp_Icon = _GDIPlus_BitmapCreateFromHICON32($hIcon)
    $hHBmp_Icon = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp_Icon)
    $idButton = GUICtrlCreateButton("", 10, 200, 150, 150, $BS_BITMAP)
    _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($idButton), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_Icon))
    GUISetOnEvent($GUI_EVENT_CLOSE, "_beenden")
    GUISetState()
    
    
    While 1
    	Sleep(10)
    WEnd
    
    
    Func _beenden()
    	_WinAPI_DestroyIcon($hIcon)
    	_GDIPlus_BitmapDispose($hBmp_Icon)
    	_WinAPI_DeleteObject($hHBmp_Icon)
    	_GDIPlus_Shutdown()
    	GUIDelete()
    	Exit
    EndFunc   ;==>_beenden
    Alles anzeigen
  • TreeView Erstellung

    • UEZ
    • 19. September 2015 um 21:12

    Hintergrund ist, dass eine Webandwendung eine 2D Tabelle mit vielen Informationen erstellt, die nach Excel exportiert werden kann.

    Diese Exceltabelle will ich benutzen, um simple Rack Layouts zu erstellen. Dabei werden nur bestimmte Spalten extrahiert, um den Baum zu erstellen, quasi die Koordinate, wo das Rack steht.

    Es soll nun die Koordinate per Baum selektiert werden und auf der rechten Seite wird dann "on the fly" das Rack Layout dargestellt.

    Danke für die Links.

  • TreeView Erstellung

    • UEZ
    • 18. September 2015 um 23:02

    Kanashius: sieht schon mal sehr gut aus!

    Vielen Dank!

    :thumbup:

    Mit TVs habe ich kaum gearbeitet. :whistling:

  • TreeView Erstellung

    • UEZ
    • 18. September 2015 um 20:31

    Hi,

    mit TreeViews habe ich kaum Erfahrung und wollte ein sortiertes 2D Array in ein Treeview abbilden.

    Das Array sieht so aus und ist auch als Datei verfügbar (Path.txt:(
    Array.png

    Spalte 0 bildet die Wurzel ab und hier gibt es nur "EMEA". Spalte 9 bildet das letzte Element ab. Spalte 7 ist zu ignorieren und dient nur für die Sortierung des Arrays.
    Das Array wird aus einer Excel Tabelle erstellt.

    Hier ein Beispiel Code:

    AutoIt
    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiTreeView.au3>
    #include <WindowsConstants.au3>
    
    
    Example()
    
    
    Func Example()
        Local $hItem, $iTree, $x, $y, $iParent
        Local $iStyle = BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
    
    
        GUICreate("TreeView Add First", 600, 800)
    
    
        $iTree = GUICtrlCreateTreeView(2, 2, 596, 768, $iStyle, $WS_EX_CLIENTEDGE)
        GUISetState(@SW_SHOW)
    	Local $aData = StringSplit2D(FileRead(@ScriptDir & "\Path.txt"))
        _GUICtrlTreeView_BeginUpdate($iTree)
    	Local $aTmp[UBound($aData, 2)]
    	For $y = 1 To UBound($aData) - 1
    		For $x = 0 To UBound($aData, 2) - 1
    			If $x = 7 Then ContinueLoop
    
    
    		Next
    	Next
    	_GUICtrlTreeView_EndUpdate($iTree)
    
    
        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
    EndFunc   ;==>Example
    
    
    ; #FUNCTION# ========================================================================================================================================
    ; Name .................:	StringSplit2D()
    ; Description ..........:	Splits  a string into columns instead of rows as it is done by SplitString(), like a csv file to a 2d array ;-)
    ; Syntax ...............:	StringSplit2D($sString[, $sDelimiter = ";"[, $bStripWS = True[, $sQuotationMark = '"'[, $sDummy = "¦"[, $iWidthLen = 256]]]]])
    ; Parameters ...........:	$sString             - A string value.
    ;                  			$sDelimiter          - [optional] A string value. Default is ";".
    ;                  			$bStripWS            - [optional] A binary value. Default is True.
    ;                  			$sQuotationMark      - [optional] A string value. Default is '"'.
    ;                  			$sDummy              - [optional] A string value. Default is "¦".
    ;                  			$iWidthLen           - [optional] An integer value. Default is 256.
    ; Return values .......:   	Success - 2d array
    ; 							Error 1 - $sStringis not set
    ; 							Error 2 - $delimter is not set
    ; 							Error 3 - error splitting string
    ; 							Error 4 - array width exceeded
    ;
    ; Version .............:	v0.97 build 2015-03-03 beta
    ; Author ..............:	UEZ
    ; Modified ............:
    ; Comment .............:	former StringSplitW
    ; Remarks .............:	RegEx take from http://stackoverflow.com/questions/4476812/regular-expressions-how-to-replace-a-character-within-quotes
    ; Related .............:	StringSplit, StringReplace, StringRegExpReplace, StringLen, StringStripCR
    ; ===================================================================================================================================================
    Func StringSplit2D($sString, $sDelimiter = ";", $bStripWS = False, $sQuotationMark = '"', $sDummy = "¦", $iWidthLen = 256)
        If $sString = "" Then Return SetError(1, 0, 0)
        If $sDelimiter = "" Then Return SetError(2, 0, 0)
        Local $aSplit =  StringSplit(StringStripCR($sString), @LF)
    	If @error Then Return SetError(3, 0, 0)
        Local $chk, $iWidth, $i, $j, $k, $iLen, $iMax = 1, $iMaxWidth, $iSum = 0
        Local $aPos[1], $l = 0
        Local $aVertical[$aSplit[0]][$iWidthLen], $iDelimiterLen = StringLen($sDelimiter) - 1, $sLine
        For $k = 1 To $aSplit[0]
            $iLen = StringLen($aSplit[$k])
            If $iLen > 1 Then
    			Switch $bStripWS
    				Case True
    					$sLine = StringRegExpReplace($aSplit[$k], '(?m)\' & $sDelimiter & '(?=[^' & $sQuotationMark & ']*' & $sQuotationMark & '(?:[^' & $sQuotationMark & '\r\n]*' & $sQuotationMark & '[^' & $sQuotationMark & ']*' & $sQuotationMark & ')*[^' & $sQuotationMark & '\r\n]*$)', $sDummy)
    				Case Else ;      ,(?=[^"]*"(?:[^"\r\n]*"[^"]*")*[^"\r\n]*$)
    					$sLine = StringRegExpReplace(StringStripWS($aSplit[$k], 4), '(?m)\' & $sDelimiter & '(?=[^' & $sQuotationMark & ']*' & $sQuotationMark & '(?:[^' & $sQuotationMark & '\r\n]*' & $sQuotationMark & '[^' & $sQuotationMark & ']*' & $sQuotationMark & ')*[^' & $sQuotationMark & '\r\n]*$)', $sDummy)
    			EndSwitch
                $chk = StringReplace($sLine, $sDelimiter, $sDelimiter)
                $iWidth = @extended
    			$iSum += $iWidth
                If $iWidth > $iWidthLen Then Return SetError(4, 0, 0)
                If $iWidth >= $iMax Then $iMax = $iWidth + 1
                Switch $iWidth
                    Case 0
                        $aVertical[$l][0] = $sLine
                    Case Else
                        Dim $aPos[$iWidth * 2 + 2]
                        $j = 1
                        $aPos[0] = 1
                        For $i = 0 To $iWidth - 1
                            $aPos[$j] = StringInStr($sLine, $sDelimiter, 0, $i + 1) - 1
                            $aPos[$j + 1] = $aPos[$j] + 2 + $iDelimiterLen
                            $j += 2
                        Next
                        $aPos[UBound($aPos) - 1] = StringLen($sLine)
                        $j = 0
                        For $i = 0 To UBound($aPos) - 1 Step 2
                            $aVertical[$l][$j] = StringReplace(StringMid(StringReplace($sLine, $sDummy, $sDelimiter), $aPos[$i], $aPos[$i + 1] - $aPos[$i] + 1), '""', "")
    ;~ 						ConsoleWrite($aVertical[$l][$j] & @CRLF)
                            $j += 1
                        Next
                    EndSwitch
                    $l += 1
            EndIf
        Next
        ReDim $aVertical[$l][$iMax]
        Return $aVertical
    EndFunc
    Alles anzeigen

    Hat jemand eine Idee, wie ich effizient die Tabelle als Treeview abbilden kann?

    So etwa soll es aussehen:

    +EMEA
    _____+DE
    ________+Frankfurt
    _________________+FFM.A
    _______________________+00
    __________________________+Carrier-4-D
    _____________________________________+A-Carrier-4D
    _________________________________________________+AC
    ____________________________________________________+12 (letzes Element)
    ...
    _________________+FFM.B
    _______________________+01
    ...

    Danke!

    Dateien

    Path.txt 142,66 kB – 512 Downloads
  • exe icon als Bild auf GUI

    • UEZ
    • 31. August 2015 um 22:38

    Mit

    AutoIt
    #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\MyAutoIt3_Green.ico")
    #AutoIt3Wrapper_UseX64=y


    sollte es auch funzen. Getestet auf Win 8.1 x64.

  • Dateien auf GUI - Möglichkeiten

    • UEZ
    • 30. August 2015 um 00:33

    Ist im Prinzip das Gleiche über 2 verschiedene Wege - Callback bzw. Windows Message.

    Adhog würde ich sagen, dass beide Techniken gleich gut sind. Ich persönlich arbeite mehr mit WM.

  • exe icon als Bild auf GUI

    • UEZ
    • 29. August 2015 um 23:55

    Probiere es mal so:

    AutoIt
    #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\MyAutoIt3_Green.ico")
    #AutoIt3Wrapper_UseX64=y
    
    
    #include <GuiConstantsEx.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPIGdi.au3>
    
    
    Global Const $STM_SETIMAGE = 0x0172
    Global Const $hIcon = _WinAPI_ShellExtractIcon(@AutoItExe, 0, 48, 48)
    Global Const $hBmp = _WinAPI_Create32BitHBITMAP($hIcon, False, True)
    
    
    Global Const $hGUI = GUICreate("Test", 300, 400)
    Global Const $iPic = GUICtrlCreatePic("", 100, 100, 48, 48)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp))
    GUISetState()
    
    
    Do
    	Switch GUIGetMsg()
    		Case $GUI_EVENT_CLOSE
    			_WinAPI_DeleteObject($hBmp)
    			GUIDelete()
    			Exit
    	EndSwitch
    Until False
    Alles anzeigen
  • _WinAPI_EnumFiles im lokalen Netzwerk

    • UEZ
    • 28. August 2015 um 20:21

    Der Fehler liegt in der Funktion unter

    AutoIt
    $aRet = DllCall('ntdll.dll', 'uint', 'ZwQueryDirectoryFile', 'handle', $hDir, 'ptr', 0, 'ptr', 0, 'ptr', 0, _
    				'struct*', $tIOSB, 'struct*', $pBuffer, 'ulong', 8388608, 'uint', 1, 'boolean', 0, 'ptr', 0, 'boolean', 1)

    Bist du sicher, dass diese Funktion UNC Pfade unterstützt?

  • Array variable has incorrect number...

    • UEZ
    • 28. August 2015 um 19:21

    Scheint so, dass $IniRead kein Array ist bzw. die Länge des Arrays $Split ungleich der Länge von $IniRead ist.

    Am besten ein paar reale Testdaten hochladen.

  • GUI resizen und Button neu erstellen

    • UEZ
    • 16. August 2015 um 18:36
    Zitat von Oscar

    Direkt beim maximieren noch nicht, aber wenn man dann auf "Button neu erstellen 1" klickt, sind die Button verschwunden (Win 7, 64 Bit).

    Stimmt, hängt daran, dass 400 - genommen wird.

    AutoIt
    $aidButton[1][$i] = GUICtrlCreateButton(Chr(65 + $i), 400 - $aPosW[2] + $aPosC[0] + 41 + $i * 50, 25, 45, 25)

    Beim Maximieren stimmt dann natürlich die 400 (Fensterbreite) nicht mehr. Dies müsste angepasst werden.

  • GUI resizen und Button neu erstellen

    • UEZ
    • 16. August 2015 um 14:12
    Zitat von Oscar

    Beim maximieren des Fensters sind die Button jedoch verschwunden.

    Hmm komisch, bei mir nicht. Ich benutze Win8.1.

  • GUI resizen und Button neu erstellen

    • UEZ
    • 16. August 2015 um 12:36

    Ups, war schon sehr spät. Ich habe nun den vollen Code gepostet.

    Sorry.

  • GUI resizen und Button neu erstellen

    • UEZ
    • 16. August 2015 um 02:45

    Hier noch ein Workaround, welches nicht perfekt ist:

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <Math.au3>
    #include <WindowsConstants.au3>
    
    
    Opt('GUIOnEventMode', 1)
    
    
    Global $aidButton[2][3]
    
    
    Global $hGui = GUICreate('Test', 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
    GUISetOnEvent($GUI_EVENT_CLOSE, '_GuiClose')
    Global $iSE = GUICtrlCreateLabel('', 199, 0, 2, 600, Default, $WS_EX_STATICEDGE)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH)
    _CreateButton1()
    
    
    GUICtrlCreateButton('Button neu erstellen 1', 10, 220, 160, 35)
    GUICtrlSetOnEvent(-1, '_CreateButton1')
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE)
    
    
    GUICtrlCreateButton('Button neu erstellen 2', 210, 220, 160, 35)
    GUICtrlSetOnEvent(-1, '_CreateButton2')
    GUICtrlSetResizing(-1, $GUI_DOCKHCENTER + $GUI_DOCKSIZE)
    
    
    GUISetState(@SW_SHOW, $hGui)
    
    
    Global $aWinSize = WinGetPos($hGui)
    GUIRegisterMsg($WM_GETMINMAXINFO, '_WM_GETMINMAXINFO')
    
    
    WinWaitClose($hGui)
    Exit
    
    
    Func _CreateButton1()
    	For $i = 0 To UBound($aidButton, 2) - 1
    		For $j = 0 To 1
    			GUICtrlDelete($aidButton[$j][$i])
    		Next
    	Next
    	Local Static $iDir = 1
    	GUISetState(@SW_LOCK, $hGui)
    	Local $aPosC = ControlGetPos($hGui, "", $iSE), $aPosW = WinGetPos($hGui)
    	For $i = 0 To UBound($aidButton, 2) - 1
    		$aidButton[0][$i] = GUICtrlCreateButton(Chr(65 + $i), 20 + $i * 50, 25, 45, 25)
    		GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
    		$aidButton[1][$i] = GUICtrlCreateButton(Chr(65 + $i), 400 - $aPosW[2] + $aPosC[0] + 41 + $i * 50, 25, 45, 25)
    		GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKTOP, $GUI_DOCKSIZE))
    	Next
    	WinMove($hGui, "", $aPosW[0], $aPosW[1], $aPosW[2] + $iDir, $aPosW[3] + $iDir)
    	GUISetState(@SW_UNLOCK, $hGui)
    	$iDir *= -1
    EndFunc   ;==>_CreateButton1
    
    
    Func _CreateButton2()
    	Local $aOldSize = WinGetPos($hGui)
    	WinMove($hGui, '', Default, Default, $aWinSize[2], $aWinSize[3])
    	For $i = 0 To UBound($aidButton, 2) - 1
    		For $j = 0 To 1
    			GUICtrlDelete($aidButton[$j][$i])
    		Next
    	Next
    	For $i = 0 To UBound($aidButton, 2) - 1
    		$aidButton[0][$i] = GUICtrlCreateButton(Chr(65 + $i), 20 + $i * 50, 25, 45, 25)
    		GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
    		$aidButton[1][$i] = GUICtrlCreateButton(Chr(65 + $i), 220 + $i * 50, 25, 45, 25)
    		GUICtrlSetResizing(-1, $GUI_DOCKHCENTER + $GUI_DOCKTOP + $GUI_DOCKSIZE)
    	Next
    	WinMove($hGui, '', Default, Default, $aOldSize[2], $aOldSize[3])
    EndFunc   ;==>_CreateButton2
    
    
    Func _GuiClose()
    	GUIDelete($hGui)
    EndFunc   ;==>_GuiClose
    
    
    Func _WM_GETMINMAXINFO($hWnd, $iMsg, $iwParam, $ilParam)
    	#forceref $iMsg, $iwParam
    	Local $minmaxinfo
    	If $hWnd = $hGui Then
    		$minmaxinfo = DllStructCreate('int;int;int;int;int;int;int;int;int;int', $ilParam)
    		DllStructSetData($minmaxinfo, 7, $aWinSize[2])
    		DllStructSetData($minmaxinfo, 8, $aWinSize[3])
    	EndIf
    	Return $GUI_RUNDEFMSG
    EndFunc   ;==>_WM_GETMINMAXINFO
    Alles anzeigen
  • Kicktipp Bundesliga 2015/2016

    • UEZ
    • 14. August 2015 um 18:28

    LETZER AUFRUF! :D

  • Kicktipp Bundesliga 2015/2016

    • UEZ
    • 12. August 2015 um 19:21

    Yaerox: bitte tippen!

    @All: noch ist Zeit zum Mitmachen! :party:

  • Jpg schrumpfen exif löschen.

    • UEZ
    • 5. August 2015 um 15:47

    Zu Exif: https://www.autoitscript.com/forum/topic/82…tting-meta-data / https://msdn.microsoft.com/en-us/library/…magedescription

  • Tetris - kleiner Zeitvertreib für Zwischendurch

    • UEZ
    • 1. August 2015 um 13:42

    Flimmert, weil du direkt in die Grafik zeichnest, ansonsten läuft's ganz gut. Vielleicht wäre eine Punktesystem nicht schlecht.

    AutoIt
    #include <GdiPlus.au3>
    #include <Misc.au3>
    
    
    Opt("GUIOnEventMode", 1)
    $hGUI = GUICreate("Tetris", 288, 448, 192, 124)
    GUISetOnEvent(-3, "_Exit")
    
    
    GUISetState(@SW_SHOW)
    
    
    Local $hUser32 = DllOpen("user32.dll")
    _GDIPlus_Startup()
    
    
    $hCanvas = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromScan0(288, 448)
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hGraphics)
    
    
    Global $aField[9][14], $aBlock[4][2]
    
    
    Local $aPalette[7] = [_GDIPlus_BrushCreateSolid(0xFF00FF00), _GDIPlus_BrushCreateSolid(0xFFFF0000), _GDIPlus_BrushCreateSolid(0xFFFF4500), _
    					  _GDIPlus_BrushCreateSolid(0xFF0000FF), _GDIPlus_BrushCreateSolid(0xFFFFFF00), _GDIPlus_BrushCreateSolid(0xFF8888FF), _GDIPlus_BrushCreateSolid(0xFFFF00FF)]
    
    
    $aBlock = _GenerateRandomBlock()
    $iCurrColor = @extended
    $iTurn = 0
    
    
    $iScore = 0
    
    
    Local $bLeft, $bRight, $bTurn, $bDown, $bDrop
    
    
    AdlibRegister("_PushTheBlock", 850)
    
    
    While Sleep(30)
    	_GDIPlus_GraphicsClear($hGraphics)
    
    
    	For $x = 0 To 8
    		For $y = 0 To 13
    			If $aField[$x][$y] Then _GDIPlus_GraphicsFillRect($hGraphics, $x * 32, $y * 32, 32, 32, $aPalette[$aField[$x][$y] - 1])
    		Next
    	Next
    
    
    	For $i = 0 To 3
    		_GDIPlus_GraphicsFillRect($hGraphics, $aBlock[$i][0] * 32, $aBlock[$i][1] * 32, 32, 32, $aPalette[$iCurrColor - 1])
    	Next
    
    
    	If _IsPressed("25", $hUser32) and Not $bLeft and Not _Collides($aBlock, -1, 0) Then
    		For $i = 0 To 3
    			$aBlock[$i][0] -= 1
    		Next
    
    
    		$bLeft = True
    	ElseIf _IsPressed("27", $hUser32) and Not $bRight and Not _Collides($aBlock, 1, 0) Then
    		For $i = 0 To 3
    			$aBlock[$i][0] += 1
    		Next
    
    
    		$bRight = True
    	ElseIf _IsPressed("26", $hUser32) and Not $bTurn and $iCurrColor <> 5 Then
    		Switch $iCurrColor - 1
    			Case 0 ;S-Block
    				Switch $iTurn
    					Case 0
    						Local $tmpBlock[4][2] = [[$aBlock[0][0], $aBlock[0][1] - 2], [$aBlock[1][0] - 1, $aBlock[1][1] - 1], [$aBlock[2][0], $aBlock[2][1]], [$aBlock[3][0] - 1, $aBlock[3][1] + 1]]
    
    
    					Case 1
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 2, $aBlock[0][1] + 1], [$aBlock[1][0] + 1, $aBlock[1][1]], [$aBlock[2][0], $aBlock[2][1] + 1], [$aBlock[3][0] - 1, $aBlock[3][1]]]
    
    
    					Case 2
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 1, $aBlock[0][1] + 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] - 1, $aBlock[2][1] - 1], [$aBlock[3][0], $aBlock[3][1] - 2]]
    
    
    					Case 3
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 1, $aBlock[0][1]], [$aBlock[1][0], $aBlock[1][1] + 1], [$aBlock[2][0] + 1, $aBlock[2][1]], [$aBlock[3][0] + 2, $aBlock[3][1] + 1]]
    				EndSwitch
    
    
    			Case 1 ;RS-Block
    				Switch $iTurn
    					Case 0
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 1, $aBlock[0][1] - 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] - 1, $aBlock[2][1] - 1], [$aBlock[3][0] - 2, $aBlock[3][1]]]
    
    
    					Case 1
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 1, $aBlock[0][1] + 2], [$aBlock[1][0], $aBlock[1][1] + 1], [$aBlock[2][0] + 1, $aBlock[2][1]], [$aBlock[3][0], $aBlock[3][1] - 1]]
    
    
    					Case 2
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 2, $aBlock[0][1]], [$aBlock[1][0] - 1, $aBlock[1][1] - 1], [$aBlock[2][0], $aBlock[2][1]], [$aBlock[3][0] + 1, $aBlock[3][1] - 1]]
    
    
    					Case 3
    						Local $tmpBlock[4][2] = [[$aBlock[0][0], $aBlock[0][1] - 1], [$aBlock[1][0] + 1, $aBlock[1][1]], [$aBlock[2][0], $aBlock[2][1] + 1], [$aBlock[3][0] + 1, $aBlock[3][1] + 2]]
    				EndSwitch
    
    
    			Case 2 ;L-Block
    				Switch $iTurn
    					Case 0
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 2, $aBlock[0][1] + 1], [$aBlock[1][0] + 1, $aBlock[1][1]], [$aBlock[2][0], $aBlock[2][1] - 1], [$aBlock[3][0] - 1, $aBlock[3][1]]]
    
    
    					Case 1
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 1, $aBlock[0][1] + 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] + 1, $aBlock[2][1] - 1], [$aBlock[3][0], $aBlock[3][1] - 2]]
    
    
    					Case 2
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 1, $aBlock[0][1]], [$aBlock[1][0], $aBlock[1][1] + 1], [$aBlock[2][0] + 1, $aBlock[2][1] + 2], [$aBlock[3][0] + 2, $aBlock[3][1] + 1]]
    
    
    					Case 3
    						Local $tmpBlock[4][2] = [[$aBlock[0][0], $aBlock[0][1] - 2], [$aBlock[1][0] - 1, $aBlock[1][1] - 1], [$aBlock[2][0] - 2, $aBlock[2][1]], [$aBlock[3][0] - 1, $aBlock[3][1] + 1]]
    				EndSwitch
    
    
    			Case 3 ;RL-Block
    				Switch $iTurn
    					Case 0
    						Local $tmpBlock[4][2] = [[$aBlock[0][0], $aBlock[0][1] - 1], [$aBlock[1][0] - 1, $aBlock[1][1]], [$aBlock[2][0], $aBlock[2][1] + 1], [$aBlock[3][0] + 1, $aBlock[3][1] + 2]]
    
    
    					Case 1
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 1, $aBlock[0][1] - 1], [$aBlock[1][0], $aBlock[1][1] - 2], [$aBlock[2][0] - 1, $aBlock[2][1] - 1], [$aBlock[3][0] - 2, $aBlock[3][1]]]
    
    
    					Case 2
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 1, $aBlock[0][1] + 2], [$aBlock[1][0] + 2, $aBlock[1][1] + 1], [$aBlock[2][0] + 1, $aBlock[2][1]], [$aBlock[3][0], $aBlock[3][1] - 1]]
    
    
    					Case 3
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 2, $aBlock[0][1]], [$aBlock[1][0] - 1, $aBlock[1][1] + 1], [$aBlock[2][0], $aBlock[2][1]], [$aBlock[3][0] + 1, $aBlock[3][1] - 1]]
    				EndSwitch
    
    
    			Case 5 ;I-Block
    				Switch $iTurn
    					Case 0
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 1, $aBlock[0][1] - 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] - 1, $aBlock[2][1] + 1], [$aBlock[3][0] - 2, $aBlock[3][1] + 2]]
    
    
    					Case 1
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 2, $aBlock[0][1] + 1], [$aBlock[1][0] + 1, $aBlock[1][1]], [$aBlock[2][0], $aBlock[2][1] - 1], [$aBlock[3][0] - 1, $aBlock[3][1] - 2]]
    
    
    					Case 2
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 2, $aBlock[0][1] + 2], [$aBlock[1][0] - 1, $aBlock[1][1] + 1], [$aBlock[2][0], $aBlock[2][1]], [$aBlock[3][0] + 1, $aBlock[3][1] - 1]]
    
    
    					Case 3
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 1, $aBlock[0][1] - 2], [$aBlock[1][0], $aBlock[1][1] - 1], [$aBlock[2][0] + 1, $aBlock[2][1]], [$aBlock[3][0] + 2, $aBlock[3][1] + 1]]
    				EndSwitch
    
    
    			Case 6 ;T-Block
    				Switch $iTurn
    					Case 0
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 1, $aBlock[0][1] - 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] - 1, $aBlock[2][1] - 1], [$aBlock[3][0] - 1, $aBlock[3][1] + 1]]
    
    
    					Case 1
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] + 1, $aBlock[0][1] + 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] + 1, $aBlock[2][1] - 1], [$aBlock[3][0] - 1, $aBlock[3][1] - 1]]
    
    
    					Case 2
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 1, $aBlock[0][1] + 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] + 1, $aBlock[2][1] + 1], [$aBlock[3][0] + 1, $aBlock[3][1] -1]]
    
    
    					Case 3
    						Local $tmpBlock[4][2] = [[$aBlock[0][0] - 1, $aBlock[0][1] - 1], [$aBlock[1][0], $aBlock[1][1]], [$aBlock[2][0] - 1, $aBlock[2][1] + 1], [$aBlock[3][0] + 1, $aBlock[3][1] + 1]]
    				EndSwitch
    		EndSwitch
    
    
    		If Not _Collides($tmpBlock, 0, 0) Then
    			$aBlock = $tmpBlock
    			$iTurn = Mod($iTurn + 1, 4)
    		EndIf
    
    
    		$bTurn = True
    	ElseIf _IsPressed("28", $hUser32) and Not $bDown and Not _Collides($aBlock, 0, 1) Then
    		_PushTheBlock()
    
    
    		$bDown = True
    	ElseIf _IsPressed("20", $hUser32) and Not $bDrop Then
    		For $i = 0 To 14
    			If _Collides($aBlock, 0, $i) Then ExitLoop
    		Next
    
    
    		For $x = 0 To $i
    			_PushTheBlock()
    		Next
    
    
    		$bDrop = True
    	EndIf
    
    
    
    
    	If Not _IsPressed("25", $hUser32) Then $bLeft = False
    	If Not _IsPressed("26", $hUser32) Then $bTurn = False
    	If Not _IsPressed("27", $hUser32) Then $bRight = False
    	If Not _IsPressed("28", $hUser32) Then $bDown = False
    	If Not _IsPressed("20", $hUser32) Then $bDrop = False
    	_GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap, 0, 0, 288, 448)
    WEnd
    
    
    Func _Collides($aBlock, $iIncX, $iIncY)
    	For $i = 0 To 3
    		If $aBlock[$i][0] + $iIncX < 0 or $aBlock[$i][0] + $iIncX > 8 or $aBlock[$i][1] + $iIncY > 13 Then Return 1
    	Next
    
    
    	For $i = 0 To 3
    		If $aField[$aBlock[$i][0] + $iIncX][$aBlock[$i][1] + $iIncY] Then Return 1
    	Next
    EndFunc
    
    
    Func _PushTheBlock()
    	If Not _Collides($aBlock, 0, 1) Then
    		For $i = 0 To 3
    			$aBlock[$i][1] += 1
    		Next
    	Else
    		For $i = 0 To 3
    			$aField[$aBlock[$i][0]][$aBlock[$i][1]] = $iCurrColor
    		Next
    
    
    		$aBlock = _GenerateRandomBlock()
    		$iCurrColor = @extended
    		$iTurn = 0
    
    
    		If _Collides($aBlock, 0, 0) Then
    			MsgBox(48, "Game Over", "Looks like you messed up!" & @CRLF & "Score: " & $iScore)
    			Exit
    		EndIf
    	EndIf
    
    
    	$m = 1
    
    
    	Do
    		Dim $aNewField[9][0] ;Dim nutzen damit alle vorherigen Einträge gelöscht werden.
    
    
    		For $iRow = 0 To 13
    			$m = 1
    
    
    			For $iColumn = 0 To 8
    				$m *= $aField[$iColumn][$iRow]
    			Next
    
    
    			If $m Then
    				For $iRow_ = 0 To 13
    					If $iRow_ = $iRow Then ContinueLoop
    
    
    					ReDim $aNewField[9][UBound($aNewField, 2) + 1]
    
    
    					For $i = 0 To 8
    						$aNewField[$i][UBound($aNewField, 2) - 1] = $aField[$i][$iRow_]
    					Next
    				Next
    
    
    				ExitLoop
    			EndIf
    		Next
    
    
    		If UBound($aNewField, 2) Then
    			Dim $aField[9][14]
    
    
    			For $i = 14 - UBound($aNewField, 2) To 13
    				For $i_ = 0 To 8
    					$aField[$i_][$i] = $aNewField[$i_][$i - 14 + UBound($aNewField, 2)]
    				Next
    			Next
    
    
    			$iScore += 1
    			WinSetTitle($hGUI, "", "Tetris Score: " & $iScore)
    		EndIf
    	Until Not UBound($aNewField, 2)
    EndFunc
    
    
    Func _Exit()
    	_GDIPlus_GraphicsDispose($hCanvas)
    	_GDIPlus_GraphicsDispose($hGraphics)
    	_GDIPlus_BitmapDispose($hBitmap)
    	_GDIPlus_Shutdown()
    	Exit
    EndFunc
    
    
    Func _GenerateRandomBlock()
    	Local $iRandom = Random(1, 7, 1)
    
    
    	Switch $iRandom
    		Case 1 ;S-Block
    			Local $aReturn[4][2] = [[3, 3], [4, 3], [4, 2], [5, 2]]
    
    
    		Case 2 ;RS-Block
    			Local $aReturn[4][2] = [[3, 2], [4, 2], [4, 3], [5, 3]]
    
    
    		Case 3 ;L-Block
    			Local $aReturn[4][2] = [[3, 1], [3, 2], [3, 3], [4, 3]]
    
    
    		Case 4 ;RL-Block
    			Local $aReturn[4][2] = [[3, 3], [4, 3], [4, 2], [4, 1]]
    
    
    		Case 5 ;O-Block
    			Local $aReturn[4][2] = [[3, 2], [3, 3], [4, 2], [4, 3]]
    
    
    		Case 6 ;I-Block
    			Local $aReturn[4][2] = [[3, 2], [4, 2], [5, 2], [6, 2]]
    
    
    		Case 7 ;T-Block
    			Local $aReturn[4][2] = [[3, 2], [4, 2], [4, 3], [5, 2]]
    
    
    	EndSwitch
    
    
    	SetExtended($iRandom)
    	Return $aReturn
    EndFunc
    Alles anzeigen

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™