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

  • Hilfe bei Arrays gesucht

    • UEZ
    • 11. Dezember 2009 um 21:33

    Sehr wahrscheinlich ist $mainpos kein Array. Prüfe es doch mal mit IsArray()!

    Gruß,
    UEZ

  • GDI+ Graphic über einen Hintergrund bewegen

    • UEZ
    • 11. Dezember 2009 um 21:15

    Meinst du sowas?

    Spoiler anzeigen
    [autoit]


    ;Coded by UEZ 2009.12.11
    #include <GDIplus.au3>
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $load_background = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Background.png")
    Global $load_foreground = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Smiley.png")
    Global $width = _GDIPlus_ImageGetWidth($load_background)
    Global $height = _GDIPlus_ImageGetHeight($load_background)
    Global $dx = _GDIPlus_ImageGetWidth($load_foreground)
    Global $dy = _GDIPlus_ImageGetHeight($load_foreground)
    Global Const $pi_div_180 = 4 * ATan(1) / 180
    Global $radius = 60
    Global $i, $x = $width / 2 - $dx / 2, $y = $height / 2 - $dy / 2

    [/autoit] [autoit][/autoit] [autoit]

    Global $hwnd = GUICreate("GDI+: Example by UEZ", $width, $height, -1, -1, Default)
    GUISetOnEvent(-3, "_Exit")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
    Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
    Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    ;~ _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)

    [/autoit] [autoit][/autoit] [autoit]

    $i = 0
    While Sleep(30)
    _GDIPlus_GraphicsDrawImage($backbuffer, $load_background, 0, 0) ;draw background
    _GDIPlus_GraphicsDrawImage($backbuffer, $load_foreground, $x + Cos($i * $pi_div_180) * $radius, $y + Sin($i * $pi_div_180) * $radius) ;draw foreground
    $i += 2
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]

    Im Anhang unten sind die Bilder!

    Gruß,
    UEZ

    Dateien

    GDI+ Beispiel.7z 450,98 kB – 211 Downloads
  • Bei Hover - Rand einer GDI-Grafik ändern

    • UEZ
    • 11. Dezember 2009 um 15:36

    Hier die GDI+ Version:

    Spoiler anzeigen
    [autoit]


    #include <GUICtrlSetOnHover.au3>
    #include <GDIPlus.au3>
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    $GUIMain = GUICreate("Test", 200, 150)
    GUISetOnEvent(-3, "Quit")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    $DUMMY = GUICtrlCreateLabel("", 10, 10, 100, 100)
    GUICtrlSetBkColor(-1, -2)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($GUIMain)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    $pen_size = 4
    $hPen1 = _GDIPlus_PenCreate(0xFFFF0000, $pen_size)
    $hPen2 = _GDIPlus_PenCreate(0xFF000000, $pen_size)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 100, 100)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrl_SetOnHover($DUMMY, "_Hover_Proc", "_Leave_Hover_Func")

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(50)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Hover_Proc($iCtrlID, $iParam)
    _GDIPlus_GraphicsDrawRect($hGraphic, 10 + $pen_size / 2, 10 + $pen_size / 2, 100 - $pen_size, 100 - $pen_size, $hPen1)
    EndFunc ;==>_Hover_Proc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Leave_Hover_Func($iCtrlID)
    _GDIPlus_GraphicsDrawRect($hGraphic, 10 + $pen_size / 2, 10 + $pen_size / 2, 100 - $pen_size, 100 - $pen_size, $hPen2)
    EndFunc ;==>_Leave_Hover_Func

    [/autoit] [autoit][/autoit] [autoit]

    Func Quit()
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>Quit

    [/autoit]

    Gruß,
    UEZ

  • ObjGet() und IsObj()

    • UEZ
    • 10. Dezember 2009 um 16:17
    Zitat von ojo

    Hi,

    kontrollier mal den Dienst Remote-Registrierung. Falls er nicht gestartet sein sollte -> starten.

    ;-))
    Stefan

    Das ist nicht das Problem, sondern, wenn ich mein Skript starte, soll es unabhängig von den Remote Diensten laufen und nicht mit dem Fehler den Dienst quittieren.

    Abgesehen davon kann ich mich mit Regedit auf das Remote System verbinden ;)

    Ich werde es mal, wie von funkey vorgeschlagen, mit RegRead() probieren.

    Gruß,
    UEZ

  • ObjGet() und IsObj()

    • UEZ
    • 10. Dezember 2009 um 15:44
    Zitat von nuts

    Liegt der Schluss nahe, dass deine Anfrage nicht korrekt ist.
    http://msdn.microsoft.com/en-us/library/aa390788(VS.85).aspx

    Auf anderen System bekomme ich den Wert zurück, nur nicht auf diesem System. Wo siehst du den Fehler?

    UEZ

  • ObjGet() und IsObj()

    • UEZ
    • 10. Dezember 2009 um 15:22

    Brauche mal Hilfe hierzu:

    Wenn ich mit ObjGet() eine WMI Verbindung zu einem Remote System aufbaue

    $objReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $srv & "\root\default:StdRegProv")

    und mit

    If IsObj($objReg) Then

    das Objekt abfrage, hab ich das Problem, dass zwar $objReg zwar als Objekt erkannt wird, aber meine nächste Abfrage

    $objReg.GetStringValue($HKLM, $BaseKey, "Test", $OS_TEST)

    die Fehlermeldung

    Line -1:

    Error: The requested action with this object has failed.

    erscheint.

    Wenn ich mit Scriptomatic das System abfrage, kommt nichts zurück. Ich gehe davon aus, dass eine Verbing zwar aufgebaut wird, aber es kommen keine Werte zurück.

    Hat jemand eine Idee?

    Hier ein Extrakt des Codes:

    [autoit]


    ...
    $HKLM = 0x80000002
    $BaseKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
    $objReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $srv & "\root\default:StdRegProv")

    [/autoit][autoit][/autoit][autoit]

    If IsObj($objReg) Then
    $objReg.GetStringValue($HKLM, $BaseKey, "Test", $OS_TEST)
    Else
    ...

    [/autoit]


    Danke,
    UEZ

  • Decompiler unschädlich machen

    • UEZ
    • 10. Dezember 2009 um 10:09

    Meine Meinung dazu ist, dass es keinen absoluten Schutz gibt!

    Z.B. die Spieleindustrie hat sich die wildesten Kopierschutzmechanismen ausgedacht und trotzdem werden die Spiele geknackt! Oder die Cracks und Keygens zu diversen Programmen. Haben sich die Programmieren keine Gedanken über Schutzmaßnahmen gemacht? Ich denke doch.

    Zu AutoIt: wenn jemand den Skill hat, wird er den Code knacken und den Code reversen. Wenn ich meine AutoIt Programm kommerzialisieren will, dann muss ich damit rechnen, dass er geknackt wird.

    Jos und Co. kann den Code von der Exe wiederherstellen - also ist eine Möglichkeit doch möglich!

    Gruß,
    UEZ

  • XP-CD Key auslesen

    • UEZ
    • 9. Dezember 2009 um 09:47

    Habe den Code in #18 geändert. Bitte nochmals checken!

    Danke

  • XP-CD Key auslesen

    • UEZ
    • 8. Dezember 2009 um 21:31

    Hier der Versuch den Key auch von x64 Systemen zu lesen. Da das ganze über WMI läuft, können auch Remote System abgefragt werden.

    Da ich momentan Zuhause bin, kann ich den Remote Check nicht durchführen!

    Für einen Test von einem x32 auf einen x64 System wäre ich dankbar!

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_UseUpx=n
    ;~ #AutoIt3Wrapper_Change2CUI=y

    [/autoit] [autoit][/autoit] [autoit]

    If $CmdLine[0] > 0 Then
    MsgBox(0, "Windows OS Product Key", DecodeProductKey($CmdLine[1]))
    Else
    MsgBox(0, "Windows OS Product Key", DecodeProductKey("localhost"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Func DecodeProductKey($srv)
    Local $objWMILocator, $objRegService, $BaseKey, $BaseKey64, $oReg, $Product_Key, $Key, $arrSubKeys, $i, $t, $p
    Dim $BinaryDPID, $TempBinaryDPID
    $BaseKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
    $BaseKey64 = "SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\"
    $strValueName = "DigitalProductId"
    Const $HKLM = 0x80000002

    [/autoit] [autoit][/autoit] [autoit]

    $oReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $srv & "\root\default:StdRegProv")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If IsObj($oReg) Then
    If @OSArch = "X64" And ($srv = @ComputerName Or _ ;local check
    $srv = "localhost" Or _
    $srv = @IPAddress1 Or _
    $srv = @IPAddress2 Or _
    $srv = @IPAddress3 Or _
    $srv = @IPAddress4) Then
    $BinaryDPID = StringMid(RegRead("HKEY_LOCAL_MACHINE\" & $BaseKey, $strValueName), 3) ;if exe is x64
    If $BinaryDPID = "" Then $BinaryDPID = StringMid(RegRead("HKEY_LOCAL_MACHINE64\" & $BaseKey, $strValueName), 3) ;otherwise exe is x32
    Else
    $oReg.GetBinaryValue($HKLM, $BaseKey, "DigitalProductId", $Product_Key) ;remote check
    If Not IsArray($Product_Key) Then
    $oReg.GetBinaryValue($HKLM, $BaseKey64, "DigitalProductId", $Product_Key)
    EndIf
    $BinaryDPID = ""
    For $i = 0 To UBound($Product_Key) - 1
    $BinaryDPID &= Hex($Product_Key[$i], 2)
    Next
    EndIf
    Local $bKey[15]
    Local $sKey[29]
    Local $Digits[24]
    Local $Value = 0
    Local $hi = 0
    Local $n = 0
    Local $i = 0
    Local $dlen = 29
    Local $slen = 15
    Local $ProductKey
    $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
    $BinaryDPID = StringMid($BinaryDPID, 105, 30)
    For $i = 1 To 29 Step 2
    $bKey[Int($i / 2)] = Dec(StringMid($BinaryDPID, $i, 2))
    Next
    For $i = $dlen - 1 To 0 Step -1
    If Mod(($i + 1), 6) = 0 Then
    $sKey[$i] = "-"
    Else
    $hi = 0
    For $n = $slen - 1 To 0 Step -1
    $Value = BitOR(BitShift($hi, -8), $bKey[$n])
    $bKey[$n] = Int($Value / 24)
    $hi = Mod($Value, 24)
    Next
    $sKey[$i] = $Digits[$hi + 1]
    EndIf
    Next
    For $i = 0 To 28
    $ProductKey = $ProductKey & $sKey[$i]
    Next
    SetError(0)
    Return $ProductKey
    Else
    SetError(1)
    MsgBox(16, "ERROR", "An error has occured!", 10)
    EndIf
    EndFunc ;==>DecodeProductKey

    [/autoit]

    Danke,
    UEZ

  • GDI+: Filled Brushes

    • UEZ
    • 8. Dezember 2009 um 13:05

    Ups, stimmt :whistling: Habe den Code + Anhang entsprechend aktualisiert!

    Nichtsdestotrotz danke für beide Dateien.

    Sorry,
    UEZ

  • GDI+: Filled Brushes

    • UEZ
    • 8. Dezember 2009 um 08:14

    Ein kleines Beispiel dazu:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2009
    #include <GDIplus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $width = @DesktopWidth / 2
    Global Const $height = @DesktopHeight / 2
    Global Const $pi_div_180 = 4 * ATan(1) / 180

    [/autoit] [autoit][/autoit] [autoit]

    Global $hwnd = GUICreate("Border Collision with Hatch Brushes!", $width, $height, -1, -1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close") ;$GUI_EVENT_CLOSE = -3
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Move") ;move main window
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
    Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
    Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    _GDIPlus_GraphicsClear($backbuffer)
    _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)

    [/autoit] [autoit][/autoit] [autoit]

    Global $max_dots = 20
    Global $max_speed = 5
    Global $iWidth = 100
    Global $iHeight = 100
    Dim $coordinates[$max_dots][5], $angle
    Dim $brush[$max_dots]
    Global $hImage[$max_dots]
    Global $hContext
    Global $hBrush
    Global $sleep = 40

    [/autoit] [autoit][/autoit] [autoit]

    Initialize()

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113

    [/autoit] [autoit][/autoit] [autoit]

    DllCall("User32.dll", "int", "SetTimer", "hwnd", $hwnd, "int", 0, "int", $sleep, "int", 0)
    ;~ $hCallBack = DllCallbackRegister("Draw", "none", "") ;crashing on exit
    ;~ DllCall("User32.dll", "int", "SetTimer", "hwnd", $hwnd, "int", 0, "int", $sleep, "ptr", DllCallbackGetPtr($hCallBack))

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until False * Not Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    Func Move() ;move whole window when pressed lmb and hold continuing drawing of window content
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $hwnd, "int", $WM_NCLBUTTONDOWN, "int", 2, "int", 0) ;$WM_NCLBUTTONDOWN = 0x00A1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Draw()
    _GDIPlus_GraphicsClear($backbuffer, 0xFF000000)
    Draw_Dots()
    Calculate_New_Position()
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Initialize()
    For $k = 0 To $max_dots - 1
    $hImage[$k] = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    $hBrush = _GDIPlus_HatchBrushCreate(Random(0, 52, 1), "0xD0" & Hex(Random(0x400000, 0xFFFFFF, 1), 6), 0xFFFFFFFF)
    $hContext = _GDIPlus_ImageGetGraphicsContext($hImage[$k])
    _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iWidth, $iWidth, $hBrush)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BrushDispose($hBrush)
    New_Coordinates($k)
    Next
    EndFunc ;==>Initialize

    [/autoit] [autoit][/autoit] [autoit]

    Func Draw_Dots()
    Local $i, $temp_x, $temp_y
    For $i = 0 To $max_dots - 1
    _GDIPlus_GraphicsDrawImageRect($backbuffer, $hImage[$i], $coordinates[$i][0], $coordinates[$i][1], $iWidth, $iHeight)
    Next
    EndFunc ;==>Draw_Dots

    [/autoit] [autoit][/autoit] [autoit]

    Func New_Coordinates($k)
    $coordinates[$k][0] = $width / 2 ;Random($width / 20, $width - $width / 20, 1);start x position
    $coordinates[$k][1] = $height / 2 ;Random($height / 20, $height - $height / 20, 1) ;start y position
    $coordinates[$k][2] = Random(1, $max_speed, 1) ;speed of pixel
    $angle = Random(0, 359, 1)
    ;~ ConsoleWrite("Angle: " & $angle & "°" & @CRLF)
    $coordinates[$k][3] = $coordinates[$k][2] * Cos($angle * $pi_div_180)
    $coordinates[$k][4] = $coordinates[$k][2] * Sin($angle * $pi_div_180)
    EndFunc ;==>New_Coordinates

    [/autoit] [autoit][/autoit] [autoit]

    Func Calculate_New_Position()
    Local $k
    For $k = 0 To $max_dots - 1
    $coordinates[$k][0] += $coordinates[$k][3] ;increase x coordinate with appropriate slope
    $coordinates[$k][1] += $coordinates[$k][4] ;increase y coordinate with appropriate slope
    If $coordinates[$k][0] <= 0 Then ;border collision x left
    $coordinates[$k][0] = 1
    $coordinates[$k][3] *= -1
    ElseIf $coordinates[$k][0] >= $width - $iWidth Then ;border collision x right
    $coordinates[$k][0] = $width - ($iWidth + 1)
    $coordinates[$k][3] *= -1
    EndIf
    If $coordinates[$k][1] <= 0 Then ;border collision y top
    $coordinates[$k][1] = 1
    $coordinates[$k][4] *= -1
    ElseIf $coordinates[$k][1] >= $height - $iHeight Then ;border collision y bottom
    $coordinates[$k][1] = $height - ($iHeight + 1)
    $coordinates[$k][4] *= -1
    EndIf
    Next
    EndFunc ;==>Calculate_New_Position

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)

    [/autoit] [autoit][/autoit] [autoit]

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[6]
    EndFunc ;==>_GDIPlus_BitmapCreateFromScan0

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_HatchBrushCreate($iHatchStyle = 0, $iARGBForeground = 0xFFFFFFFF, $iARGBBackground = 0xFFFFFFFF)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateHatchBrush", "int", $iHatchStyle, "uint", $iARGBForeground, "uint", $iARGBBackground, "int*", 0)

    [/autoit] [autoit][/autoit] [autoit]

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[4]
    EndFunc ;==>_GDIPlus_HatchBrushCreate

    [/autoit] [autoit][/autoit] [autoit]

    Func close()
    GUIRegisterMsg($WM_TIMER, "")
    GUIRegisterMsg($WM_TIMER, "")
    ;~ DllCallbackFree($hCallBack)
    For $k = 0 To $max_dots-1
    _GDIPlus_ImageDispose($hImage[$k])
    Next
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>close

    [/autoit]

    Danke an Authenticity für die GDIp Bibliothek und die Hilfe die Kugel so zu füllen, dass die Muster nicht statisch im Hintergrund sind!

    Gruß,
    UEZ

    PS: GDIp.au3 + GDIpConstants.au3 werden für das Beispiel oben nicht mehr benötigt. Funktionen sind nun im Code integriert. Nichtsdestotrotz ein "must have" und sollte in keiner Sammlung fehlen!
    +: nun wird das Fenster weitergezeichnet, auch wenn das Fenster verschoben wird!

    Dateien

    Hatch Brushes Example 3.au3 5,54 kB – 286 Downloads
  • Graphicinhalt mit Farbe füllen

    • UEZ
    • 7. Dezember 2009 um 16:09

    Stimmt, wo du es jetzt sagst! :D

    Das Beispiel ist ein Mix aus GDI+ und GDI32!

    Gruß,
    UEZ

  • Graphicinhalt mit Farbe füllen

    • UEZ
    • 7. Dezember 2009 um 15:59

    Hier noch eine GDI32 Funktion: Flood Fill (Danke an Zedna für den ursprünglichen Code ) gemixt mit GDI+ :whistling: :

    Spoiler anzeigen
    [autoit]


    ;thanks to Zedna for the original code -> http://www.autoitscript.com/forum/index.ph…ew=findpost&p=3
    #include <GDIplus.au3>
    #include <GUIConstantsEx.au3>
    #Include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode",2)

    [/autoit] [autoit][/autoit] [autoit]

    Global $dll = DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $bitmap_from_file = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\South_America_Map.GIF')

    [/autoit] [autoit][/autoit] [autoit]

    Global $width = _GDIPlus_ImageGetWidth ($bitmap_from_file)
    Global $height = _GDIPlus_ImageGetHeight ($bitmap_from_file)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hwnd = GUICreate("GDI32: Flood Fill Example", $width, $height)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetOnEvent(-3, "Close")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Global $hDC = _WinAPI_GetDC($hWnd)
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $bitmap_from_file, 0, 0, $width, $height)

    [/autoit] [autoit][/autoit] [autoit]

    $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", 0xFF5050) ; fill color BGR
    $obj_orig = DLLCall("gdi32.dll", "int", "SelectObject", "int", $hDC, "int", $hBrush[0])

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(50)

    [/autoit] [autoit][/autoit] [autoit]

    If _IsPressed("01") And WinActive($hWnd) Then
    $mp = MouseGetPos()
    DllCall("gdi32.dll", "int", "FloodFill", "int", $hDC, "int", $mp[0], "int", $mp[1], "int", 0x00) ; border color
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Close()
    DllClose($dll)
    DLLCall("gdi32.dll" ,"int", "SelectObject", "hwnd", $hwnd, "int", $obj_orig[0])
    DLLCall("gdi32.dll","int","DeleteObject","int",$hBrush[0])
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]

    Am besten die Zip Datei benutzen, da dort auch die Grafik ist, um die Flächen zu füllen (lmt füllt die Fläche)!

    Gruß,
    UEZ

    Dateien

    GDI32 Flood Fill.zip 7,5 kB – 278 Downloads
  • Checkboxen

    • UEZ
    • 7. Dezember 2009 um 00:20

    Ich hatte mal vor längere Zeit was geschrieben.

    Vielleicht hilft es dir ja.

    Spoiler anzeigen
    [autoit]


    ;Coded by UEZ
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #include <StructureConstants.au3>
    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Test", 237, 143)
    $Checkbox1 = GUICtrlCreateCheckbox("Convert X", 8, 8, 97, 17)
    $Checkbox2 = GUICtrlCreateCheckbox("Convert Y", 8, 40, 97, 17)
    $Checkbox3 = GUICtrlCreateCheckbox("Convert Z", 8, 72, 97, 17)
    $Input1 = GUICtrlCreateInput("", 105, 8, 121, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Input2 = GUICtrlCreateInput("", 105, 40, 121, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Input3 = GUICtrlCreateInput("", 105, 72, 121, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button1 = GUICtrlCreateButton("Load", 8, 104, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Save", 153, 104, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Button1
    Load()

    Case $Button2
    Save()

    Case $Checkbox1
    If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then
    GUICtrlSetState($Input1, $GUI_ENABLE)
    Else
    GUICtrlSetState($Input1, $GUI_DISABLE)
    EndIf

    Case $Checkbox2
    If BitAND(GUICtrlRead($Checkbox2), $GUI_CHECKED) Then
    GUICtrlSetState($Input2, $GUI_ENABLE)
    Else
    GUICtrlSetState($Input2, $GUI_DISABLE)
    EndIf

    Case $Checkbox3
    If BitAND(GUICtrlRead($Checkbox3), $GUI_CHECKED) Then
    GUICtrlSetState($Input3, $GUI_ENABLE)
    Else
    GUICtrlSetState($Input3, $GUI_DISABLE)
    EndIf
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func Save()
    Local $ini, $save_file, $filename, $dummy_array
    Local $filename_suffix = ".ini"
    Local $save_path = @ScriptDir
    $filename = ""
    $filename = FileSaveDialog("Save Project Request Form", $save_path, "Ini Files (*" & $filename_suffix & ")|All Files(*.*)", 16)
    If $filename <> "" Then
    $dummy_array = StringSplit($filename, ".")
    If UBound($dummy_array) > 0 Then
    $filename = $dummy_array[1] & $filename_suffix
    Else
    $filename = $filename_suffix
    EndIf
    If Not @error Then
    $ini = "[Input Section]" & @CRLF & _
    "Convert X=" & GUICtrlRead($Input1) & @CRLF & _
    "Convert Y=" & GUICtrlRead($Input2) & @CRLF & _
    "Convert Z=" & GUICtrlRead($Input3) & @CRLF & @CRLF & _
    "[Checkbox Section]" & @CRLF & _
    "Checkbox1=" & GUICtrlRead($Checkbox1) & @CRLF & _
    "Checkbox2=" & GUICtrlRead($Checkbox2) & @CRLF & _
    "Checkbox3=" & GUICtrlRead($Checkbox3) & @CRLF
    FileOpen($filename, 2)
    FileWrite($filename, $ini)
    FileClose($filename)
    EndIf
    EndIf
    EndFunc ;==>Save

    [/autoit] [autoit][/autoit] [autoit]

    Func Load()
    Local $filename, $dummy_array, $line
    Local $filename_suffix = ".ini"
    Local $load_path = @ScriptDir
    $filename = ""
    $filename = FileOpenDialog("Load Project Request Form", $load_path, "Ini Files (*" & $filename_suffix & ")|All Files(*.*)", 1)
    If $filename <> "" Then
    $filename = FileOpen($filename, 0)
    If Not @error Then
    While 1
    $line = FileReadLine($filename)
    If @error = -1 Then ExitLoop
    If StringInStr($line, "Convert X=") Then GUICtrlSetData($Input1, StringMid($line, StringInStr($line, "=") + 1))
    If StringInStr($line, "Convert Y=") Then GUICtrlSetData($Input2, StringMid($line, StringInStr($line, "=") + 1))
    If StringInStr($line, "Convert Z=") Then GUICtrlSetData($Input3, StringMid($line, StringInStr($line, "=") + 1))
    If StringInStr($line, "Checkbox1=") = True And StringMid($line, StringInStr($line, "=") + 1) = 1 Then
    GUICtrlSetState($Checkbox1, $GUI_CHECKED)
    GUICtrlSetState($Input1, $GUI_ENABLE)
    EndIf
    If StringInStr($line, "Checkbox1=") = True And StringMid($line, StringInStr($line, "=") + 1) = 4 Then
    GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
    GUICtrlSetState($Input1, $GUI_DISABLE)
    EndIf
    If StringInStr($line, "Checkbox2=") = True And StringMid($line, StringInStr($line, "=") + 1) = 1 Then
    GUICtrlSetState($Checkbox2, $GUI_CHECKED)
    GUICtrlSetState($Input2, $GUI_ENABLE)
    EndIf
    If StringInStr($line, "Checkbox2=") = True And StringMid($line, StringInStr($line, "=") + 1) = 4 Then
    GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
    GUICtrlSetState($Input2, $GUI_DISABLE)
    EndIf
    If StringInStr($line, "Checkbox3=") = True And StringMid($line, StringInStr($line, "=") + 1) = 1 Then
    GUICtrlSetState($Checkbox3, $GUI_CHECKED)
    GUICtrlSetState($Input3, $GUI_ENABLE)
    EndIf
    If StringInStr($line, "Checkbox3=") = True And StringMid($line, StringInStr($line, "=") + 1) = 4 Then
    GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
    GUICtrlSetState($Input3, $GUI_DISABLE)
    EndIf
    WEnd
    FileClose($filename)
    EndIf
    EndIf
    EndFunc ;==>Load

    [/autoit]

    Mit Load bzw. Save kannst du den Zustand laden oder speichern. Wenn die Checkbox aktiviert ist, kannst du in das Feld was reinschreiben.

    Gruß,
    UEZ

  • GDI+: Filled Brushes

    • UEZ
    • 6. Dezember 2009 um 15:32

    Ich habe mir mal die GDI+ Funktion _GDIPlus_HatchBrushCreate() näher angeschaut. Man kann den Pinsel jetzt mit 53 Muster füllen lassen!

    Nichts besonderes, aber erwähnenswert:

    Spoiler anzeigen
    [autoit]


    ;Coded by UEZ 2009.12.06
    #include <GDIplus.au3>
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $width = @DesktopWidth * 0.75
    Global $height = @DesktopHeight * 0.75

    [/autoit] [autoit][/autoit] [autoit]

    Global $hwnd = GUICreate("GDI+: Filled Brushes by UEZ", $width, $height, -1, -1, Default)
    GUISetOnEvent(-3, "_Exit")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
    _GDIPlus_GraphicsSetSmoothingMode($graphics, 4)

    [/autoit] [autoit][/autoit] [autoit]

    Global $brush[53]
    For $i = 0 To UBound($brush) - 1
    $brush[$i] = _GDIPlus_HatchBrushCreate($i, 0xFF0000FF, 0xFFFFFFFF)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $dx = Int($width / 8)
    $dy = Int($height / 7)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($graphics, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    $k = 0
    For $i = 0 To $height -1 Step $dy
    For $j = 0 To $width - 1 Step $dx
    If $k <= UBound($brush) -1 Then _GDIPlus_GraphicsFillEllipse($graphics, $j, $i, $dx, $dy, $brush[$k])
    $k += 1
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(150)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    For $i = 0 To UBound($brush) - 1
    _GDIPlus_BrushDispose($brush[$i])
    Next
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_HatchBrushCreate($iHatchStyle = 0, $iARGBForeground = 0xFFFFFFFF, $iARGBBackground = 0xFFFFFFFF)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateHatchBrush", "int", $iHatchStyle, "uint", $iARGBForeground, "uint", $iARGBBackground, "int*", 0)

    [/autoit] [autoit][/autoit] [autoit]

    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[4])
    EndFunc ;==>_GDIPlus_HatchBrushCreate

    [/autoit]

    Viel Spaß und schönen Nikolaus!

    UEZ

  • Mausbewegung beschleunigt Programmausführung?!

    • UEZ
    • 4. Dezember 2009 um 23:55

    Wollte ich gerade bestätigen!

    UEZ ;)

  • Geburtstag von peethebee und funkey

    • UEZ
    • 4. Dezember 2009 um 23:25

    Auch von mir ein Happy Birthday und alles Gute!

    UEZ

  • GDI+ : 1 Bild + 2 Bild = ???

    • UEZ
    • 4. Dezember 2009 um 23:17

    Aber das Beispiel aus der Hilfe ist wohl besser und einfacher:

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICreate("GDI+ Example", 500, 300)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 36)
    $hLayout = _GDIPlus_RectFCreate(0, 150 - 36, 500, 300)
    $hStringFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hStringFormat, 1)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, "0 1 2 3 4 5 6 7 8 9", $hFont, $hLayout, $hStringFormat, $hBrush)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()

    [/autoit]

    Gruß,
    UEZ

  • GDI+ : 1 Bild + 2 Bild = ???

    • UEZ
    • 4. Dezember 2009 um 23:02

    Damit der Text wie in dem Bild aussieht, benötigst du ein Font!

    Hier ein GDI+ Text Beispiel:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ
    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGUI, $hWnd, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
    Global $x, $y, $w, $h
    Global $sString = "Hello world"
    Global $width = 400
    Global $heigh = 40
    ; Create GUI
    $hWnd = GUICreate("GDI+", $width, $heigh)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _Main()

    [/autoit] [autoit][/autoit] [autoit]

    Func _Main()

    [/autoit] [autoit][/autoit] [autoit]

    ; Draw a string
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    $hBrush = _GDIPlus_BrushCreateSolid (0xFF00007F)
    $hFormat = _GDIPlus_StringFormatCreate ()
    $hFamily = _GDIPlus_FontFamilyCreate ("Arial")
    $hFont = _GDIPlus_FontCreate ($hFamily, 12, 2)
    Measure($sString)
    $tLayout = _GDIPlus_RectFCreate (($width - $w) / 2, ($heigh - $h) / 2, 0, 0)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    [/autoit] [autoit][/autoit] [autoit]

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit]

    ; Clean up resources
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_StringFormatDispose ($hFormat)
    _GDIPlus_BrushDispose ($hBrush)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_Main

    [/autoit] [autoit][/autoit] [autoit]

    Func Measure($text)
    Local $hBuffer = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    Local $hBrush = _GDIPlus_BrushCreateSolid (0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate ()
    Local $hFamily = _GDIPlus_FontFamilyCreate ("Arial")
    Local $hFont = _GDIPlus_FontCreate ($hFamily, 12, 2)
    Local $tLayout = _GDIPlus_RectFCreate (0, 0, 0, 0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString ($hBuffer, $sString, $hFont, $tLayout, $hFormat)
    $x = DllStructGetData($aInfo[0],1)
    $y = DllStructGetData($aInfo[0],2)
    $w = DllStructGetData($aInfo[0],3)
    $h = DllStructGetData($aInfo[0],4)
    ConsoleWrite("x: " & $x & @CRLF & "y: " & $y & @CRLF & "w: " & $w & @CRLF & "h: " & $h & @CRLF)
    EndFunc

    [/autoit]

    Willst du ein Font laden und in GDI+ benutzen, so schaue doch mal hier vorbei: http://www.autoitscript.com/forum/index.php?showtopic=94679&view=findpost&p=680168&hl=&fromsearch=1

    Gruß,
    UEZ

    PS: ist ein älteres Beispiel!

  • Remote Lokale Gruppe members auslesen

    • UEZ
    • 3. Dezember 2009 um 16:13

    Hier ein Auszug aus SIC2 :

    Spoiler anzeigen
    [autoit]


    ;Coded by UEZ 2009
    #AutoIt3Wrapper_Change2CUI=y
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_UseX64=n
    #include <array.au3>
    Global $server = "localhost"
    If $CmdLine[0] > 0 Then $server = $CmdLine[1]

    [/autoit] [autoit][/autoit] [autoit]

    $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $server & "\root\cimv2")

    [/autoit] [autoit][/autoit] [autoit]

    Membership_Administrators_Local($server)

    [/autoit] [autoit][/autoit] [autoit]

    Func Membership_Administrators_Local($srv)
    If StringUpper($srv) = StringUpper("Localhost") Then $srv = @ComputerName
    Local $function_name = "Members"
    Local $LM_members, $x, $LM_LocalGroup_Name, $type, $colItems2, $LM_local_user, $y, $line, $TimeStamp
    Local $filename_ms = $function_name & "_" & $srv
    Local $filename_error_current = $function_name & "_" & $srv & "_error.log"
    $LM_LocalGroup_Name = "Administrators"
    $colItems = $objWMIService.ExecQuery("Select SID from Win32_Group WHERE Domain='" & $srv & "'", "WQL", 0x30)
    If IsObj($colItems) Then
    For $objItem In $colItems
    If StringUpper($objItem.SID) = StringUpper("S-1-5-32-544") Then $LM_LocalGroup_Name = $objItem.Name
    Next
    EndIf
    $type = ""
    $LM_local_user = ""
    $colItems = $objWMIService.ExecQuery("Select * from Win32_GroupUser Where GroupComponent=""Win32_Group.Domain='" & $srv & "',Name='" & $LM_LocalGroup_Name & "'""", "WQL", 0x30)
    If IsObj($colItems) Then
    For $objItem In $colItems
    If $objItem.PartComponent <> "" Then
    $x = StringSplit($objItem.PartComponent, """")
    $type = StringMid($x[1], StringInStr($x[1], ":Win32_") + 7, (StringInStr($x[1], ".") - (StringInStr($x[1], ":Win32_") + 7)))
    $LM_members &= $srv & ";" & $LM_LocalGroup_Name & ";" & $type & ";" & $x[2] & "\" & $x[4] & ";" & @CRLF
    EndIf
    Next
    EndIf
    ConsoleWrite($LM_members)
    EndFunc ;==>Membership_Administrators_Local

    [/autoit]

    Vielleicht musst du noch die Sprache anpassen (Administrators -> Administratoren)!

    Gruß,
    UEZ

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™