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

  • GDI+ Bitmap "trapezoid" zeichnen / DrawImage_4Points

    • UEZ
    • 18. November 2010 um 22:43

    Wie füllt denn ein Malprogramm zu was? Ich kenne mich zu wenig mit Gimp aus.

    Kann jemand mal so ein Trapez zeichnen und es mit dem Bild füllen?

    Gruß,
    UEZ

  • AntiSpeed hat B-Day

    • UEZ
    • 16. November 2010 um 19:45
    Code
    ,ggg,        gg                                                
    dP""Y8b       88                                                
    Yb, `88       88                                                
     `"  88       88                                                
         88aaaaaaa88                                                
         88"""""""88    ,gggg,gg  gg,gggg,    gg,gggg,    gg     gg 
         88       88   dP"  "Y8I  I8P"  "Yb   I8P"  "Yb   I8     8I 
         88       88  i8'    ,8I  I8'    ,8i  I8'    ,8i  I8,   ,8I 
         88       Y8,,d8,   ,d8b,,I8 _  ,d8' ,I8 _  ,d8' ,d8b, ,d8I 
         88       `Y8P"Y8888P"`Y8PI8 YY88888PPI8 YY88888PP""Y88P"888
                                  I8          I8               ,d8I'
                                  I8          I8             ,dP'8I 
                                  I8          I8            ,8"  8I 
                                  I8          I8            I8   8I 
                                  I8          I8            `8, ,8I 
                                  I8          I8             `Y8P"  
    
    
     ,ggggggggggg,                                                                         
    dP"""88""""""Y8,                    I8    ,dPYb,             8I                        
    Yb,  88      `8b                    I8    IP'`Yb             8I                        
     `"  88      ,8P  gg             88888888 I8  8I             8I                        
         88aaaad8P"   ""                I8    I8  8'             8I                        
         88""""Y8ba   gg    ,gggggg,    I8    I8 dPgg,     ,gggg,8I    ,gggg,gg  gg     gg 
         88      `8b  88    dP""""8I    I8    I8dP" "8I   dP"  "Y8I   dP"  "Y8I  I8     8I 
         88      ,8P  88   ,8'    8I   ,I8,   I8P    I8  i8'    ,8I  i8'    ,8I  I8,   ,8I 
         88_____,d8'_,88,_,dP     Y8, ,d88b, ,d8     I8,,d8,   ,d8b,,d8,   ,d8b,,d8b, ,d8I 
        88888888P"  8P""Y88P      `Y8 8P""Y8 88P     `Y8P"Y8888P"`Y8P"Y8888P"`Y8P""Y88P"888
                                                                                      ,d8I'
                                                                                    ,dP'8I 
                                                                                   ,8"  8I 
                                                                                   I8   8I 
                                                                                   `8, ,8I 
                                                                                    `Y8P"
    Alles anzeigen


    Gruß,
    UEZ

  • PNG als Gui (Transparent)

    • UEZ
    • 16. November 2010 um 15:39

    Probiere das mal:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #Include <WinAPI.au3>

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

    Global $hGUI, $hImage, $hGraphic, $hImage
    Global Const $SC_DRAGMOVE = 0xF012

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

    ; Create GUI
    $hGUI = GUICreate("Show PNG", 350, 550, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST)
    GUISetBkColor(0x01, $hGUI)
    GUISetState()
    _WinAPI_SetLayeredWindowAttributes($hGUI, 0x01, 0xFF, 3)

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

    ; Load PNG image
    _GDIPlus_StartUp()
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir& "\Trans.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)

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

    $Input1 = GUICtrlCreateInput("Input1", 156, 232, 121, 21)
    $Input2 = GUICtrlCreateInput("Input2", 156, 256, 121, 21)
    $Input3 = GUICtrlCreateInput("Input3", 156, 280, 121, 21)
    $Slider1 = GUICtrlCreateSlider(128, 312, 150, 45)
    $Button1 = GUICtrlCreateButton("Start", 208, 376, 75, 25)

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

    GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    ExitLoop
    Case $Button1
    ExitLoop
    Case $GUI_EVENT_PRIMARYDOWN
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndSwitch
    WEnd

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

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_ShutDown()
    Exit

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

    ; Draw PNG image
    Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
    _WinAPI_RedrawWindow($hGUI, 0, 0, 1)
    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]

    Gruß,
    UEZ

  • _arrayadd

    • UEZ
    • 14. November 2010 um 22:23

    Hier eine Variante auf die Schnelle erstellt:

    [autoit]


    #include <Array.au3>

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

    Dim $aPing[1]
    $aPing[0] = "www.google.de"

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

    AdlibRegister("Ping_Result", 5000)

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

    HotKeySet("{Esc}", "_Exit")

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

    While Sleep(100)
    WEnd

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

    Func Ping_Result()
    _ArrayAdd($aPing, Ping($aPing[0]))
    EndFunc

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

    Func _Exit()
    AdlibUnRegister("Ping_Result")
    _ArrayDisplay($aPing)
    Exit
    EndFunc

    [/autoit]

    Gruß,
    UEZ

  • Xenobiologist wird heute 31 Jahre

    • UEZ
    • 13. November 2010 um 16:43

    Auch von mir nachträglich:

    PHP
    .-. .-.   .--.    ,---.    ,---.   .-.   .-.
     | | | |  / /\ \   | .-.\   | .-.\   \ \_/ )/
     | `-' | / /__\ \  | |-' )  | |-' )   \   (_)
     | .-. | |  __  |  | |--'   | |--'     ) (   
     | | |)| | |  |)|  | |      | |        | |   
     /(  (_) |_|  (_)  /(       /(        /(_|   
    (__)              (__)     (__)      (__)  
     ,---.   ,-. ,---.     _______  .-. .-.  ,'|"\     .--.   .-.   .-.
     | .-.\  |(| | .-.\   |__   __| | | | |  | |\ \   / /\ \   \ \_/ )/
     | |-' \ (_) | `-'/     )| |    | `-' |  | | \ \ / /__\ \   \   (_)
     | |--. \| | |   (     (_) |    | .-. |  | |  \ \|  __  |    ) (   
     | |`-' /| | | |\ \      | |    | | |)|  /(|`-' /| |  |)|    | |   
     /( `--' `-' |_| \)\     `-'    /(  (_) (__)`--' |_|  (_)   /(_|   
    (__)             (__)          (__)                        (__)
    Alles anzeigen

    Gruß,
    UEZ

  • AutoBert hat Geburtstag

    • UEZ
    • 13. November 2010 um 15:53

    Auch von mir ein

    PHP
    ,--,                                                 
          ,--.'|                                                 
       ,--,  | :               ,-.----.   ,-.----.               
    ,---.'|  : '               \    /  \  \    /  \              
    |   | : _' |               |   :    | |   :    |             
    :   : |.'  |    ,--.--.    |   | .\ : |   | .\ :       .--,  
    |   ' '  ; :   /       \   .   : |: | .   : |: |     /_ ./|  
    '   |  .'. |  .--.  .-. |  |   |  \ : |   |  \ :  , ' , ' :  
    |   | :  | '   \__\/: . .  |   : .  | |   : .  | /___/ \: |  
    '   : |  : ;   ," .--.; |  :     |`-' :     |`-'  .  \  ' |  
    |   | '  ,/   /  /  ,.  |  :   : :    :   : :      \  ;   :  
    ;   : ;--'   ;  :   .'   \ |   | :    |   | :       \  \  ;  
    |   ,/       |  ,     .-./ `---'.|    `---'.|        :  \  \ 
    '---'         `--`---'       `---`      `---`         \  ' ; 
                                                           `--`  
    
        ,---,.                          ___       ,---,                                           
      ,'  .'  \   ,--,                ,--.'|_   ,--.' |           ,---,                           
    ,---.' .' | ,--.'|      __  ,-.   |  | :,'  |  |  :         ,---.'|                           
    |   |  |: | |  |,     ,' ,'/ /|   :  : ' :  :  :  :         |   | :                           
    :   :  :  / `--'_     '  | |' | .;__,'  /   :  |  |,--.     |   | |    ,--.--.          .--,  
    :   |    ;  ,' ,'|    |  |   ,' |  |   |    |  :  '   |   ,--.__| |   /       \       /_ ./|  
    |   :     \ '  | |    '  :  /   :__,'| :    |  |   /' :  /   ,'   |  .--.  .-. |   , ' , ' :  
    |   |   . | |  | :    |  | '      '  : |__  '  :  | | | .   '  /  |   \__\/: . .  /___/ \: |  
    '   :  '; | '  : |__  ;  : |      |  | '.'| |  |  ' | : '   ; |:  |   ," .--.; |   .  \  ' |  
    |   |  | ;  |  | '.'| |  , ;      ;  :    ; |  :  :_:,' |   | '/  '  /  /  ,.  |    \  ;   :  
    |   :   /   ;  :    ;  ---'       |  ,   /  |  | ,'     |   :    :| ;  :   .'   \    \  \  ;  
    |   | ,'    |  ,   /               ---`-'   `--''        \   \  /   |  ,     .-./     :  \  \ 
    `----'       ---`-'                                       `----'     `--`---'          \  ' ; 
                                                                                            `--`  
                              _       
                             ( `.     
     ,.--.                    '. \    
    //    \                     \ \   
    \\    /   ,.----------.      \ \  
     `'--'   //            \      ' . 
     ,.--.   \\            /      | | 
    //    \   `'----------'       ' ' 
    \\     |                     / /  
     `'-) /                     / /   
       /.'                    .' /    
                             (_.'
    Alles anzeigen


    Gruß,
    UEZ

  • GDI+ Bitmap "trapezoid" zeichnen / DrawImage_4Points

    • UEZ
    • 13. November 2010 um 11:42

    Was soll ich da noch sagen? TOP :thumbup:

    "Die Pfade" scheinen richtig mächtig zu sein, wenn man weiß, wie sie funktionieren! :whistling:

    Die Direct2D / Direct3D Sachen sind ja auch krass und da ist bereits diese Funktion enthalten, aber der Kick ist es, dass in GDI+ zu implementieren! :D

    Die Symbiose von GDI+ und ASM würde den Turbo einschalten, aber muss man erst mal ASM können...

    Gruß,
    UEZ

  • _GetMinMaxNumber kleinsten, größten Wert aus Singlevariablen und/oder 1D-Arrays ermitteln

    • UEZ
    • 12. November 2010 um 21:59

    So was meine ich:

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>

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

    $numbers = "40,3,-2.5,-10,1000,-20202.188, +50,-1.937462,3.14"
    ConsoleWrite("Fünftkleinste Zahl: " & nNumber($numbers, 5, 0) & @CRLF) ; fünftkleinste Zahl
    ConsoleWrite("Drittgrößte Zahl: " & nNumber($numbers, 3, 1) & @CRLF) ; drittgrößte Zahl

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

    ; #FUNCTION# =====================================================================================================================
    ; Name...........: nNumber
    ; Description ...: Returns the n biggest or smallest number
    ; Syntax.........: nNumber($numbers, $n, $dir = 0)
    ; Parameters ....: $numbers - the numbers either from a string or from an array
    ; $n - search for n biggest or smallest number where n is an integer
    ; $dir - 0 search for smallest number, 1 for biggest number
    ; Return values .: Success - Returns the appropriate number and set @error to 0
    ; Failure - Returns error code:
    ; 1 - Wrong delimiter in string! Valid is comma (,) only!
    ; 2 - No numbers found!
    ; 3 - n is not an integer
    ; 4 - n is not in boundary of amount of numbers
    ; Remarks .......: Needs the function CompSort() for sorting the internal array
    ; Author ........: UEZ
    ; Version .......: 0.90 Build 2010-11-11 Beta
    ; ================================================================================================================================
    Func nNumber($numbers, $n, $dir = 0)
    If IsArray($numbers) Then
    $num = _ArrayToString($numbers, ",")
    If @error Then Return SetError(1, 0, "Error! Wrong delimiter in string! Valide is comma (,) only!")
    $numbers = $num
    EndIf
    Local $aNum = StringRegExp($numbers, "(-\d+\.\d+|\d+\.\d+|\d+)", 3)
    If Not IsArray($aNum) Then Return SetError(2, 0, "Error! No numbers found!")
    If Not IsInt($n) Then Return SetError(3, 0, "Error! n is not an integer")
    If $n < 1 Or $n > UBound($aNum) - 1 Then Return SetError(4, 0, "Error! n is not in boundary of amount of numbers")
    CompSort($aNum)
    If Not $dir Then Return SetError(0, 0, $aNum[$n - 1]) ;n smallest number
    Return SetError(0, 0, $aNum[UBound($aNum) - $n]) ;n biggest number
    EndFunc

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

    ;Die Komplexität liegt je nach Ausgangssituation zwischen O(n^2) (Worst-Case) und O(n*log(n)) (Best-Case).
    ;Im Best-Case ist die Liste der zu sortierenden Elemente geordnet, sobald die Schrittlänge 1 beträgt.
    ;Im Worst-Case müssen alle benachbarten Elemente nochmals getauscht werden (mehrere Durchgänge mit Schrittlänge 1).
    ;In diesem Fall ist Combsort nicht schneller als Bubblesort.
    ;Speicherverbrauch: O(c)
    ;Shrink-Faktor: 1/(1-1/e^phi) = 1.247330950103979, phi = 1.61803398874994
    Func CompSort(ByRef $aArray)
    Local $gap = UBound($aArray)
    Local $swaps, $i, $tmp
    Do
    $gap = Int($gap / 1.247330950103979)
    If $gap < 1 Then $gap = 1
    $i = 0
    $swaps = 0
    Do
    If Number($aArray[$i]) > Number($aArray[$i + $gap]) Then
    $tmp= Number($aArray[$i])
    $aArray[$i] = Number($aArray[$i + $gap])
    $aArray[$i + $gap] = $tmp
    $swaps = 1
    EndIf
    $i += 1
    Until $i + $gap > UBound($aArray) - 1
    Until $gap = 1 And $swaps = 0
    EndFunc

    [/autoit]

    Der Sortieralg. ist nicht der Schnellste. ;)

    Gruß,
    UEZ

  • _GetMinMaxNumber kleinsten, größten Wert aus Singlevariablen und/oder 1D-Arrays ermitteln

    • UEZ
    • 12. November 2010 um 14:40

    Eigentlich meine ich, dass du ein String oder ein Array übergibst und du z.B. die 7 größte oder 4 kleinste Zahl haben willst .

    Gruß,
    UEZ

  • stringregexp StringBetween

    • UEZ
    • 12. November 2010 um 12:42

    Hier noch eine Variante:

    [autoit]


    StringRegExp($string, '"solltexttable">(.\d+)</span', 3)

    [/autoit]

    Gruß,
    UEZ

  • _GetMinMaxNumber kleinsten, größten Wert aus Singlevariablen und/oder 1D-Arrays ermitteln

    • UEZ
    • 12. November 2010 um 11:56

    Warum hast du nicht das Ganze allgemein gehalten, also z.B. für die n größte bzw. kleinste Zahl? ;)

    Gruß,
    UEZ

  • suche jemanden für nen treiber - ich hoffe ich hab das hier alles richtig verstanden .

    • UEZ
    • 11. November 2010 um 00:34

    Einen Treiber mit AutoIt schreiben? ?(

    Wer das schafft, ist wirklich krank... 8)

    Gruß,
    UEZ

  • ArrayUnique ohne Bug´s und Schneller

    • UEZ
    • 10. November 2010 um 22:28

    Habe auch mal was gebastelt:

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    ;~ Dim $aNames[10][2] = [["Anton", ""], ["Berta", 15]]
    Dim $aNames[10] = ["Antonia", "Anton", "Cäsar", "Dora", "Emil", "Friedrich", "Gustav", "Heinrich", "Ida", "Julius"]

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

    Dim $aUnique[100000]
    For $I = 0 To Ubound($aUnique) - 1
    $r = Random(0, 9, 1)
    $aUnique[$I] = $aNames[$r]
    Next

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

    $ts = TimerInit()
    $test = ArrayUnique($aUnique)
    $te = TimerDiff($ts)
    ConsoleWrite(Round($te, 2) & " ms." & @CRLF)
    _ArrayDisplay($test)

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

    Dim $aNames[10][2] = [["Antonia", ""], ["Anton", ""], ["Cäsar", 300], ["Dora", 24], ["Emil", 33], ["Friedrich", 57], ["Gustav", 53], ["Heinrich", 34], ["Ida", 13], ["Julius", 77]]
    Dim $aUnique[100000][2]
    For $I = 0 To Ubound($aUnique) - 1
    $r = Random(0, 9, 1)
    $aUnique[$I][0] = $aNames[$r][0]
    $aUnique[$I][1] = $aNames[$r][1]
    Next

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

    $ts = TimerInit()
    $test = ArrayUnique($aUnique)
    $te = TimerDiff($ts)
    ConsoleWrite(Round($te, 2) & " ms." & @CRLF)
    _ArrayDisplay($test)

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

    ; #FUNCTION# =====================================================================================================================
    ; Name.............: ArrayUnique
    ; Description ...: Returns the Unique Elements of a 1-dimensional or 2-dimensional array.
    ; Syntax...........: _ArrayUnique($aArray[, $iBase = 0, oBase = 0, $iCase = 0])
    ; Parameters ...: $aArray - The Array to use
    ; $iBase - [optional] Is the input Array 0-base or 1-base index. 0-base by default
    ; $oBase - [optional] Is the output Array 0-base or 1-base index. 0-base by default
    ; $iCase - [optional] Flag to indicate if the operations should be case sensitive.
    ; 0 = not case sensitive, using the user's locale (default)
    ; 1 = case sensitive
    ; 2 = not case sensitive, using a basic/faster comparison
    ; Return values: Success - Returns a 1-dimensional or 2-dimensional array containing only the unique elements of that Dimension
    ; Failure - Returns 0 and Sets @Error:
    ; 0 - No error.
    ; 1 - Returns 0 if parameter is not an array.
    ; 2 - Array has more than 2 dimensions
    ; 3 - Array is already unique
    ; 4 - when source array is selected as one base but UBound(array) - 1 <> array[0] / array[0][0]
    ; 5 - Scripting.Dictionary cannot be created for 1D array unique code
    ; Author .........: UEZ 2010 for 2D-array, Yashied for 1D-array (modified by UEZ)
    ; Version ........: 0.96 Build 2010-11-20 Beta
    ; ================================================================================================================================
    Func ArrayUnique($aArray, $iBase = 0, $oBase = 0, $iCase = 0)
    If Not IsArray($aArray) Then Return SetError(1, 0, 0) ;not an array
    If UBound($aArray, 0) > 2 Then Return SetError(2, 0, 0) ;array is greater than a 2D array
    If UBound($aArray) = $iBase + 1 Then Return SetError(3, 0, $aArray) ;array is already unique because of only 1 element
    Local $dim = UBound($aArray, 2), $i
    If $dim Then ;2D array
    If $iBase And UBound($aArray) - 1 <> $aArray[0][0] Then Return SetError(4, 0, 0)
    Local $oD = ObjCreate('Scripting.Dictionary')
    If @error Then Return SetError(5, 0, 0)
    Local $i, $j, $k = $oBase, $l, $s, $aTmp, $flag, $sSep = Chr(01)
    Local $aUnique[UBound($aArray)][$dim]
    If Not $oBase Then $flag = 2
    For $i = $iBase To UBound($aArray) - 1
    For $j = 0 To $dim - 1
    $s &= $aArray[$i][$j] & $sSep
    Next
    If Not $oD.Exists($s) And StringLen($s) > 3 Then
    $oD.Add($s, $i)
    $aTmp = StringSplit(StringTrimRight($s, 1), $sSep, 2)
    For $l = 0 To $dim - 1
    $aUnique[$k][$l] = $aTmp[$l]
    Next
    $k += 1
    EndIf
    $s = ""
    Next
    $oD.RemoveAll
    If $k > 0 Then
    If $oBase Then $aUnique[0][0] = $k - 1
    ReDim $aUnique[$k][$dim]
    Else
    ReDim $aUnique[1][$dim]
    EndIf
    Else ;1D array
    If $iBase And UBound($aArray) - 1 <> $aArray[0] Then Return SetError(4, 0, 0)
    Local $sData = '', $sSep = ChrW(160), $flag
    For $i = $iBase To UBound($aArray) - 1
    If Not IsDeclared($aArray[$i] & '$') Then
    Assign($aArray[$i] & '$', 0, 1)
    $sData &= $aArray[$i] & $sSep
    EndIf
    Next
    If Not $oBase Then $flag = 2
    Local $aUnique = StringSplit(StringTrimRight($sData, 1), $sSep, $flag)
    EndIf
    Return SetError(0, 0, $aUnique)
    EndFunc ;==>ArrayUnique

    [/autoit]

    Sollte auch für 2D Arrays funzen!

    Gruß,
    UEZ

    Dateien

    ArrayUnique - Example.au3 1,22 kB – 473 Downloads ArrayUnique.au3 3,2 kB – 483 Downloads
  • ArrayUnique ohne Bug´s und Schneller

    • UEZ
    • 10. November 2010 um 21:55

    Wer ist denn UZE? :P

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    Dim $aNames[10][2] = [["Anton", 33], ["Berta", 15], ["Cäsar", 300], ["Dora", 24], ["Emil", 33], ["Friedrich", 57], ["Gustav", 53], ["Heinrich", 34], ["Ida", 13], ["Julius", 77]]
    Dim $aUnique[1000][2]
    For $I = 0 To Ubound($aUnique) - 1
    $r = Random(0, 9, 1)
    $aUnique[$I][0] = $aNames[$r][0]
    $aUnique[$I][1] = $aNames[$r][1]
    Next
    $test2 = _ArrayUnique3($aUnique)
    _ArrayDisplay($test2)

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

    Func _ArrayUnique3(Const ByRef $aArray, $iDimension = 0, Const $iBase = 0, Const $iCase = 0, $vDelim = '|')
    If ($iDimension > 2) Or ($iDimension < 0) Then Return SetError(3, 0, -2)
    If Not IsArray($aArray) Then Return SetError(1, 0, -1)
    If ($vDelim = '|') Then $vDelim = Chr(01)
    Local $iUboundDim = UBound($aArray)
    Local $sHold
    If Not UBound($aArray, 2) Then
    For $I = $iBase To $iUboundDim - 1
    If Not StringInStr($sHold, $aArray[$I], $iCase) Then $sHold &= $aArray[$I] & $vDelim
    Next
    Else
    For $I = $iBase To $iUboundDim - 1
    If Not StringInStr($sHold, $aArray[$I][$iDimension], $iCase) Then $sHold &= $aArray[$I][$iDimension] & $vDelim
    Next
    EndIf
    If $sHold Then Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim, 2)
    Return SetError(2, 0, 0)
    EndFunc

    [/autoit]

    Ich bekomme nur ein 1D Array zurück!

    Gruß,
    UEZ

  • Array Ergenisse nur 1 mal

    • UEZ
    • 10. November 2010 um 17:04

    2D Arrays scheinen auch nicht zu funzen:

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    Dim $aNames[10][2] = [["Anton", 33], ["Berta", 15], ["Cäsar", 300], ["Dora", 24], ["Emil", 33], ["Friedrich", 57], ["Gustav", 53], ["Heinrich", 34], ["Ida", 13], ["Julius", 77]]
    Dim $aUnique[1000][2]
    For $I = 0 To Ubound($aUnique) - 1
    $r = Random(0, 9, 1)
    $aUnique[$I][0] = $aNames[$r][0]
    $aUnique[$I][1] = $aNames[$r][1]
    Next
    _ArrayDisplay($aUnique, "Vorher")
    Dim $T1 = 0, $T2 = 0
    For $I = 1 To 20
    $T = TimerInit()
    $aTemp1 = ___ArrayUnique($aUnique, 1, 1)
    $T1 += TimerDiff($T)
    $T = TimerInit()
    $aTemp2 = _ArrayUnique($aUnique, 1, 1)
    $T2 += TimerDiff($T)
    Next
    _ArrayDisplay($aTemp1, Round($T1) & " ms")
    _ArrayDisplay($aTemp2, Round($T2) & " ms")
    Exit

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _ArrayUnique
    ; Description ...: Returns the Unique Elements of a 1-dimensional array.
    ; Syntax.........: _ArrayUnique($aArray[, $iDimension = 1[, $iBase = 0[, $iCase = 0[, $vDelim = "|"]]]])
    ; Parameters ....: $aArray - The Array to use
    ; $iDimension - [optional] The Dimension of the Array to use
    ; $iBase - [optional] Is the Array 0-base or 1-base index. 0-base by default
    ; $iCase - [optional] Flag to indicate if the operations should be case sensitive.
    ; 0 = not case sensitive, using the user's locale (default)
    ; 1 = case sensitive
    ; 2 = not case sensitive, using a basic/faster comparison
    ; $vDelim - [optional] One or more characters to use as delimiters. However, cannot forsee its usefullness
    ; Return values .: Success - Returns a 1-dimensional array containing only the unique elements of that Dimension
    ; Failure - Returns 0 and Sets @Error:
    ; 0 - No error.
    ; 1 - Returns 0 if parameter is not an array.
    ; 2 - _ArrayUnique failed for some other reason
    ; 3 - Array dimension is invalid, should be an integer greater than 0
    ; Author ........: SmOke_N
    ; Modified.......: litlmike
    ; Remarks .......: Returns an array, the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the unique strings.
    ; Related .......: _ArrayMax, _ArrayMin
    ; Link ..........:
    ; Example .......: Yes
    ; ===============================================================================================================================
    Func ___ArrayUnique($aArray, $iDimension = 1, $iBase = 0, $iCase = 0, $vDelim = "|")
    Local $iUboundDim
    ;$aArray used to be ByRef, but litlmike altered it to allow for the choosing of 1 Array Dimension, without altering the original array
    If $vDelim = "|" Then $vDelim = Chr(01) ; by SmOke_N, modified by litlmike
    If Not IsArray($aArray) Then Return SetError(1, 0, 0) ;Check to see if it is valid array

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

    ;Checks that the given Dimension is Valid
    If Not $iDimension > 0 Then
    Return SetError(3, 0, 0) ;Check to see if it is valid array dimension, Should be greater than 0
    Else
    ;If Dimension Exists, then get the number of "Rows"
    $iUboundDim = UBound($aArray, 1) ;Get Number of "Rows"
    If @error Then Return SetError(3, 0, 0) ;2 = Array dimension is invalid.
    ;Declare blank array, which will hold the dimension declared by user
    Local $aArrayTmp[$iUboundDim]
    ;If $iDimension Exists, And the number of "Rows" is Valid:
    If $iDimension > 1 Then ;Makes sure the Array dimension desired is more than 1-dimensional
    For $i = 0 To $iUboundDim - 1 ;Loop through "Rows"
    $aArrayTmp[$i] = $aArray[$i][$iDimension - 1] ;$iDimension-1 to match Dimension
    Next
    Else ;Makes sure the Array dimension desired is 1-dimensional
    ;If Dimension Exists, And the number of "Rows" is Valid, and the Dimension desired is not > 1, then:
    ;For the Case that the array is 1-Dimensional
    If UBound($aArray, 0) = 1 Then ;Makes sure the Array is only 1-Dimensional
    ;~ For $i = 0 To $iUboundDim - 1
    ;~ $aArrayTmp[$i] = $aArray[$i]
    ;~ Next
    $aArrayTmp = $aArray
    Else ;For the Case that the array is 2-Dimensional
    For $i = 0 To $iUboundDim - 1
    $aArrayTmp[$i] = $aArray[$i][$iDimension - 1] ;$iDimension-1 to match Dimension
    Next
    EndIf
    EndIf
    EndIf

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

    Local $sHold ;String that holds the Unique array info
    For $iCC = $iBase To UBound($aArrayTmp) - 1 ;Loop Through array
    ;If Not the case that the element is already in $sHold, then add it
    If Not StringInStr($vDelim & $sHold, $vDelim & $aArrayTmp[$iCC] & $vDelim, $iCase) Then _
    $sHold &= $aArrayTmp[$iCC] & $vDelim
    Next
    If $sHold Then
    $aArrayTmp = StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim, 2 - $iBase) ;Split the string into an array
    Return $aArrayTmp ;SmOke_N's version used to Return SetError(0, 0, 0)
    EndIf
    Return SetError(2, 0, 0) ;If the script gets this far, it has failed
    EndFunc ;==>_ArrayUnique

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

    Func ____ArrayUnique(Const ByRef $aArray, $iDimension = 1, Const $iBase = 0, Const $iCase = 0, $vDelim = "|")
    If Not IsArray($aArray) Then Return SetError(1, 0, 0)
    If Not $iDimension Then Return SetError(3, 0, 0)
    If ($vDelim = '|') Then $vDelim = Chr(01)
    Local $iUboundDim = UBound($aArray)
    Local $sHold
    If (UBound($aArray, 0) = 1) Then
    For $I = $iBase To $iUboundDim - 1
    If Not StringInStr($sHold, $aArray[$I], $iCase) Then $sHold &= $aArray[$I] & $vDelim
    Next
    Else
    For $I = $iBase To $iUboundDim - 1
    If Not StringInStr($sHold, $aArray[$I][$iDimension - 1], $iCase) Then $sHold &= $aArray[$I][$iDimension - 1] & $vDelim
    Next
    EndIf
    If $sHold Then Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim, 2)
    Return SetError(2, 0, 0)
    EndFunc ;==>___ArrayUnique

    [/autoit]


    Wenn ich Zeit finde, bastele ich an einer ArrayUnique Funktion.

    Gruß,
    UEZ

  • Array Ergenisse nur 1 mal

    • UEZ
    • 9. November 2010 um 21:27

    Ich habe mir mal die _ArrayUnique() Funktion genauer angeschaut und es sieht nach einem Bug aus:

    [autoit]


    ...
    If $sHold Then
    $aArrayTmp = StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim, 1) ;Split the string into an array
    Return $aArrayTmp ;SmOke_N's version used to Return SetError(0, 0, 0)
    EndIf
    ...

    [/autoit]

    Der Fehler liegt an dem StringSplit(), sollte so aussehen:

    [autoit]


    $aArrayTmp = StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim, 2 - $iBase) ;Split the string into an array

    [/autoit]

    Das Beispiel von oben:

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>

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

    Dim $aArray[10] = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
    _ArrayDisplay($aArray, "$aArray")
    $aNewArray = __ArrayUnique($aArray, 1, 0) ;Using Default Parameters
    _ArrayDisplay($aNewArray, "$aNewArray represents the 1st Dimension of $aArray")

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _ArrayUnique
    ; Description ...: Returns the Unique Elements of a 1-dimensional array.
    ; Syntax.........: _ArrayUnique($aArray[, $iDimension = 1[, $iBase = 0[, $iCase = 0[, $vDelim = "|"]]]])
    ; Parameters ....: $aArray - The Array to use
    ; $iDimension - [optional] The Dimension of the Array to use
    ; $iBase - [optional] Is the Array 0-base or 1-base index. 0-base by default
    ; $iCase - [optional] Flag to indicate if the operations should be case sensitive.
    ; 0 = not case sensitive, using the user's locale (default)
    ; 1 = case sensitive
    ; 2 = not case sensitive, using a basic/faster comparison
    ; $vDelim - [optional] One or more characters to use as delimiters. However, cannot forsee its usefullness
    ; Return values .: Success - Returns a 1-dimensional array containing only the unique elements of that Dimension
    ; Failure - Returns 0 and Sets @Error:
    ; 0 - No error.
    ; 1 - Returns 0 if parameter is not an array.
    ; 2 - _ArrayUnique failed for some other reason
    ; 3 - Array dimension is invalid, should be an integer greater than 0
    ; Author ........: SmOke_N
    ; Modified.......: litlmike
    ; Remarks .......: Returns an array, the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the unique strings.
    ; Related .......: _ArrayMax, _ArrayMin
    ; Link ..........:
    ; Example .......: Yes
    ; ===============================================================================================================================
    Func __ArrayUnique($aArray, $iDimension = 1, $iBase = 0, $iCase = 0, $vDelim = "|")
    Local $iUboundDim
    ;$aArray used to be ByRef, but litlmike altered it to allow for the choosing of 1 Array Dimension, without altering the original array
    If $vDelim = "|" Then $vDelim = Chr(01) ; by SmOke_N, modified by litlmike
    If Not IsArray($aArray) Then Return SetError(1, 0, 0) ;Check to see if it is valid array

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

    ;Checks that the given Dimension is Valid
    If Not $iDimension > 0 Then
    Return SetError(3, 0, 0) ;Check to see if it is valid array dimension, Should be greater than 0
    Else
    ;If Dimension Exists, then get the number of "Rows"
    $iUboundDim = UBound($aArray, 1) ;Get Number of "Rows"
    If @error Then Return SetError(3, 0, 0) ;2 = Array dimension is invalid.

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

    ;If $iDimension Exists, And the number of "Rows" is Valid:
    If $iDimension > 1 Then ;Makes sure the Array dimension desired is more than 1-dimensional
    Local $aArrayTmp[1] ;Declare blank array, which will hold the dimension declared by user
    For $i = 0 To $iUboundDim - 1 ;Loop through "Rows"
    _ArrayAdd($aArrayTmp, $aArray[$i][$iDimension - 1]) ;$iDimension-1 to match Dimension
    Next
    _ArrayDelete($aArrayTmp, 0) ;Get rid of 1st-element which is blank
    Else ;Makes sure the Array dimension desired is 1-dimensional
    ;If Dimension Exists, And the number of "Rows" is Valid, and the Dimension desired is not > 1, then:
    ;For the Case that the array is 1-Dimensional
    If UBound($aArray, 0) = 1 Then ;Makes sure the Array is only 1-Dimensional
    Dim $aArrayTmp[1] ;Declare blank array, which will hold the dimension declared by user
    For $i = 0 To $iUboundDim - 1
    _ArrayAdd($aArrayTmp, $aArray[$i])
    Next
    _ArrayDelete($aArrayTmp, 0) ;Get rid of 1st-element which is blank
    Else ;For the Case that the array is 2-Dimensional
    Dim $aArrayTmp[1] ;Declare blank array, which will hold the dimension declared by user
    For $i = 0 To $iUboundDim - 1
    _ArrayAdd($aArrayTmp, $aArray[$i][$iDimension - 1]) ;$iDimension-1 to match Dimension
    Next
    _ArrayDelete($aArrayTmp, 0) ;Get rid of 1st-element which is blank
    EndIf
    EndIf
    EndIf

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

    Local $sHold ;String that holds the Unique array info
    For $iCC = $iBase To UBound($aArrayTmp) - 1 ;Loop Through array
    ;If Not the case that the element is already in $sHold, then add it
    If Not StringInStr($vDelim & $sHold, $vDelim & $aArrayTmp[$iCC] & $vDelim, $iCase) Then _
    $sHold &= $aArrayTmp[$iCC] & $vDelim
    Next
    If $sHold Then
    $aArrayTmp = StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim, 2 - $iBase) ;Split the string into an array
    Return $aArrayTmp ;SmOke_N's version used to Return SetError(0, 0, 0)
    EndIf
    Return SetError(2, 0, 0) ;If the script gets this far, it has failed
    EndFunc ;==>_ArrayUnique

    [/autoit]


    Gruß,
    UEZ

  • Array Ergenisse nur 1 mal

    • UEZ
    • 9. November 2010 um 20:41

    Hier ein Workaround:

    [autoit]


    #include <Array.au3>
    Dim $aArray[10] = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
    _ArrayDisplay($aArray, "$aArray")
    $aNewArray = _ArrayUnique($aArray) ;Using Default Parameters
    _ArrayDelete($aNewArray, 0)
    _ArrayDisplay($aNewArray, "$aNewArray represents the 1st Dimension of $aArray")

    [/autoit]

    Beispiel ist aus der Hilfe.

    Gruß,
    UEZ

  • StringRegExp Tutorial / Reguläre Ausdrücke in AutoIt

    • UEZ
    • 9. November 2010 um 19:14
    Zitat von Oscar

    UEZ: So geht's

    [autoit]


    #include <Array.au3>
    $string = '14 124 AutoIt 4 283 Coding macht Spass 0815 Ende'
    $array = StringRegExp($string, '([^\d+|\h]+?)(?:\h|\z)', 3)
    _ArrayDisplay($array)

    [/autoit]

    Vielen Dank Oscar! :thumbup:

    Ich dachte da eher an einen "Schalter" in RegEx, der das Ergebnis im Prinzip umkehrt. Anscheinend gibt es diesen "Schalter" nicht!

    Gruß,
    UEZ

  • Was ist die schnellste Grafik(engine) ?

    • UEZ
    • 9. November 2010 um 15:34

    Nach meiner Meinung ist diese Frage irrelevant für AutoIt, da AutoIt der Flaschenhals ist! Ob man jetzt Direct2D, Direct3D, OpenGL, Irrlicht benutzt, ist teilweise eher geschmacksache, aber an der absoluten Geschwindigkeit wird sich nicht viel ändern.

    Wer in die Programmierung von 2D/3D Grafiken einsteigen will, sollte lieber eine andere Programmiersprachen nehmen (wie Andy bereits sagte)!

    Gruß,
    UEZ

  • StringRegExp Tutorial / Reguläre Ausdrücke in AutoIt

    • UEZ
    • 9. November 2010 um 15:26

    Alizame: Dass es anders geht, ist ja klar, aber wie geht es mit RegEx ist hier die Frage oder?

    Apropos Frage: kann man das Resultat umkehren (inventieren) für allgemeine reg. Ausdrücke?

    Z.B:
    14
    124
    AutoIt
    4
    283
    Coding
    macht
    Spaß
    0815

    Suche nach allen Zahlen mit RegEx und inventiere das Ergebnis, so dass man hier nur Wörter erhält!

    Warum suchst du nicht gleich nach Wörtern, wäre vielleicht eine Antwort! Aber wenn ich nicht weiß, dass es Wörter sind, aber ich weiß, dass es Zahlen sind, wäre es einfach nach dem Rest zu suchen!

    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™