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. SEuBo

Beiträge von SEuBo

  • Monochromzeichnen eines Bildes

    • SEuBo
    • 15. Dezember 2009 um 19:46

    Hallöchen,
    Habe hier dieses Skript gebastelt, welches ein jpg zu einem Monochrom (Schwarz/Weiß)-Bild "umwandelt". Funktioniert auch super! Nur Frage ich mich, ob es nicht einen Weg gibt, die Geschwindigkeit des ganzen zu optimieren?

    Ich erinnere mich, dass Andy mal vor einigen Tagen erwähnte, er habe für das englische Forum eine PixelGetColor / PixelSearch Funktion geschrieben die sehr viel schneller arbeitet (Kann mich aber auch irren !)

    Auf das PixelGetColor kann ich leider nicht verzichten. Das Programm soll noch so erweitert werden, dass es das Bild zB. in Paint nachmalt (per Mousemove/Mouseclick). Deswegen brauche ich die einzelnen Pixelfarben in einem Array

    Spoiler anzeigen
    [autoit]

    $FilePath = FileOpenDialog("", "", "JPG (*.jpg)")
    If @error Then Exit

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

    #include <GDIPlus.au3>
    #include <Array.au3>
    #include <Color.au3>
    #include <File.au3>
    _GDIPlus_Startup()

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

    Global Const $AC_SRC_ALPHA = 1

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

    $img_hwnd = _GDIPlus_ImageLoadFromFile($FilePath)
    $img_w = _GDIPlus_ImageGetWidth($img_hwnd)
    $img_h = _GDIPlus_ImageGetHeight($img_hwnd)
    _GDIPlus_ImageDispose($img_hwnd)

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

    $guiMain = GUICreate("", $img_w, $img_h + 50, -1, -1)
    $ctrl_Einlesen = GUICtrlCreateButton("Einlesen", 0, $img_h, $img_w, 25)
    $ctrl_Progress = GUICtrlCreateProgress(0, $img_h + 25, $img_w, 25)
    $guiChild = GUICreate("", $img_w, $img_h, 0, 0, 0x40000000, Default, $guiMain)
    GUICtrlCreatePic($FilePath, 0, 0, 0, 0)
    $guiChild2 = GUICreate("", $img_w, $img_h, 0, 0, 0x40000000, Default, $guiMain)

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

    GUISetState(@SW_SHOW, $guiMain)
    GUISetState(@SW_SHOW, $guiChild)

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

    ;~ _ColorGetBlue()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $ctrl_Einlesen
    _ImageDrawBlackAndWhite($guiChild, 115)
    Case -3
    Exit
    EndSwitch
    WEnd

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

    Func _ImageDrawBlackAndWhite($hWnd, $iTol=115, $iArray=0)
    Local $xPos = 0, $yPos = 0, $aRet[$img_h*$img_w+1]
    $opt_Mode = Opt("PixelCoordMode", 2)
    ConsoleWrite("+> " & $img_h * $img_w & @CR & @CR)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hPenBlack = _GDIPlus_PenCreate(0xFF000000)
    $hPenWhite = _GDIPlus_PenCreate(0xFFFFFFFF)

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

    For $i = 1 To ($img_h * $img_w)
    $iTmp = _ColorToBrightness(PixelGetColor($xPos, $yPos), 1, $iTol)
    If $iTmp = 0xFFFFFF Then _GDIPlus_GraphicsDrawLine ($hGraphic, $xPos, $yPos, $xPos-1, $yPos, $hPenWhite)
    If $iTmp = 0x000000 Then _GDIPlus_GraphicsDrawLine ($hGraphic, $xPos, $yPos, $xPos-1, $yPos, $hPenBlack)
    If $iArray = 1 Then $aRet[$i] = $iTmp

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

    $xPos += 1
    If $xPos = $img_w Then
    GUICtrlSetData($ctrl_Progress, $i / ($img_h * $img_w) * 100)
    ConsoleWrite("+> " & $i & " / " & $img_h * $img_w & " ("&Round($i / ($img_h * $img_w) * 100,1)&" %) "&@CR & @CR)
    $xPos = 0
    $yPos += 1
    EndIf
    Next
    GUICtrlSetData($ctrl_Progress, 0)
    If $iArray=1 Then Return $aRet

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

    EndFunc ;==>_ImageDrawBlackAndWhite

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

    Func _ColorToBrightness($iColor, $iBlackAndWhite = 1, $iTol = 115)
    Local $aRet, $aTemp[3] = [_ColorGetRed($iColor), _ColorGetGreen($iColor), _ColorGetBlue($iColor)]
    $aRet = _ColorConvertRGBtoHSL($aTemp)
    If $iBlackAndWhite = 1 Then
    If $aRet[2] < $iTol Then
    Return 0x000000
    Else
    Return 0xFFFFFF
    EndIf
    EndIf
    Return $aRet[2]
    EndFunc ;==>_ColorToBrightness

    [/autoit]

    EDIT: hab mal ein Bild in den Anhang geladen, um zu zeigen was dabei rauskommt

    EDIT2: Habe grade das hier gefunden:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <Color.au3>
    #include <WinAPI.au3>

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

    Global $threshold
    Global $image
    Global $width
    Global $height
    Global $pixels
    Global $pathString = "12345678"
    Global $scramble = False
    Global $rotate = 0
    Global $speed

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

    ;; Check hotkeys ;;
    If (Not HotKeySet ("{F9}", "Nothing")) Then
    MsgBox (16, "Error", "Could not register the F9 hotkey.")
    Exit
    EndIf
    If (Not HotKeySet ("{F10}", "Nothing")) Then
    MsgBox (16, "Erro", "Could not register the F10 hotkey.")
    Exit
    EndIf

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

    ;; Image dialog ;;
    $imageFile = FileOpenDialog ("Open image", "", "Images (*.jpg;*.jpeg;*.gif;*.png;*.bmp)", 1)
    If (@error) Then Exit

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

    ;; Options dialog ;;
    $optGUI = GUICreate ("Settings", 160, 270, -1, -1, $WS_CAPTION, BitOr ($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW))
    GUICtrlCreateGroup ("Image processing", 5, 5, 150, 85)
    GUICtrlCreateLabel ("Sensitivity (0~255):", 10, 28, 110, 15)
    $thresholdInput = GUICtrlCreateInput ("100", 125, 25, 25, 20, $ES_NUMBER)
    GUICtrlCreateLabel ("Width (px):", 10, 48, 110, 15)
    $widthInput = GUICtrlCreateInput ("100", 125, 45, 25, 20, $ES_NUMBER)
    GUICtrlCreateLabel ("Height (px):", 10, 68, 110, 15)
    $heightInput = GUICtrlCreateInput ("100", 125, 65, 25, 20, $ES_NUMBER)
    GUICtrlCreateGroup ("Drawing pattern", 5, 95, 150, 140)
    $horizontalRadio = GUICtrlCreateRadio ("Horizontal", 10, 115, 110, 15)
    $verticalRadio = GUICtrlCreateRadio ("Vertical", 10, 135, 110, 15)
    $diagonalRadio = GUICtrlCreateRadio ("Diagonal", 10, 155, 110, 15)
    $rotateRadio = GUICtrlCreateRadio ("Spiral", 10, 175, 110, 15)
    $scrambleRadio = GUICtrlCreateRadio ("Random", 10, 195, 110, 15)
    GUICtrlSetState ($diagonalRadio, $GUI_CHECKED)
    GUICtrlCreateLabel ("Mouse speed (0~100):", 10, 213, 110, 15)
    $speedInput = GUICtrlCreateInput ("0", 125, 210, 25, 20, $ES_NUMBER)
    $okBtn = GUICtrlCreateButton ("Ok", 30, 245, 40, 20)
    $cancelBtn = GUICtrlCreateButton ("Cancel", 80, 245, 50, 20)
    GUISetState ()

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

    While 1
    Switch (GUIGetMsg ())
    Case $GUI_EVENT_CLOSE
    Exit
    Case $cancelBtn
    Exit
    Case $okBtn
    $threshold = GUICtrlRead ($thresholdInput)
    $width = GUICtrlRead ($widthInput)
    $height = GUICtrlRead ($heightInput)
    $speed = GUICtrlRead ($speedInput)
    If (GUICtrlRead ($horizontalRadio) == $GUI_CHECKED) Then
    $pathString = "45273618"
    ElseIf (GUICtrlRead ($verticalRadio) == $GUI_CHECKED) Then
    $pathString = "27453618"
    ElseIf (GUICtrlRead ($diagonalRadio) == $GUI_CHECKED) Then
    $pathString = "36184527"
    ElseIf (GUICtrlRead ($rotateRadio) == $GUI_CHECKED) Then
    $pathString = "14678532"
    $rotate = 1
    ElseIf (GUICtrlRead ($scrambleRadio) == $GUI_CHECKED) Then
    $scramble = True
    EndIf

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

    GUIDelete ($optGUI)
    ExitLoop
    EndSwitch
    WEnd

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

    ;; Processing dialog ;;
    $GUI = GUICreate ("Processing image...", $width, $height + 20, -1, -1, $WS_CAPTION, BitOr ($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW))
    GUISetBkColor (0xffffff)
    $imageBox = GUICtrlCreatePic ($imageFile, 0, 0, $width, $height)
    $progress = GUICtrlCreateProgress (0, $height, $width, 20)
    GUISetState ()

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

    ;; Get image pixels ;;
    $dc = _WinAPI_GetDC ($GUI)
    $memDc = _WinAPI_CreateCompatibleDC ($dc)
    $bitmap = _WinAPI_CreateCompatibleBitmap ($dc, $width, $height)
    _WinAPI_SelectObject ($memDc, $bitmap)
    _WinAPI_BitBlt ($memDc, 0, 0, $width, $height, $dc, 0, 0, $SRCCOPY)
    $bits = DllStructCreate ("dword[" & ($width * $height) & "]")
    DllCall ("gdi32", "int", "GetBitmapBits", "ptr", $bitmap, "int", ($width * $height * 4), "ptr", DllStructGetPtr ($bits))
    GUICtrlDelete ($imageBox)

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

    ;; Process the pixels ;;
    Dim $pixels[$width][$height]
    For $y = 0 To ($height - 1)
    For $x = 0 To ($width - 1)
    $index = ($y * $width) + $x
    $color = DllStructGetData ($bits, 1, $index)

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

    $red = _ColorGetBlue ($color)
    $green = _ColorGetGreen ($color)
    $blue = _ColorGetRed ($color)
    $shade = ($red + $green + $blue) / 3
    If ($shade > $threshold) Then
    $color = 0xffffff
    $pixels[$x][$y] = 0
    Else
    $color = 0
    $pixels[$x][$y] = 1
    EndIf

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

    DllStructSetData ($bits, 1, $color, $index)
    Next

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

    DllCall ("gdi32", "int", "SetBitmapBits", "ptr", $bitmap, "int", ($width * $height * 4), "ptr", DllStructGetPtr ($bits))
    _WinAPI_BitBlt ($dc, 0, 0, $width, $height, $memDc, 0, 0, $SRCCOPY)
    GUICtrlSetData ($progress, ($y * 100) / $height)
    Next

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

    _WinAPI_ReleaseDC ($GUI, $dc)
    GUIRegisterMsg ($WM_PAINT, "OnPaint")

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

    ;; Ready to draw ;;
    TrayTip ("Pronto!", "Press F9 para draw. You can press F10 anytime to exit.", 10)
    HotKeySet ("{F9}", "Draw")
    HotKeySet ("{F10}", "Quit")

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

    While 1
    Sleep (60000)
    WEnd

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

    Func OnPaint ($hwndGUI, $msgID, $wParam, $lParam)
    Local $paintStruct = DllStructCreate ("hwnd hdc;int fErase;dword rcPaint[4];int fRestore;int fIncUpdate;byte rgbReserved[32]")

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

    $dc = DllCall ("user32", "hwnd", "BeginPaint", "hwnd", $hwndGUI, "ptr", DllStructGetPtr ($paintStruct))
    $dc = $dc[0]

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

    _WinAPI_BitBlt ($dc, 0, 0, $width, $height, $memDc, 0, 0, $SRCCOPY)

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

    DllCall ("user32", "hwnd", "EndPaint", "hwnd", $hwndGUI, "ptr", DllStructGetPtr ($paintStruct))
    Return $GUI_RUNDEFMSG
    EndFunc

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

    Func Draw ()
    $mouseCenter = MouseGetPos ()
    $x0 = $mouseCenter[0] - ($width / 2)
    $y0 = $mouseCenter[1] - ($height / 2)

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

    ;; Move the mouse around the drawing perimeter ;;
    MouseMove ($x0, $y0)
    MouseMove ($x0 + $width, $y0)
    MouseMove ($x0 + $width, $y0 + $height)
    MouseMove ($x0, $y0 + $height)
    MouseMove ($x0, $y0)

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

    ;; Draw all the areas ;;
    $stack = CreateStack (1000)
    For $y = 0 To ($height - 1)
    For $x = 0 To ($width - 1)
    If ($pixels[$x][$y] == 1) Then
    MouseMove ($x + $x0, $y + $y0, $speed)
    MouseDown ("primary")
    DrawArea ($stack, $x, $y, $x0, $y0)
    MouseUp ("primary")
    Else
    EndIf
    Next
    Next

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

    ;; Reset the pixels statuses ;;
    For $y = 0 To ($height - 1) Step 1
    For $x = 0 To ($width - 1) Step 1
    If ($pixels[$x][$y] == 2) Then
    $pixels[$x][$y] = 1
    EndIf
    Next
    Next
    EndFunc

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

    Func DrawArea (ByRef $stack, $x, $y, $x0, $y0)
    Local $path[8]
    Local $continue

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

    $path = MakePath ($pathString)

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

    While 1
    MouseMove ($x + $x0, $y + $y0, $speed)
    $pixels[$x][$y] = 2

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

    If ($scramble) Then ScramblePath ($path)
    If ($rotate > 0) Then RotatePath ($path, $rotate)

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

    ;;;;;;;;;;;;;;;;;;;
    ;; +---+---+---+ ;;
    ;; | 1 | 2 | 3 | ;;
    ;; +---+---+---+ ;;
    ;; | 4 | | 5 | ;;
    ;; +---+---+---+ ;;
    ;; | 6 | 7 | 8 | ;;
    ;; +---+---+---+ ;;
    ;;;;;;;;;;;;;;;;;;;

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

    $continue = False
    For $i = 0 To 7
    Switch ($path[$i])
    Case 1
    If (($x > 0) And ($y > 0)) Then
    If ($pixels[$x - 1][$y - 1] == 1) Then
    Push ($stack, $x, $y)
    $x -= 1
    $y -= 1
    $continue = True
    ExitLoop
    EndIf
    EndIf

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

    Case 2
    If ($y > 0) Then
    If ($pixels[$x][$y - 1] == 1) Then
    Push ($stack, $x, $y)
    $y -= 1
    $continue = True
    ExitLoop
    EndIf
    EndIf

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

    Case 3
    If (($x > 0) And ($y < 0)) Then
    If ($pixels[$x + 1][$y - 1] == 1) Then
    Push ($stack, $x, $y)
    $x += 1
    $y -= 1
    $continue = True
    ExitLoop
    EndIf
    EndIf

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

    Case 4
    If ($x > 0) Then
    If ($pixels[$x - 1][$y] == 1) Then
    Push ($stack, $x, $y)
    $x -= 1
    $continue = True
    ExitLoop
    EndIf
    EndIf

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

    Case 5
    If ($x < ($width - 1)) Then
    If ($pixels[$x + 1][$y] == 1) Then
    Push ($stack, $x, $y)
    $x += 1
    $continue = True
    ExitLoop
    EndIf
    EndIf

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

    Case 6
    If (($x < 0) And ($y > 0)) Then
    If ($pixels[$x - 1][$y + 1] == 1) Then
    Push ($stack, $x, $y)
    $x -= 1
    $y += 1
    $continue = True
    ExitLoop
    EndIf
    EndIf

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

    Case 7
    If ($y < ($height - 1)) Then
    If ($pixels[$x][$y + 1] == 1) Then
    Push ($stack, $x, $y)
    $y += 1
    $continue = True
    ExitLoop
    EndIf
    EndIf

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

    Case 8
    If (($x < ($width - 1)) And ($y < ($height - 1))) Then
    If ($pixels[$x + 1][$y + 1] == 1) Then
    Push ($stack, $x, $y)
    $x += 1
    $y += 1
    $continue = True
    ExitLoop
    EndIf
    EndIf
    EndSwitch
    Next
    If ($continue) Then ContinueLoop

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

    If (Not Pop ($stack, $x, $y)) Then ExitLoop
    WEnd
    EndFunc

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

    Func MakePath ($string)
    Return StringSplit ($string, "")
    EndFunc

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

    Func ScramblePath (ByRef $path)
    Local $table = "12345678"
    Local $newPath[8]

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

    For $i = 8 To 1 Step -1
    $next = StringMid ($table, Random (1, $i, 1), 1)
    $newPath[$i - 1] = Number ($next)
    $table = StringReplace ($table, $next, "")
    Next

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

    $path = $newPath
    EndFunc

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

    Func RotatePath (Byref $path, $places)
    If ($places == 0) Then
    Return $path
    Else
    For $i = 1 To Abs ($places)
    $temp = $path[7]
    $path[7] = $path[6]
    $path[6] = $path[5]
    $path[5] = $path[4]
    $path[4] = $path[3]
    $path[3] = $path[2]
    $path[2] = $path[1]
    $path[1] = $path[0]
    $path[0] = $temp
    Next
    EndIf
    EndFunc

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

    Func CreateStack ($size)
    Dim $stack[$size + 1][2]
    $stack[0][0] = 0
    $stack[0][1] = $size
    Return $stack
    EndFunc

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

    Func Push (ByRef $stack, $x, $y)
    $stack[0][0] += 1
    If ($stack[0][0] > $stack[0][1]) Then
    $stack[0][1] += 1000
    ReDim $stack[$stack[0][1] + 1][2]
    EndIf

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

    $stack[$stack[0][0]][0] = $x
    $stack[$stack[0][0]][1] = $y
    EndFunc

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

    Func Pop (ByRef $stack, ByRef $x, ByRef $y)
    If ($stack[0][0] < 1) Then
    Return False
    EndIf

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

    $x = $stack[$stack[0][0]][0]
    $y = $stack[$stack[0][0]][1]

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

    $stack[0][0] -= 1
    Return True
    EndFunc

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

    Func Nothing ()
    EndFunc

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

    Func Quit ()
    MouseUp ("primary")
    Exit
    EndFunc

    [/autoit]


    Muss mich da zwar noch durchkämpfen, aber ich stell mal auf gelöst - der DLL Call macht ja das gleiche wie mein PixelGetcolor. Nur 100000 mal schneller

    Bilder

    • FR2bnw.jpg
      • 16,72 kB
      • 238 × 165
  • MSG Box - Funktionen und Text Anzeigen

    • SEuBo
    • 15. Dezember 2009 um 19:39

    Ich versteh das Problem ehrlich gesagt nicht wirklich ?(

  • Farbraum Umrechner

    • SEuBo
    • 15. Dezember 2009 um 18:52

    :thumbup: Kann ich aus gegebenem Anlass sehr gut gebrauchen
    Gute Arbeit.

  • Dummy-Editor in Autoit ?

    • SEuBo
    • 15. Dezember 2009 um 18:18

    Erst vor kurzem gepostet worden: https://autoit.de/index.php?page…9820#post109820

  • List Box Befehle

    • SEuBo
    • 14. Dezember 2009 um 22:18

    Mal ergänzend zu Raupis erklärungen:

    Spoiler anzeigen
    [autoit]

    #Include <GuiListBox.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    $hGUI = GUICreate("Button321",450,200)
    $Delete_Selected = GUICtrlCreateButton("Auswahl löschen",20,30,150,25)
    $Delete_All = GUICtrlCreateButton("Alle löschen",20,70,150,25)
    $Insert_Into = GUICtrlCreateButton("Bei Auswahl einfügen",20,110,150,25)
    $GetAllText = GUICtrlCreateButton("Strings auslesen",20,150,150,25)
    $ListBox = _GUICtrlListBox_Create($hGUI,"",270,20,160,160,BitOR($WS_HSCROLL, $WS_VSCROLL, $WS_BORDER))
    _GUICtrlListBox_AddString($ListBox,"1")
    _GUICtrlListBox_AddString($ListBox,"2")
    _GUICtrlListBox_AddString($ListBox,"3")
    _GUICtrlListBox_AddString($ListBox,"4")
    GUISetState()

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

    While 1 * Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Delete_Selected
    _GUICtrlListBox_DeleteString($ListBox,_GUICtrlListBox_GetCurSel($ListBox))
    Case $Delete_All
    _GUICtrlListBox_ResetContent($ListBox)
    Case $Insert_Into
    _GUICtrlListBox_InsertString($ListBox,"Hallo",_GUICtrlListBox_GetCurSel($ListBox))
    Case $GetAllText
    MsgBox(0,"",_GetListBoxText($ListBox))
    Case -3
    Exit
    EndSwitch

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

    WEnd
    Func _GetListBoxText($hWnd)
    Local $Return
    For $i = 0 To _GUICtrlListBox_GetCount($hWnd)-1
    $Return &= _GUICtrlListBox_GetText($hWnd,$i)&"|"
    Next
    Return StringTrimRight($Return,1)
    EndFunc

    [/autoit]
  • Wieso ist eine Struct größer als ihre definitierte Größe?

    • SEuBo
    • 14. Dezember 2009 um 21:59

    Also vorweg: ich habe von sowas generall keinen Schimmer, trotzdem muss ich wie immer meinen Senf dazu geben. Ich nehme als Beispiel mal eine Handelsübliche Festplatte. Wie du sicherlich weisst, ist so eine Festplatte in Sektoren unterteilt. Hat man nun zum Beispiel eine Sektorengröße von 32 Byte, und speichert eine 5 Byte Datei auf der Festplatte, so belegt diese winzige Datei trotzdem die vollen 32 Byte. Vielleicht ist es bei einer Struct so, dass das größte Element die "Sektorengröße" angibt. Nur so ein Gedanke, kenne mich da wie gesagt nicht so gut aus.

  • Hilfe mit 2 Gui s

    • SEuBo
    • 14. Dezember 2009 um 21:48
    Zitat von zausel3112

    geht auch gut aber nur einmal

    und zwar funktioniert das ganze nur einmal, weil du $Stein, also die Variable, die die Control ID deines Buttons beinhaltet, mit einem neuen Wert überschreibst. Im prinzip sollte die Funktion danach mit einem der vorher erstellten Buttons oder Lables funktionieren.

    Hier mal ein Beispiel: Die Funktion startet zuerst, wenn man Button 3 drückt.
    Danach wird der Wert in $Button3 geändert. Nun funktioniert die Funktion nur noch wenn man Button 1 drückt. Da $Button3 nun eine andere Control ID als die des ursprünglichen Buttons beinhaltet (hoffe das war verständlich)

    Spoiler anzeigen
    [autoit]


    $hGUI = GUICreate("Button321",280,100)
    $Button1 = GUICtrlCreateButton("",20,30,70,25)
    GUICtrlSetData(-1,$Button1); Ich schreibe auf die Buttons die jeweiligen Control ID's (nur zum verständniss)
    $Button2 = GUICtrlCreateButton("",100,30,70,25)
    GUICtrlSetData(-1,$Button2); Ich schreibe auf die Buttons die jeweiligen Control ID's (nur zum verständniss)
    $Button3 = GUICtrlCreateButton("",180,30,70,25)
    GUICtrlSetData(-1,$Button3); Ich schreibe auf die Buttons die jeweiligen Control ID's (nur zum verständniss)
    GUISetState()

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

    While 1 * Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button3
    MsgBox(0,"","Vorher: "&$Button3&", jetzt 3")
    $Button3 = 3
    Case -3
    Exit
    EndSwitch

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

    WEnd

    [/autoit]
  • Funktion erzeugen durch Button-Klicks

    • SEuBo
    • 14. Dezember 2009 um 21:05

    So hier?

    Spoiler anzeigen
    [autoit]

    Global $Return

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

    $hGUI = GUICreate("Button321",450,200)
    $1 = GUICtrlCreateButton("Button 1",20,30,70,25)
    $2 = GUICtrlCreateButton("Button 2",100,30,70,25)
    $3 = GUICtrlCreateButton("Button 3",180,30,70,25)
    $Go = GUICtrlCreateButton("Okey",100,65,70,25)
    $Edit = GUICtrlCreateEdit("",270,20,160,160)
    GUISetState()

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

    While 1 * Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $1
    $Return &= "1"
    GUICtrlSetData($Edit,GUICtrlRead($Edit)&"1"&@CRLF)
    Case $2
    $Return &= "2"
    GUICtrlSetData($Edit,GUICtrlRead($Edit)&"2"&@CRLF)
    Case $3
    $Return &= "3"
    GUICtrlSetData($Edit,GUICtrlRead($Edit)&"3"&@CRLF)
    Case $Go
    MsgBox(0,"",$Return,1)
    $Return = ""
    GUICtrlSetData($Edit,"")
    Case -3
    Exit
    EndSwitch

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

    WEnd

    [/autoit]

    Oder so mit einer ListBox

    Spoiler anzeigen
    [autoit]

    #Include <GuiListBox.au3>

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

    Global $Return

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

    $hGUI = GUICreate("Button321",450,200)
    $1 = GUICtrlCreateButton("Button 1",20,30,70,25)
    $2 = GUICtrlCreateButton("Button 2",100,30,70,25)
    $3 = GUICtrlCreateButton("Button 3",180,30,70,25)
    $Go = GUICtrlCreateButton("Okey",100,65,70,25)
    $ListBox = _GUICtrlListBox_Create($hGUI,"",270,20,160,160,$LBS_NOSEL)
    GUISetState()

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

    While 1 * Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $1
    $Return &= "1"
    _GUICtrlListBox_AddString($ListBox,"1")
    Case $2
    $Return &= "2"
    _GUICtrlListBox_AddString($ListBox,"2")
    Case $3
    $Return &= "3"
    _GUICtrlListBox_AddString($ListBox,"3")
    Case $Go
    MsgBox(0,"",$Return,1)
    $Return = ""
    _GUICtrlListBox_ResetContent($ListBox)
    Case -3
    Exit
    EndSwitch

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

    WEnd

    [/autoit]
  • CPU Last steigt auf 100% obwohl das GUI noch nicht arbeiten muss.

    • SEuBo
    • 14. Dezember 2009 um 20:50

    Einfach statt

    [autoit]

    While 1

    [/autoit]

    das hier

    [autoit]

    While 1 * sleep(20)

    [/autoit]


    Zitat

    Nein, dadran kann es nicht liegen. GuiGetMsg() bewirkt defacto auch ein Sleep().


    Doch, daran liegt es aber. Da geb ich dir Brief und Siegel drauf!

  • Prob -,-

    • SEuBo
    • 14. Dezember 2009 um 20:49

    Müsste dann

    [autoit]

    GUICtrlCreateButton ("",$Breitea,20)

    [/autoit]


    nicht eher

    [autoit]

    GUICtrlCreateButton ("",20,$Breitea)

    [/autoit]


    sein?

  • Funktion erzeugen durch Button-Klicks

    • SEuBo
    • 14. Dezember 2009 um 20:41

    Leider musst du da etwas konkreter werden, denn mit dem 123-Beispiel verbinde ich dann sowas hier:

    Spoiler anzeigen
    [autoit]

    Global $Return

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

    $hGUI = GUICreate("Button321",280,100)
    $1 = GUICtrlCreateButton("Button 1",20,30,70,25)
    $2 = GUICtrlCreateButton("Button 2",100,30,70,25)
    $3 = GUICtrlCreateButton("Button 3",180,30,70,25)
    $Go = GUICtrlCreateButton("Okey",100,65,70,25)
    GUISetState()

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

    While 1 * Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $1
    $Return &= "1"
    Case $2
    $Return &= "2"
    Case $3
    $Return &= "3"
    Case $Go
    MsgBox(0,"",$Return,1)
    $Return = ""
    Case -3
    Exit
    EndSwitch

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

    WEnd

    [/autoit]
  • Hilfe bei Arrays gesucht

    • SEuBo
    • 14. Dezember 2009 um 15:29
    Zitat von retrokid


    bitte schreib mir eine funktion die klappt :!:

    LOL

  • $GUI_Focus

    • SEuBo
    • 14. Dezember 2009 um 14:58

    'tschudligung. 2te Zeile muss so lauten:

    [autoit]

    If ControlGetHandle("","",ControlGetFocus("")) <> ControlGetHandle($GUI,"",$ispeed) Then GuiCtrlSetData($ispeed, $was[0])

    [/autoit]

    Und hier kannste es direkt testen:

    Spoiler anzeigen
    [autoit]

    HotKeySet("{-}","_hks")

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

    $hGUI = GUICreate("Test",300,200)
    $Input = GUICtrlCreateInput("",20,50,150,25)
    GUISetState()
    While 1
    Sleep(10)
    WEnd
    Func _hks()
    If ControlGetHandle("","",ControlGetFocus("")) <> ControlGetHandle($hGUI,"",$Input) Then MsgBox(0,"","Control hat keinen Focus!")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • Link einer Internetseite im TrayTip

    • SEuBo
    • 14. Dezember 2009 um 14:29
    Zitat von m-obi

    weil es ja eben bei HotKeySet keine Maustasten gibt


    _MouseSetOnEvent() UDF! Just like HotKeySet, but this one is for the mouse

  • $GUI_Focus

    • SEuBo
    • 14. Dezember 2009 um 14:28
    [autoit]

    If Not GuiCtrlGetState(BitAND($ispeed,$GUI_FOCUS)) = $GUI_FOCUS Then GuiCtrlSetData($ispeed, $was[0])
    ; oder so
    If ControlGetFocus(WinGetHandle("")) <> ControlGetHandle($GUI,"",$ispeed) Then GuiCtrlSetData($ispeed, $was[0])

    [/autoit]

    Alle angaben ohne gewähr

  • Hilfe mit 2 Gui s

    • SEuBo
    • 14. Dezember 2009 um 14:24

    @Calypso: Das wird so nur mäßig funktionieren. Das liegt am Verhalten von GUIGetMsg. Liefert GUIGetMsg einen leerstring zurück, so drosselt es die Hauptschleife. Wenn bei dir in der While Schleife nichts passiert, wird gleich doppelt gedrosselt. Deswegen wird deine Variante das Script ungemein verlangsamen, und die Buttons werden nur träge reagieren.

  • Hilfe mit 2 Gui s

    • SEuBo
    • 14. Dezember 2009 um 14:13

    Du hattest zwar die Struktur in der While Schleife für erweiterten GUIGetMsg-Mode schon drin, aber du hattest den erweiterten Modus nicht aktiviert. (GUIGetMsg(1) müsste es richtigerweise heißen). Außerdem hattest du eine Variable $msg[0], die aber $nMsg[0] hätte heißen müssen.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    $Start = GUICtrlCreateButton("Start", 192, 280, 217, 97, 0)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $Pic1 = GUICtrlCreatePic("bsp1.jpg", 64, 40, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("bsp2.jpg", 256, 40, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("bsp3.jpg", 456, 40, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))

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

    $Form2 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    GUICtrlSetFont(-1, 25, 400, 0, "")
    $1 = GUICtrlCreateButton("bsp", 232, 120, 153, 41, 0)
    $Label = GUICtrlCreateLabel("Game", 168, 24, 286, 41)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $2 = GUICtrlCreateButton("bsp", 232, 176, 153, 41)
    $3 = GUICtrlCreateButton("bsp", 232, 232, 153, 41)
    $Back = GUICtrlCreateButton("Zurück", 470, 400, 153, 41)
    GUISetState(@SW_SHOW, $Form1)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    ExitLoop
    Case $Start
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    ;Case $Back
    ; MsgBox(0, '', 'Button 2 geklickt')
    Case $Back
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    EndSwitch
    WEnd
    GUIDelete($Form1)
    GUIDelete($Form2)

    [/autoit]
  • Skript löscht ständig Dateien

    • SEuBo
    • 14. Dezember 2009 um 13:27
    Zitat von achim89

    nene, ich hab keine logfile, es wird ja alles gelöscht ?(

    Dann schreib dein Log mal per ConsoleWrite - dann bist du schonmal ein stück schlauer.

    PS: mach anstatt den sleeps mal eine Variable rein, die anzeigt ob das Skript heute schon durchgelafuen ist. Damit es nicht 2 mal in einer Nacht läuft.

  • µit Light Dezember 2009

    • SEuBo
    • 14. Dezember 2009 um 13:23

    Das wär dann aber doof, immerhin wollen wir ja was eigenes schaffen...

    Mal ganz abgesehen davon, dass mein "Erinnerungs-Tool" langsam aber sicher zum vollwertigen Kalender mutiert.

  • Skript löscht ständig Dateien

    • SEuBo
    • 14. Dezember 2009 um 13:12

    Ich gehe jetzt mal davon aus, dass es ein Array ist.

    Datei_A.txt _______ Datei_A.txt
    Datei_B.txt _______ Datei_B.txt
    Datei_C.txt _______ Datei_C.txt

    Sobald sich da jetzt ein Element zwischenschiebt, stimmt die gesamte reihenfolge nicht mehr.
    Das führt dann Wahrscheinlcih zu fehlverhalten.

    Datei_A.txt _______ Datei_A.txt
    Datei_A2.txt _______ Datei_B.txt
    Datei_B.txt _______ Datei_C.txt
    Datei_C.txt

    [autoit]

    If $liste[$i] <> $alte_scans Then

    [/autoit]


    Solche Zeilen verstehe ich einfach nicht. Ist $alte_scans jetzt ein Ordner? Ein Array? Ein String?!

    Außerdem hast du doch ein Logfile erstellt. das sollte doch recht aufschlussreich sein, WANN der Fehler auftritt

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™