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

Beiträge von TheLuBu

  • HotKeySet temporär deaktivieren | Abfrage ob ein Fester/Tab aktiv ist

    • TheLuBu
    • 14. Mai 2013 um 10:13

    Es geht auch mit HotkeySet:

    Spoiler anzeigen
    [autoit]

    Global $HotKeyArray[4][3]

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

    HotKeySet("{F1}", "ShowActiveHotkeys")

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

    $HotKeyArray[0][0] = "{F2}" ; Hotkey
    $HotKeyArray[0][1] = "Test2" ; Funktionsname
    $HotKeyArray[0][2] = "Unbenannt - Editor" ; Fenstername

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

    $HotKeyArray[1][0] = "{F3}"
    $HotKeyArray[1][1] = "Test3"
    $HotKeyArray[1][2] = "Fenstername"

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

    $HotKeyArray[2][0] = "{F4}"
    $HotKeyArray[2][1] = "Test4"
    $HotKeyArray[2][2] = "Fenstername"

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

    $HotKeyArray[3][0] = "{F5}"
    $HotKeyArray[3][1] = "Test5"
    $HotKeyArray[3][2] = "Fenstername"

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

    While 1
    Sleep(100)
    Updatehotkeys()
    WEnd

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

    Func ShowActiveHotkeys()
    For $I = 0 To UBound($HotKeyArray) -1

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

    If WinActive($HotKeyArray[$i][2], "") Then
    ConsoleWrite("Aktives Fenster: " &$HotKeyArray[$i][2] & @CRLF & "Aktiver Hotkey: " & $HotKeyArray[$i][0] & @CRLF & "Funktionsname: " & $HotKeyArray[$i][1] & @CRLF)
    EndIf
    Next
    EndFunc

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

    Func Updatehotkeys()
    For $I = 0 To UBound($HotKeyArray) -1
    If WinActive($HotKeyArray[$i][2], "") Then
    HotKeySet($HotKeyArray[$i][0], $HotKeyArray[$i][1])
    Else
    HotKeySet($HotKeyArray[$i][0])
    EndIf
    Next
    EndFunc

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

    Func Test2()
    MsgBox(0, "Test", "Test2")
    EndFunc

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

    Func Test3()
    MsgBox(0, "Test", "Test3")
    EndFunc

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

    Func Test4()
    MsgBox(0, "Test", "Test4")
    EndFunc

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

    Func Test5()
    MsgBox(0, "Test", "Test5")
    EndFunc

    [/autoit]
  • Custom Message Box

    • TheLuBu
    • 30. April 2013 um 16:36

    Wusst ich ja garnicht, ok danke dir :)

  • Custom Message Box

    • TheLuBu
    • 30. April 2013 um 14:13

    Beide Bugs wurden entfernt, siehe erste Post :)

  • Custom Message Box

    • TheLuBu
    • 30. April 2013 um 13:41
    Spoiler anzeigen
    [autoit]

    #include-once

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

    Local $asButtonarray[6] = ["OK", "Abbrechen", "Weiter", "Zurück", "Ignorieren", "Hinzufügen"]
    $t = CustomMsgBox("Custom Messagebox", "Ein wenig Text, nur zu Demozwecken" & @CRLF & "Funktionieren die Zeilenumbrüche?" & @CRLF & "Ich denke schon", $asButtonarray, -1, 3)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $t = ' & $t & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

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

    Func CustomMsgBox($sTitle, $sText, $asButtonarray = "", $iTimeout = "", $iIcon = -1, $sIconpath = "shell32.dll")
    Local $Useopt = Opt("GUIOnEventMode")
    Opt("GUIOnEventMode", 0)
    Local $h_CMBGUI, $iLeft = 12, $iTop = 25, $Timer, $iMsG, $iButtonTop, $iButtonLeft
    Local $iMaxStringWidth = 400, $aSize, $aControlPos, $iUseleft
    Local $iDefButton = -1, $cIcon, $avButtonHandleArray
    $h_CMBGUI = GUICreate($sTitle, 500, 500, -1, -1, 13107200) ;BitOR($WS_SYSMENU, $WS_CAPTION))
    If $iIcon >= 0 And $iIcon <= 3 Then
    $iLeft = 25
    $cIcon = GUICtrlCreateIcon($sIconpath, $iIcon, $iLeft, $iTop, 32, 32)
    GUICtrlSetBkColor($cIcon, 0xFFFFFF)
    GUICtrlSetResizing($cIcon, 802)
    $iLeft = 65
    $iTop = 34
    EndIf
    If IsArray($asButtonarray) Then
    If UBound($asButtonarray) > 6 Then $iMaxStringWidth = Ceiling(UBound($asButtonarray) / 2) * 100 + 100
    Local $avButtonHandleArray[UBound($asButtonarray)]
    EndIf
    $aSize = _StringSize($sText, Default, Default, Default, "", $iMaxStringWidth)
    If $aSize[3] > 17 Then $iTop = 25
    GUICtrlCreateLabel($aSize[0], $iLeft, $iTop, $aSize[2], $aSize[3])
    GUICtrlSetResizing(-1, 802)
    GUICtrlSetBkColor(-1, -2)
    If Not IsArray($asButtonarray) Then
    $iDefButton = GUICtrlCreateButton("Ok", ($iLeft + $aSize[2]) / 2 - 44, $iTop + $aSize[3], 88, 26)
    GUICtrlSetResizing(-1, 802)
    Else
    $iButtonTop = 0
    $iButtonLeft = 12
    For $i = 0 To UBound($asButtonarray) - 1
    $avButtonHandleArray[$i] = GUICtrlCreateButton($asButtonarray[$i], $iButtonLeft, $iTop + $aSize[3] + $iButtonTop, 88, 26)
    $iButtonLeft += 100
    If $i = Ceiling(UBound($asButtonarray) / 2) - 1 Then
    $iButtonTop += 30
    $iButtonLeft = 12
    EndIf
    GUICtrlSetResizing(-1, 802)
    Next
    EndIf
    If $iIcon >= 0 And $iIcon <= 3 Then
    If IsArray($asButtonarray) Then
    $aControlPos = ControlGetPos($h_CMBGUI, "", $avButtonHandleArray[Floor(UBound($asButtonarray) / 2) - 1])
    If $aControlPos[0] + $aControlPos[2] > $iLeft + $aSize[2] Then
    $iUseleft = $aControlPos[0] + $aControlPos[2] + 15
    Else
    $iUseleft = $iLeft + $aSize[2] + 15
    EndIf
    EndIf
    WinMove($h_CMBGUI, "", Default, Default, $iUseleft, $iTop * 2 + $aSize[3] + 35 + $iButtonTop)
    Else
    If IsArray($asButtonarray) Then
    $aControlPos = ControlGetPos($h_CMBGUI, "", $avButtonHandleArray[Floor(UBound($asButtonarray) / 2) - 1])
    If $aControlPos[0] + $aControlPos[2] > $aSize[2] Then
    $iUseleft = $aControlPos[0] + $aControlPos[2] + 15
    Else
    $iUseleft = $aSize[2] + 15
    EndIf
    EndIf
    WinMove($h_CMBGUI, "", Default, Default, $iUseleft, $iTop * 2 + $aSize[3] + 35 + $iButtonTop)
    EndIf
    GUISetState(@SW_SHOW, $h_CMBGUI)
    $Timer = TimerInit()
    While 1
    $iMsG = GUIGetMsg(1)
    Switch $iMsG[1]
    Case $h_CMBGUI
    Switch $iMsG[0]
    Case -3
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return 0
    Case $iDefButton
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return 1
    Case $avButtonHandleArray[0] To $avButtonHandleArray[UBound($avButtonHandleArray) - 1]
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return $iMsG[0] + 1 - $avButtonHandleArray[0]
    EndSwitch
    EndSwitch
    If $iTimeout > 0 Then
    If TimerDiff($Timer) > $iTimeout * 1000 Then
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return 0
    EndIf
    EndIf
    WEnd

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

    EndFunc ;==>CustomMsgBox

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

    ; #INDEX# ============================================================================================================
    ; Title .........: _StringSize
    ; AutoIt Version : v3.2.12.1 or higher
    ; Language ......: English
    ; Description ...: Returns size of rectangle required to display string - maximum width can be chosen
    ; Remarks .......:
    ; Note ..........:
    ; Author(s) .....: Melba23 - thanks to trancexx for the default DC code
    ; ====================================================================================================================

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

    ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

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

    ; #CURRENT# ==========================================================================================================
    ; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen
    ; ====================================================================================================================

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

    ; #INTERNAL_USE_ONLY#=================================================================================================
    ; _StringSize_Error_Close: Releases DC and deletes font object after error
    ; _StringSize_DefaultFontName: Determines Windows default font
    ; ====================================================================================================================

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

    ; #FUNCTION# =========================================================================================================
    ; Name...........: _StringSize
    ; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen
    ; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]])
    ; Parameters ....: $sText - String to display
    ; $iSize - [optional] Font size in points - (default = 8.5)
    ; $iWeight - [optional] Font weight - (default = 400 = normal)
    ; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike)
    ; + 1 if tabs are to be expanded before sizing
    ; $sName - [optional] Font name - (default = Tahoma)
    ; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string)
    ; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required)
    ; Requirement(s) : v3.2.12.1 or higher
    ; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set)
    ; |$array[0] = String reformatted with additonal @CRLF // Original string
    ; |$array[1] = Height of single line in selected font // idem
    ; |$array[2] = Width of rectangle required for reformatted // original string
    ; |$array[3] = Height of rectangle required for reformatted // original string
    ; Failure - Returns 0 and sets @error:
    ; |1 - Incorrect parameter type (@extended = parameter index)
    ; |2 - DLL call error - extended set as follows:
    ; |1 - GetDC failure
    ; |2 - SendMessage failure
    ; |3 - GetDeviceCaps failure
    ; |4 - CreateFont failure
    ; |5 - SelectObject failure
    ; |6 - GetTextExtentPoint32 failure
    ; |3 - Font too large for chosen max width - a word will not fit
    ; Author ........: Melba23 - thanks to trancexx for the default DC code
    ; Modified ......:
    ; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not
    ; return correct dimensions without it.
    ; Related .......:
    ; Link ..........:
    ; Example .......: Yes
    ;=====================================================================================================================
    Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hwnd = 0)

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

    ; Set parameters passed as Default
    If $iSize = Default Then $iSize = 8.5
    If $iWeight = Default Then $iWeight = 400
    If $iAttrib = Default Then $iAttrib = 0
    If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName()

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

    ; Check parameters are correct type
    If Not IsString($sText) Then Return SetError(1, 1, 0)
    If Not IsNumber($iSize) Then Return SetError(1, 2, 0)
    If Not IsInt($iWeight) Then Return SetError(1, 3, 0)
    If Not IsInt($iAttrib) Then Return SetError(1, 4, 0)
    If Not IsString($sName) Then Return SetError(1, 5, 0)
    If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0)
    If Not IsHWnd($hwnd) And $hwnd <> 0 Then Return SetError(1, 7, 0)

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

    Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle

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

    ; Check for tab expansion flag
    Local $iExpTab = BitAND($iAttrib, 1)
    ; Remove possible tab expansion flag from font attribute value
    $iAttrib = BitAND($iAttrib, BitNOT(1))

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

    ; If GUI handle was passed
    If IsHWnd($hwnd) Then
    ; Create label outside GUI borders
    $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10)
    $hLabel_Handle = GUICtrlGetHandle(-1)
    GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName)
    ; Create DC
    $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle)
    If @error Or $aRet[0] = 0 Then
    GUICtrlDelete($hLabel)
    Return SetError(2, 1, 0)
    EndIf
    $hDC = $aRet[0]
    $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont
    If @error Or $aRet[0] = 0 Then
    GUICtrlDelete($hLabel)
    Return SetError(2, _StringSize_Error_Close(2, $hDC), 0)
    EndIf
    $hFont = $aRet[0]
    Else
    ; Get default DC
    $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
    If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0)
    $hDC = $aRet[0]
    ; Create required font
    $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY
    If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0)
    Local $iInfo = $aRet[0]
    $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _
    "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _
    "dword", 0, "dword", 5, "dword", 0, "wstr", $sName)
    If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0)
    $hFont = $aRet[0]
    EndIf

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

    ; Select font and store previous font
    $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont)
    If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0)
    Local $hPrevFont = $aRet[0]

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

    ; Declare variables
    Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line
    ; Declare and fill Size structure
    Local $tSize = DllStructCreate("int X;int Y")
    DllStructSetData($tSize, "X", 0)
    DllStructSetData($tSize, "Y", 0)

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

    ; Ensure EoL is @CRLF and break text into lines
    $sText = StringRegExpReplace($sText, "((?<!\x0d)\x0a|\x0d(?!\x0a))", @CRLF)
    Local $asLines = StringSplit($sText, @CRLF, 1)

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

    ; For each line
    For $i = 1 To $asLines[0]
    ; Expand tabs if required
    If $iExpTab Then
    $asLines[$i] = StringReplace($asLines[$i], @TAB, " XXXXXXXX")
    EndIf
    ; Size line
    $iLine_Length = StringLen($asLines[$i])
    DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$i], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
    If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
    If DllStructGetData($tSize, "X") > $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X")
    If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y")
    Next

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

    ; Check if $iMaxWidth has been both set and exceeded
    If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required
    ; For each Line
    For $j = 1 To $asLines[0]
    ; Size line unwrapped
    $iLine_Length = StringLen($asLines[$j])
    DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
    If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
    ; Check wrap status
    If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then
    ; No wrap needed so count line and store
    $iLine_Count += 1
    $avSize_Info[0] &= $asLines[$j] & @CRLF
    Else
    ; Wrap needed so zero counter for wrapped lines
    $iWrap_Count = 0
    ; Build line to max width
    While 1
    ; Zero line width
    $iLine_Width = 0
    ; Initialise pointer for end of word
    $iLast_Word = 0
    ; Add characters until EOL or maximum width reached
    For $i = 1 To StringLen($asLines[$j])
    ; Is this just past a word ending?
    If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1
    ; Increase line by one character
    $sTest_Line = StringMid($asLines[$j], 1, $i)
    ; Get line length
    $iLine_Length = StringLen($sTest_Line)
    DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
    If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
    $iLine_Width = DllStructGetData($tSize, "X")
    ; If too long exit the loop
    If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop
    Next
    ; End of the line of text?
    If $i > StringLen($asLines[$j]) Then
    ; Yes, so add final line to count
    $iWrap_Count += 1
    ; Store line
    $avSize_Info[0] &= $sTest_Line & @CRLF
    ExitLoop
    Else
    ; No, but add line just completed to count
    $iWrap_Count += 1
    ; Check at least 1 word completed or return error
    If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0)
    ; Store line up to end of last word
    $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF
    ; Strip string to point reached
    $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word)
    ; Trim leading whitespace
    $asLines[$j] = StringStripWS($asLines[$j], 1)
    ; Repeat with remaining characters in line
    EndIf
    WEnd
    ; Add the number of wrapped lines to the count
    $iLine_Count += $iWrap_Count
    EndIf
    Next
    ; Reset any tab expansions
    If $iExpTab Then
    $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB)
    EndIf
    ; Complete return array
    $avSize_Info[1] = $iLine_Height
    $avSize_Info[2] = $iMaxWidth
    ; Convert lines to pixels and add drop margin
    $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4
    Else ; No wrapping required
    ; Create return array (add drop margin to height)
    Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4]
    EndIf

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

    ; Clear up
    DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont)
    DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont)
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC)
    If $hLabel Then GUICtrlDelete($hLabel)

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

    Return $avSize_Info

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

    EndFunc ;==>_StringSize

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

    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _StringSize_Error_Close
    ; Description ...: Releases DC and deleted font object if required after error
    ; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI)
    ; Parameters ....: $iExtCode - code to return
    ; $hDC, $hGUI - handles as set in _StringSize function
    ; Return value ..: $iExtCode as passed
    ; Author ........: Melba23
    ; Modified.......:
    ; Remarks .......: This function is used internally by _StringSize
    ; ===============================================================================================================================
    Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0)

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

    If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont)
    If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC)
    If $hLabel Then GUICtrlDelete($hLabel)

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

    Return $iExtCode

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

    EndFunc ;==>_StringSize_Error_Close

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

    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _StringSize_DefaultFontName
    ; Description ...: Determines Windows default font
    ; Syntax ........: _StringSize_DefaultFontName()
    ; Parameters ....: None
    ; Return values .: Success - Returns name of system default font
    ; Failure - Returns "Tahoma"
    ; Author ........: Melba23, based on some original code by Larrydalooza
    ; Modified.......:
    ; Remarks .......: This function is used internally by _StringSize
    ; ===============================================================================================================================
    Func _StringSize_DefaultFontName()

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

    ; Get default system font data
    Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]")
    DllStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS))
    DllCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0)
    Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DllStructGetPtr($tNONCLIENTMETRICS, 13))
    If IsString(DllStructGetData($tLOGFONT, 14)) Then
    Return DllStructGetData($tLOGFONT, 14)
    Else
    Return "Tahoma"
    EndIf

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

    EndFunc ;==>_StringSize_DefaultFontName

    [/autoit]

    Hab den Fehler grade auch bemerkt, das entsteht, wenn man kein Array übergibt :)

    Anbei die Korrektur

    Doch, du kannst entscheiden, wieviele Buttons du haben willst, es kommt drauf an, wie dein Array aussieht

  • Custom Message Box

    • TheLuBu
    • 30. April 2013 um 13:20

    Hallo liebe Community,
    Ich möchte euch jetzt mein neues Werk vorstellen, eine Custom Message Box.
    Ich benötigte für ein Projekt mehr als nur 3 Buttons zur Auswahl für eine Message Box.
    Nach einer mehr oder weniger gründlichen aber erfolglosen Suche, habe ich beschlossen,
    selbst eine Solche Funktion zu schreiben.

    Anbei seht ihr das Ergebnis:

    Spoiler anzeigen
    [autoit]

    #include-once

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

    ; #FUNCTION# ===================================================================================================================
    ; Name...........: CustomMsgBox()
    ; Description ...: Create a Custom Msgbox
    ; Syntax ........: CustomMsgBox($sTitle, $sText, $asButtonarray = "", $iTimeout = "", $iIcon = -1, $sIconpath = "shell32.dll")
    ; Parameters ....: $sTitle - Title for Messagebox
    ; $sText - [optional] Text for the Messagebox
    ; $asButtonarray - [optional] Array with Buttonnames to add to MsgBox
    ; $iTimeout - [optional] Timeout for MsgBox
    ; $iIcon - [optional] Iconnumber for the Messagebox
    ; $sIconpath - [optional] Where to find the Icon (Default shell32.dll)
    ; Return value ..: Button klicked
    ; Author ........: TheLuBu ([email='LuBu@veytal.com'][/email])
    ; Modified.......:
    ; Remarks .......:
    ; ===============================================================================================================================

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

    Func CustomMsgBox($sTitle, $sText, $asButtonarray = "", $iTimeout = "", $iIcon = -1, $sIconpath = "shell32.dll")
    Local $Useopt = Opt("GUIOnEventMode")
    Opt("GUIOnEventMode", 0)
    Local $h_CMBGUI, $iLeft = 12, $iTop = 25, $Timer, $iMsG, $iButtonTop, $iButtonLeft
    Local $iMaxStringWidth = 400, $aSize, $aControlPos, $iUseleft
    Local $iDefButton = -1, $cIcon, $avButtonHandleArray
    $h_CMBGUI = GUICreate($sTitle, 500, 500, -1, -1, 13107200) ;BitOR($WS_SYSMENU, $WS_CAPTION))
    GUISetIcon(@AutoItExe, -2, $h_CMBGUI)
    If $iIcon >= 0 And $iIcon <= 3 Then
    $iLeft = 25
    $cIcon = GUICtrlCreateIcon($sIconpath, $iIcon, $iLeft, $iTop, 32, 32)
    GUICtrlSetBkColor($cIcon, 0xFFFFFF)
    GUICtrlSetResizing($cIcon, 802)
    $iLeft = 65
    $iTop = 34
    EndIf
    If IsArray($asButtonarray) Then
    If UBound($asButtonarray) > 6 Then $iMaxStringWidth = Ceiling(UBound($asButtonarray) / 2) * 100 + 100
    Local $avButtonHandleArray[UBound($asButtonarray)]
    EndIf
    $aSize = _StringSize($sText, Default, Default, Default, "", $iMaxStringWidth)
    If $aSize[3] > 17 Then $iTop = 25
    GUICtrlCreateLabel($aSize[0], $iLeft, $iTop, $aSize[2], $aSize[3])
    GUICtrlSetResizing(-1, 802)
    GUICtrlSetBkColor(-1, -2)
    If Not IsArray($asButtonarray) Then
    $iDefButton = GUICtrlCreateButton("Ok", ($iLeft + $aSize[2]) / 2 - 44, $iTop + $aSize[3], 88, 26)
    GUICtrlSetResizing(-1, 802)
    Else
    $iButtonTop = 0
    $iButtonLeft = 12
    For $i = 0 To UBound($asButtonarray) - 1
    $avButtonHandleArray[$i] = GUICtrlCreateButton($asButtonarray[$i], $iButtonLeft, $iTop + $aSize[3] + $iButtonTop, 88, 26)
    $iButtonLeft += 100
    If $i = Ceiling(UBound($asButtonarray) / 2) - 1 Then
    $iButtonTop += 30
    $iButtonLeft = 12
    EndIf
    GUICtrlSetResizing(-1, 802)
    Next
    EndIf
    Local $iIndex
    If $iIcon >= 0 And $iIcon <= 3 Then
    If IsArray($asButtonarray) Then
    $iIndex = Floor(UBound($asButtonarray) / 2)
    If IsInt(UBound($asButtonarray)/2) Then $iIndex -= 1
    If $iIndex < 0 THen $iIndex = 0
    $aControlPos = ControlGetPos($h_CMBGUI, "", $avButtonHandleArray[$iIndex])
    If $aControlPos[0] + $aControlPos[2] > $iLeft + $aSize[2] Then
    $iUseleft = $aControlPos[0] + $aControlPos[2] + 15
    Else
    $iUseleft = $iLeft + $aSize[2] + 15
    EndIf
    EndIf
    WinMove($h_CMBGUI, "", Default, Default, $iUseleft, $iTop * 2 + $aSize[3] + 35 + $iButtonTop)
    Else
    If IsArray($asButtonarray) Then
    $iIndex = Floor(UBound($asButtonarray) / 2)
    If IsInt(UBound($asButtonarray)/2) Then $iIndex -= 1
    If $iIndex < 0 THen $iIndex = 0
    $aControlPos = ControlGetPos($h_CMBGUI, "", $avButtonHandleArray[$iIndex])
    If $aControlPos[0] + $aControlPos[2] > $aSize[2] Then
    $iUseleft = $aControlPos[0] + $aControlPos[2] + 15
    Else
    $iUseleft = $aSize[2] + 15
    EndIf
    EndIf
    WinMove($h_CMBGUI, "", Default, Default, $iUseleft, $iTop * 2 + $aSize[3] + 35 + $iButtonTop)
    EndIf
    GUISetState(@SW_SHOW, $h_CMBGUI)
    $Timer = TimerInit()
    While 1
    $iMsG = GUIGetMsg(1)
    Switch $iMsG[1]
    Case $h_CMBGUI
    Switch $iMsG[0]
    Case -3
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return 0
    Case $iDefButton
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return 1
    Case $avButtonHandleArray[0] To $avButtonHandleArray[UBound($avButtonHandleArray) - 1]
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return $iMsG[0] + 1 - $avButtonHandleArray[0]
    EndSwitch
    EndSwitch
    If $iTimeout > 0 Then
    If TimerDiff($Timer) > $iTimeout * 1000 Then
    GUIDelete($h_CMBGUI)
    Opt("GUIOnEventMode", $Useopt)
    Return 0
    EndIf
    EndIf
    WEnd

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

    EndFunc ;==>CustomMsgBox

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

    ; #INDEX# ============================================================================================================
    ; Title .........: _StringSize
    ; AutoIt Version : v3.2.12.1 or higher
    ; Language ......: English
    ; Description ...: Returns size of rectangle required to display string - maximum width can be chosen
    ; Remarks .......:
    ; Note ..........:
    ; Author(s) .....: Melba23 - thanks to trancexx for the default DC code
    ; ====================================================================================================================

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

    ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

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

    ; #CURRENT# ==========================================================================================================
    ; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen
    ; ====================================================================================================================

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

    ; #INTERNAL_USE_ONLY#=================================================================================================
    ; _StringSize_Error_Close: Releases DC and deletes font object after error
    ; _StringSize_DefaultFontName: Determines Windows default font
    ; ====================================================================================================================

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

    ; #FUNCTION# =========================================================================================================
    ; Name...........: _StringSize
    ; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen
    ; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]])
    ; Parameters ....: $sText - String to display
    ; $iSize - [optional] Font size in points - (default = 8.5)
    ; $iWeight - [optional] Font weight - (default = 400 = normal)
    ; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike)
    ; + 1 if tabs are to be expanded before sizing
    ; $sName - [optional] Font name - (default = Tahoma)
    ; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string)
    ; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required)
    ; Requirement(s) : v3.2.12.1 or higher
    ; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set)
    ; |$array[0] = String reformatted with additonal @CRLF // Original string
    ; |$array[1] = Height of single line in selected font // idem
    ; |$array[2] = Width of rectangle required for reformatted // original string
    ; |$array[3] = Height of rectangle required for reformatted // original string
    ; Failure - Returns 0 and sets @error:
    ; |1 - Incorrect parameter type (@extended = parameter index)
    ; |2 - DLL call error - extended set as follows:
    ; |1 - GetDC failure
    ; |2 - SendMessage failure
    ; |3 - GetDeviceCaps failure
    ; |4 - CreateFont failure
    ; |5 - SelectObject failure
    ; |6 - GetTextExtentPoint32 failure
    ; |3 - Font too large for chosen max width - a word will not fit
    ; Author ........: Melba23 - thanks to trancexx for the default DC code
    ; Modified ......:
    ; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not
    ; return correct dimensions without it.
    ; Related .......:
    ; Link ..........:
    ; Example .......: Yes
    ;=====================================================================================================================
    Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hwnd = 0)

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

    ; Set parameters passed as Default
    If $iSize = Default Then $iSize = 8.5
    If $iWeight = Default Then $iWeight = 400
    If $iAttrib = Default Then $iAttrib = 0
    If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName()

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

    ; Check parameters are correct type
    If Not IsString($sText) Then Return SetError(1, 1, 0)
    If Not IsNumber($iSize) Then Return SetError(1, 2, 0)
    If Not IsInt($iWeight) Then Return SetError(1, 3, 0)
    If Not IsInt($iAttrib) Then Return SetError(1, 4, 0)
    If Not IsString($sName) Then Return SetError(1, 5, 0)
    If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0)
    If Not IsHWnd($hwnd) And $hwnd <> 0 Then Return SetError(1, 7, 0)

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

    Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle

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

    ; Check for tab expansion flag
    Local $iExpTab = BitAND($iAttrib, 1)
    ; Remove possible tab expansion flag from font attribute value
    $iAttrib = BitAND($iAttrib, BitNOT(1))

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

    ; If GUI handle was passed
    If IsHWnd($hwnd) Then
    ; Create label outside GUI borders
    $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10)
    $hLabel_Handle = GUICtrlGetHandle(-1)
    GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName)
    ; Create DC
    $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle)
    If @error Or $aRet[0] = 0 Then
    GUICtrlDelete($hLabel)
    Return SetError(2, 1, 0)
    EndIf
    $hDC = $aRet[0]
    $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont
    If @error Or $aRet[0] = 0 Then
    GUICtrlDelete($hLabel)
    Return SetError(2, _StringSize_Error_Close(2, $hDC), 0)
    EndIf
    $hFont = $aRet[0]
    Else
    ; Get default DC
    $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
    If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0)
    $hDC = $aRet[0]
    ; Create required font
    $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY
    If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0)
    Local $iInfo = $aRet[0]
    $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _
    "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _
    "dword", 0, "dword", 5, "dword", 0, "wstr", $sName)
    If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0)
    $hFont = $aRet[0]
    EndIf

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

    ; Select font and store previous font
    $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont)
    If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0)
    Local $hPrevFont = $aRet[0]

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

    ; Declare variables
    Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line
    ; Declare and fill Size structure
    Local $tSize = DllStructCreate("int X;int Y")
    DllStructSetData($tSize, "X", 0)
    DllStructSetData($tSize, "Y", 0)

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

    ; Ensure EoL is @CRLF and break text into lines
    $sText = StringRegExpReplace($sText, "((?<!\x0d)\x0a|\x0d(?!\x0a))", @CRLF)
    Local $asLines = StringSplit($sText, @CRLF, 1)

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

    ; For each line
    For $i = 1 To $asLines[0]
    ; Expand tabs if required
    If $iExpTab Then
    $asLines[$i] = StringReplace($asLines[$i], @TAB, " XXXXXXXX")
    EndIf
    ; Size line
    $iLine_Length = StringLen($asLines[$i])
    DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$i], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
    If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
    If DllStructGetData($tSize, "X") > $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X")
    If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y")
    Next

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

    ; Check if $iMaxWidth has been both set and exceeded
    If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required
    ; For each Line
    For $j = 1 To $asLines[0]
    ; Size line unwrapped
    $iLine_Length = StringLen($asLines[$j])
    DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
    If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
    ; Check wrap status
    If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then
    ; No wrap needed so count line and store
    $iLine_Count += 1
    $avSize_Info[0] &= $asLines[$j] & @CRLF
    Else
    ; Wrap needed so zero counter for wrapped lines
    $iWrap_Count = 0
    ; Build line to max width
    While 1
    ; Zero line width
    $iLine_Width = 0
    ; Initialise pointer for end of word
    $iLast_Word = 0
    ; Add characters until EOL or maximum width reached
    For $i = 1 To StringLen($asLines[$j])
    ; Is this just past a word ending?
    If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1
    ; Increase line by one character
    $sTest_Line = StringMid($asLines[$j], 1, $i)
    ; Get line length
    $iLine_Length = StringLen($sTest_Line)
    DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
    If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
    $iLine_Width = DllStructGetData($tSize, "X")
    ; If too long exit the loop
    If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop
    Next
    ; End of the line of text?
    If $i > StringLen($asLines[$j]) Then
    ; Yes, so add final line to count
    $iWrap_Count += 1
    ; Store line
    $avSize_Info[0] &= $sTest_Line & @CRLF
    ExitLoop
    Else
    ; No, but add line just completed to count
    $iWrap_Count += 1
    ; Check at least 1 word completed or return error
    If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0)
    ; Store line up to end of last word
    $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF
    ; Strip string to point reached
    $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word)
    ; Trim leading whitespace
    $asLines[$j] = StringStripWS($asLines[$j], 1)
    ; Repeat with remaining characters in line
    EndIf
    WEnd
    ; Add the number of wrapped lines to the count
    $iLine_Count += $iWrap_Count
    EndIf
    Next
    ; Reset any tab expansions
    If $iExpTab Then
    $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB)
    EndIf
    ; Complete return array
    $avSize_Info[1] = $iLine_Height
    $avSize_Info[2] = $iMaxWidth
    ; Convert lines to pixels and add drop margin
    $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4
    Else ; No wrapping required
    ; Create return array (add drop margin to height)
    Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4]
    EndIf

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

    ; Clear up
    DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont)
    DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont)
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC)
    If $hLabel Then GUICtrlDelete($hLabel)

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

    Return $avSize_Info

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

    EndFunc ;==>_StringSize

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

    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _StringSize_Error_Close
    ; Description ...: Releases DC and deleted font object if required after error
    ; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI)
    ; Parameters ....: $iExtCode - code to return
    ; $hDC, $hGUI - handles as set in _StringSize function
    ; Return value ..: $iExtCode as passed
    ; Author ........: Melba23
    ; Modified.......:
    ; Remarks .......: This function is used internally by _StringSize
    ; ===============================================================================================================================
    Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0)

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

    If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont)
    If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC)
    If $hLabel Then GUICtrlDelete($hLabel)

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

    Return $iExtCode

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

    EndFunc ;==>_StringSize_Error_Close

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

    ; #INTERNAL_USE_ONLY#============================================================================================================
    ; Name...........: _StringSize_DefaultFontName
    ; Description ...: Determines Windows default font
    ; Syntax ........: _StringSize_DefaultFontName()
    ; Parameters ....: None
    ; Return values .: Success - Returns name of system default font
    ; Failure - Returns "Tahoma"
    ; Author ........: Melba23, based on some original code by Larrydalooza
    ; Modified.......:
    ; Remarks .......: This function is used internally by _StringSize
    ; ===============================================================================================================================
    Func _StringSize_DefaultFontName()

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

    ; Get default system font data
    Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]")
    DllStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS))
    DllCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0)
    Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DllStructGetPtr($tNONCLIENTMETRICS, 13))
    If IsString(DllStructGetData($tLOGFONT, 14)) Then
    Return DllStructGetData($tLOGFONT, 14)
    Else
    Return "Tahoma"
    EndIf

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

    EndFunc ;==>_StringSize_DefaultFontName

    [/autoit]
    Beispiel
    [autoit]


    #include <CMB.au3>
    Local $asButtonarray[6] = ["OK", "Abbrechen", "Weiter", "Zurück", "Ignorieren", "Hinzufügen"]
    $t = CustomMsgBox("Custom Messagebox", "Ein wenig Text, nur zu Demozwecken" & @CRLF & "Funktionieren die Zeilenumbrüche?" & @CRLF & "Ich denke schon", $asButtonarray, -1, 3)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $t = ' & $t & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

    [/autoit]

    Ich würde mich sehr über Feedback freuen :)

  • regulärer ausdruck über MS SQL query

    • TheLuBu
    • 29. April 2013 um 15:43

    Über der Code Box steht MySQL Abfrage :D

    Ok, im Anhang ist alles enthalten, was du für RegEx auf einem MSSQL Server benötigst :)

    Abrufen kannst du das ganze dann hiermit

    Spoiler anzeigen
    SQL
    SELECT dbo.RegExSearch(a.String, '(?<=.*?OUR\sREF:\s)(\d{5}\w-[a-zA-Z]{2})')
    FROM (SELECT 'RE: YOUR REF:  P0038165.03 //  // OUR REF: 15450R-EP       TITLE:  TWO-PIECE PERCUTANEOUS PROSTHETIC HEART VALVES AND METHODS FOR MAKING AND USING THEM' as String) as a
  • regulärer ausdruck über MS SQL query

    • TheLuBu
    • 29. April 2013 um 15:34

    Redest du jetzt über MySQL oder MSSQL?

  • Abfrage einer MS SQL 2008 DB mit Autoit

    • TheLuBu
    • 29. April 2013 um 15:33

    SQlite ist ein eigenes DBMS, hat nix mit MySQL zu tun :)

  • Abfrage einer MS SQL 2008 DB mit Autoit

    • TheLuBu
    • 29. April 2013 um 15:16

    Ich habe eine der MSSQL UDF´s geschrieben (siehe Signatur) aber Dietmar hat recht, das was er dort gepostet hat, ist alles was man benötigt.
    Meine UDF basiert quasi auch nur auf diesen 3 Befehlen, nur habe ich eben auch Wrapper für andere Funktionen geschrieben.

    Es kommt eben drauf an, was du genau machen willst.
    Ich habe in meiner UDF zum Beispiel eine Funktion, um Daten abzufragen und direkt als Array zurück zu liefern. Natürlich kannst du das aber auch einfach selbst mit den 3 Funktionen zusammen basteln :)

  • Array wird in Schleife nicht abgearbeitet

    • TheLuBu
    • 29. April 2013 um 14:37

    Du benutzt den selben schleifenzähler einfach in Zeile 13 und dann nochmal in Zeile 24, nimm für einen von den beiden mal eine andere Zählervariable

  • a* A-Star Algorithmus (Grafik!!)

    • TheLuBu
    • 5. April 2013 um 15:54

    Nur als Hinweis, man kann das Ziel wegklicken aber nicht neu setzen :)
    Aber sonst wirklich sehr gut! :thumbup:

  • Changelog Creator

    • TheLuBu
    • 28. März 2013 um 15:44

    Hmm ich hätte da eine Idee, ich überlege mir was :)

  • Changelog Creator

    • TheLuBu
    • 28. März 2013 um 15:28

    minx OK, werde ich noch einbauen :)

    Nakroma

    Jetzt hab ich erst gemerkt, was du meinst. Es sollten eigentlich die Funktionen des ausgewählten Scripts sein.
    Die Datei die du geöffnet hast, enthält 3 Funktionen (close, ent, ver)

  • Changelog Creator

    • TheLuBu
    • 28. März 2013 um 15:22

    minx http://php.net/ChangeLog-5.php
    finde es kommt dem schon sehr ähnlich :P

    Nakroma beim BBCode hat sich anscheinend ein Fehler eingeschlichen, werden den noch ändern ;)

  • Changelog Creator

    • TheLuBu
    • 28. März 2013 um 15:10

    Wo steht das denn ^^

  • Changelog Creator

    • TheLuBu
    • 28. März 2013 um 15:02

    Hallo liebe Community,
    Es ist wieder soweit, ich hatte die Zeit, an einem privaten Projekt zu arbeiten :)
    Ich präsentiere: Den Changelogcreator (Version 1.0.0) :D

    Das Programm soll euch bei euren Releases helfen, sofern ihr einen Changelog führen und/oder diesen auch veröffentlichen wollt.

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=changelog.ico
    #AutoIt3Wrapper_outfile=Changelogcreator.exe
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_Res_Fileversion=1.0.0.3
    #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
    #AutoIt3Wrapper_Res_LegalCopyright=Lucas Buchwald
    #AutoIt3Wrapper_Res_Language=1031
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <Array.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiComboBox.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>
    #include <GuiButton.au3>
    #include 'include/images_include.au3'

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

    Global Const $imagepath = @TempDir & "\CC_IMG"
    _Include_changelog_images_StartUp($imagepath)
    OnAutoItExitRegister("_Include_changelog_images_ShutDown")

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

    Global Const $REG_EX_GET_FUNC = '(?m:^|\n)Func\s([^(]*)'
    Global Const $REG_EX_GET_VERSION = '(?m:^|\n)#AutoIt3Wrapper_Res_Fileversion=\s*(.*?)(?m:$|\r)'
    Global $oChangeDict = ObjCreate("Scripting.Dictionary")
    Global $hImagelist, $ButtonImageList[5]
    Create_LV_Imagelist()

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

    #region ### START Koda GUI section ### Form=
    $hGUI = GUICreate("Changelog Creator", 627, 517, 192, 124)
    GUICtrlCreateGroup("", 8, 8, 601, 81)
    $Show_au3file_Path = GUICtrlCreateInput("", 16, 24, 353, 21, $ES_READONLY)
    $Import_Au3_Button = GUICtrlCreateButton(".au3 Datei öffnen", 384, 24, 209, 25, $WS_GROUP)
    $Show_Changefile_Path = GUICtrlCreateInput("", 16, 56, 353, 21, $ES_READONLY)
    $Import_Changefile_Button = GUICtrlCreateButton("Changelog Datei öffnen", 384, 56, 209, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("", 8, 96, 601, 329)
    $All_Funcs_Combo = GUICtrlCreateCombo("", 16, 112, 153, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
    $Add_Func_Button = GUICtrlCreateButton("Add", 184, 112, 105, 25, $WS_GROUP)
    GUICtrlCreateLabel("Version", 360, 112, 55, 17)
    $Version = GUICtrlCreateInput("", 424, 112, 121, 21)
    $Changed_Funcs_Combo = GUICtrlCreateCombo("", 16, 144, 153, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
    $Remove_Func_Button = GUICtrlCreateButton("Remove", 184, 144, 105, 25, $WS_GROUP)
    $Status_Combo = GUICtrlCreateCombo("", 16, 176, 73, 25, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "Fixed|Added|Removed", "Fixed")
    $Input_Text = GUICtrlCreateInput("", 96, 176, 153, 21)
    $Add_Text_Button = GUICtrlCreateButton("Add Text", 264, 176, 105, 25, $WS_GROUP)
    $Add_Link_Button = GUICtrlCreateButton("Add Link", 373, 176, 105, 25, $WS_GROUP)
    $Remove_Text_Button = GUICtrlCreateButton("Remove Text", 482, 176, 105, 25, $WS_GROUP)
    $hListView = GUICtrlCreateListView("", 16, 216, 565, 188, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER), 512)
    _GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_BORDERSELECT, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_DOUBLEBUFFER))
    _GUICtrlListView_AddColumn($hListView, "Data", 561)
    _GUICtrlListView_SetImageList($hListView, $hImagelist, 1)
    $cb = _GUICtrlListView_RegisterSortCallBack($hListView)
    If Not IsHWnd($hListView) Then _GUICtrlListView_RegisterSortCallBack(GUICtrlGetHandle($hListView))
    GUICtrlSetData(-1, "")
    GUICtrlSetFont(-1, 8.5, 400, Default, "Courier New")
    ;~ $Sortbutton = GUICtrlCreateButton("", 565 + 16 + 2, 205 + 20, 24, 24, $BS_ICON)
    ;~ _GUICtrlButton_SetImageList($Sortbutton, $ButtonImageList[4], 4)
    $upupbutton = GUICtrlCreateButton("", 565 + 16 + 2, 230 + 20, 24, 24, $BS_ICON)
    _GUICtrlButton_SetImageList($upupbutton, $ButtonImageList[2], 4)
    $upbutton = GUICtrlCreateButton("", 565 + 16 + 2, 255 + 20, 24, 24, $BS_ICON)
    _GUICtrlButton_SetImageList($upbutton, $ButtonImageList[0], 4)
    $downbutton = GUICtrlCreateButton("", 565 + 16 + 2, 285 + 20, 24, 24, $BS_ICON)
    _GUICtrlButton_SetImageList($downbutton, $ButtonImageList[1], 4)
    $downdownbutton = GUICtrlCreateButton("", 565 + 16 + 2, 310 + 20, 24, 24, $BS_ICON)
    _GUICtrlButton_SetImageList($downdownbutton, $ButtonImageList[3], 4)

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

    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("", 8, 432, 601, 73)
    GUICtrlCreateLabel("Exportformat", 16, 450, 209, 20, $SS_CENTER)
    $Exportformat = GUICtrlCreateCombo("", 16, 472, 209, 25, $CBS_DROPDOWNLIST)
    GUICtrlSetData($Exportformat, "BBCode|HTML", "BBCode")
    $Copy_Clipboard_Button = GUICtrlCreateButton("Copy to Clipboard", 272, 455, 121, 40, $WS_GROUP)
    $Export_Button = GUICtrlCreateButton("Export", 400, 455, 121, 40, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

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

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

    Case $Add_Func_Button
    Add_Changed_Func()
    Case $Remove_Func_Button
    Remove_Changed_Func()
    Case $Add_Text_Button
    Add_Text()
    Case $Remove_Text_Button
    Remove_Text()
    Case $Changed_Funcs_Combo
    Load_Changed_Func_Changelog()
    Case $upbutton
    Move_LV_Entry_up(False)
    Case $upupbutton
    Move_LV_Entry_up(True)
    Case $downbutton
    Move_LV_Entry_down(False)
    Case $downdownbutton
    Move_LV_Entry_down(True)
    Case $Add_Link_Button
    Add_Link()
    Case $Copy_Clipboard_Button
    Export(False)
    Case $Export_Button
    Export(True)
    ;~ Case $Sortbutton
    ;~ SortListview()
    EndSwitch
    WEnd

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

    Func Export($ToFile)
    If GUICtrlRead($Show_au3file_Path) = "" Then Return 0
    Local $sPath, $sFilter, $changedarray, $sRet, $type
    $rettype = GUICtrlRead($Exportformat)
    Switch $rettype
    Case "BBCode"
    $type = ".txt"
    $sFilter = "Textdatei (*." & $type & ")"
    $sRet = "Version " & GUICtrlRead($Version) & "" & @CRLF
    Case "HTML"
    $type = ".html"
    $sFilter = "Htmldatei (*." & $type & ")"
    $sRet &= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">' & @CRLF
    $sRet &= '<html>' & @CRLF
    $sRet &= '<head>' & @CRLF
    $sRet &= '<title>Changelog</title>' & @CRLF
    $sRet &= '<style type="text/css">' & @CRLF
    $sRet &= '/* changelog_Outer */' & @CRLF
    $sRet &= '.changelog_Outer { background-color: #1d1d1d;}' & @CRLF
    $sRet &= '/* changelog_version */' & @CRLF
    $sRet &= '.changelog_version { color:#0040FF; padding-top:15px;padding-left:10px;}' & @CRLF
    $sRet &= '/* changelog_Inner */' & @CRLF
    $sRet &= '.changelog_Inner { color:#eee; }' & @CRLF
    $sRet &= '.changelog_Inner ul { font-size:18px; }' & @CRLF
    $sRet &= '.changelog_Inner ul li { }' & @CRLF
    $sRet &= '.changelog_Inner ul li ul { list-style-image: url("../images/nested.png"); padding:5px 0 5px 18px; font-size:15px; }' & @CRLF
    $sRet &= '.changelog_Inner ul li ul li { color:#bfe1f1; height:15px; margin-left:10px; }' & @CRLF
    $sRet &= '</style>' & @CRLF
    $sRet &= '</head>' & @CRLF
    $sRet &= '<body>' & @CRLF
    $sRet &= @TAB & '<div class="changelog_Outer">' & @CRLF
    $sRet &= @TAB & @TAB & '<div class="changelog_version">Version ' & GUICtrlRead($Version) & '</div>' & @CRLF
    $sRet &= @TAB & @TAB & @TAB & '<div class="changelog_Inner">' & @CRLF
    $sRet &= @TAB & @TAB & @TAB & @TAB & '<ul>' & @CRLF
    EndSwitch
    If $ToFile Then
    $sPath = FileOpenDialog("Speicherpfad wählen", @DesktopDir, $sFilter, "Export" & $type)
    If @error Then Return 0
    EndIf
    $changedarray = _GUICtrlComboBox_GetListArray($Changed_Funcs_Combo)
    For $I = 1 To $changedarray[0]
    $split = StringSplit($oChangeDict($changedarray[$I]), "&datasepchar;", 1)
    Switch $rettype
    Case "BBCode"
    $sRet &= "" & $changedarray[$I] & "" & @CRLF
    $sRet &= "

    [/autoit] [autoit]
    • " & @CRLF
      Case "HTML"
      $sRet &= @TAB & @TAB & @TAB & @TAB & @TAB & '<li>' & $changedarray[$I] & @CRLF
      $sRet &= @TAB & @TAB & @TAB & @TAB & @TAB & @TAB & '<ul>' & @CRLF
      EndSwitch
      For $k = 2 To $split[0]
      Switch $rettype
      Case "BBCode"
      $sRet &= "
    • " & $split[$k] & @CRLF
      Case "HTML"
      $sRet &= @TAB & @TAB & @TAB & @TAB & @TAB & @TAB & @TAB & '<li>' & _ConvertEntities($split[$k], False) & '</li>' & @CRLF
      EndSwitch
      Next
      Switch $rettype
      Case "BBCode"
      $sRet &= "

    [autoit]" & @CRLF
    Case "HTML"
    $sRet &= @TAB & @TAB & @TAB & @TAB & @TAB & @TAB & '</ul>' & @CRLF
    $sRet &= @TAB & @TAB & @TAB & @TAB & @TAB & '</li>' & @CRLF
    EndSwitch
    Next
    If $rettype = "HTML" Then
    $sRet &= @TAB & @TAB & @TAB & @TAB & '</ul>' & @CRLF
    $sRet &= @TAB & @TAB & @TAB & '</div>' & @CRLF
    $sRet &= @TAB & @TAB & '</div>' & @CRLF
    $sRet &= @TAB & '</div>' & @CRLF
    $sRet &= '</body>' & @CRLF
    $sRet &= '</html>' & @CRLF
    EndIf
    If Not $ToFile Then
    ClipPut($sRet)
    MsgBox(64, "Erfolg", "Die Daten wurden in die Zwischenablage kopiert!")
    Else
    $hFile = FileOpen($sPath & $type, 10)
    FileWrite($hFile, $sRet)
    FileClose($hFile)
    MsgBox(64, "Erfolg", "Die Datei wurde erstellt!")
    EndIf
    EndFunc ;==>Export

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

    Func SortListview()
    Local $hWnd
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    $sort = _GUICtrlListView_SortItems($hWnd, 0)
    ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sort = ' & $sort & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    EndFunc ;==>SortListview

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

    Func Open_Au3()
    $FilePath = FileOpenDialog("Au3 Datei öffnen", @DesktopDir, "AutoIt Source (*.au3)")
    GUICtrlSetData($Show_au3file_Path, $FilePath)
    $hFile = FileOpen($FilePath, 0)
    $Read = FileRead($hFile)
    FileClose($hFile)
    $Find_Version = StringRegExp($Read, $REG_EX_GET_VERSION, 3)
    If IsArray($Find_Version) Then GUICtrlSetData($Version, $Find_Version[0])
    $Funcs = StringRegExp($Read, $REG_EX_GET_FUNC, 3)
    If Not IsArray($Funcs) Then Return SetError(1, 0, 0)
    _ArraySort($Funcs)
    For $I = 0 To UBound($Funcs) - 1
    _GUICtrlComboBox_AddString($All_Funcs_Combo, $Funcs[$I])
    Next
    EndFunc ;==>Open_Au3

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

    Func Add_Changed_Func()
    Local $hWnd
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    $CurSel = GUICtrlRead($All_Funcs_Combo)
    If $CurSel = "" Then Return 0
    _GUICtrlComboBox_AddString($Changed_Funcs_Combo, $CurSel)
    $oChangeDict($CurSel) = ""
    _GUICtrlComboBox_DeleteString($All_Funcs_Combo, _GUICtrlComboBox_GetCurSel($All_Funcs_Combo))
    Sort_Combobox($All_Funcs_Combo)
    Sort_Combobox($Changed_Funcs_Combo)
    _GUICtrlComboBox_SetCurSel($All_Funcs_Combo, -1)
    _GUICtrlComboBox_SetCurSel($Changed_Funcs_Combo, _GUICtrlComboBox_FindString($Changed_Funcs_Combo, $CurSel))
    _GUICtrlListView_DeleteAllItems($hWnd)
    EndFunc ;==>Add_Changed_Func

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

    Func Remove_Changed_Func()
    $CurSel = GUICtrlRead($Changed_Funcs_Combo)
    If $CurSel = "" Then Return 0
    _GUICtrlComboBox_AddString($All_Funcs_Combo, $CurSel)
    $oChangeDict.remove($CurSel)
    _GUICtrlComboBox_DeleteString($Changed_Funcs_Combo, _GUICtrlComboBox_GetCurSel($Changed_Funcs_Combo))
    Sort_Combobox($All_Funcs_Combo)
    Sort_Combobox($Changed_Funcs_Combo)
    _GUICtrlComboBox_SetCurSel($Changed_Funcs_Combo, -1)
    Local $hWnd
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    _GUICtrlListView_DeleteAllItems($hWnd)
    EndFunc ;==>Remove_Changed_Func

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

    Func Sort_Combobox($combobox)
    $Listarray = _GUICtrlComboBox_GetListArray($combobox)
    _ArrayDelete($Listarray, 0)
    If $Listarray[0] = "" Then _ArrayDelete($Listarray, 0)
    _ArraySort($Listarray)
    _GUICtrlComboBox_ResetContent($combobox)
    For $I = 0 To UBound($Listarray) - 1
    _GUICtrlComboBox_AddString($combobox, $Listarray[$I])
    Next
    EndFunc ;==>Sort_Combobox

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

    Func Add_Text()
    Local $hWnd
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    If GUICtrlRead($Input_Text) = "" Then Return 0
    Local $icon
    $CurSel = GUICtrlRead($Changed_Funcs_Combo)
    If $CurSel = "" Then Return 0
    Switch GUICtrlRead($Status_Combo)
    Case "Fixed"
    $icon = 0
    Case "Added"
    $icon = 1
    Case "Removed"
    $icon = 2
    EndSwitch
    $oChangeDict($CurSel) = $oChangeDict($CurSel) & "&datasepchar;" & StringFormat("%-10s", GUICtrlRead($Status_Combo)) & ": " & GUICtrlRead($Input_Text)
    _GUICtrlListView_AddItem($hWnd, StringFormat("%-10s", GUICtrlRead($Status_Combo)) & ": " & @TAB & GUICtrlRead($Input_Text), $icon)
    GUICtrlSetData($Input_Text, "")
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE)
    If _GUICtrlListView_GetColumnWidth($hWnd, 0) < 561 Then _GUICtrlListView_SetColumnWidth($hWnd, 0, 561)
    ControlFocus($hGUI, "", $Input_Text)
    EndFunc ;==>Add_Text

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

    Func Remove_Text()
    Local $hWnd
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    $CurSelList = _GUICtrlListView_GetSelectedIndices($hWnd)
    If $CurSelList = "" Then Return SetError(1, 0, -1)
    $CurSel = GUICtrlRead($Changed_Funcs_Combo)
    If $CurSel = "" Then Return 0
    $oChangeDict($CurSel) = StringReplace($oChangeDict($CurSel), "&datasepchar;" & _GUICtrlListView_GetItemText($hWnd, $CurSelList), "")
    _GUICtrlListView_DeleteItem($hWnd, $CurSelList)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE)
    If _GUICtrlListView_GetColumnWidth($hWnd, 0) < 561 Then _GUICtrlListView_SetColumnWidth($hWnd, 0, 561)
    EndFunc ;==>Remove_Text

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

    Func Create_LV_Imagelist()
    $hImagelist = _GUIImageList_Create(24, 24, 5, 1)
    _GUIImageList_AddIcon($hImagelist, $imagepath & "\fixed.ico", 0, True)
    _GUIImageList_AddIcon($hImagelist, $imagepath & "\add.ico", 0, True)
    _GUIImageList_AddIcon($hImagelist, $imagepath & "\remove.ico", 0, True)
    $ButtonImageList[0] = _GUIImageList_Create(24, 24, 5, 1)
    _GUIImageList_AddIcon($ButtonImageList[0], $imagepath & "\up.ico", 0, True)
    $ButtonImageList[1] = _GUIImageList_Create(24, 24, 5, 1)
    _GUIImageList_AddIcon($ButtonImageList[1], $imagepath & "\down.ico", 0, True)
    $ButtonImageList[2] = _GUIImageList_Create(24, 24, 5, 1)
    _GUIImageList_AddIcon($ButtonImageList[2], $imagepath & "\upup.ico", 0, True)
    $ButtonImageList[3] = _GUIImageList_Create(24, 24, 5, 1)
    _GUIImageList_AddIcon($ButtonImageList[3], $imagepath & "\downdown.ico", 0, True)
    $ButtonImageList[4] = _GUIImageList_Create(24, 24, 5, 1)
    _GUIImageList_AddIcon($ButtonImageList[4], $imagepath & "\Sort_asc.ico", 0, True)
    EndFunc ;==>Create_LV_Imagelist

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

    Func Load_Changed_Func_Changelog()
    Local $hWnd, $icon
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    _GUICtrlListView_DeleteAllItems($hWnd)
    $CurSel = GUICtrlRead($Changed_Funcs_Combo)
    If $CurSel = "" Then Return 0
    $split = StringSplit($oChangeDict($CurSel), "&datasepchar;", 1)
    For $I = 2 To $split[0]
    Switch StringLeft($split[$I], 1)
    Case "F"
    $icon = 0
    Case "A"
    $icon = 1
    Case "R"
    $icon = 2
    EndSwitch
    _GUICtrlListView_AddItem($hWnd, $split[$I], $icon)
    Next
    EndFunc ;==>Load_Changed_Func_Changelog

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

    Func Move_LV_Entry_up($step)
    Local $hWnd, $changeseltext
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    $CurSelList = _GUICtrlListView_GetSelectedIndices($hWnd)
    If $CurSelList = "" Then Return SetError(1, 0, -1)
    $CurSel = GUICtrlRead($Changed_Funcs_Combo)
    If $CurSel = "" Or $CurSelList = 0 Then
    ControlFocus($hGUI, "", $hWnd)
    Return 0
    EndIf
    _GUICtrlListView_BeginUpdate($hWnd)
    If Not $step Then
    _GUICtrlListView_InsertItem($hWnd, _GUICtrlListView_GetItemText($hWnd, $CurSelList), $CurSelList - 1, _GUICtrlListView_GetItemImage($hWnd, $CurSelList))
    _GUICtrlListView_DeleteItem($hWnd, $CurSelList + 1)
    _GUICtrlListView_SetItemSelected($hWnd, $CurSelList - 1, True, True)
    Else
    _GUICtrlListView_InsertItem($hWnd, _GUICtrlListView_GetItemText($hWnd, $CurSelList), 0, _GUICtrlListView_GetItemImage($hWnd, $CurSelList))
    _GUICtrlListView_DeleteItem($hWnd, $CurSelList + 1)
    _GUICtrlListView_SetItemSelected($hWnd, 0, True, True)
    EndIf
    _GUICtrlListView_EndUpdate($hWnd)
    ControlFocus($hGUI, "", $hWnd)
    $changeseltext = ""
    For $I = 0 To _GUICtrlListView_GetItemCount($hWnd) - 1
    $changeseltext &= "&datasepchar;" & _GUICtrlListView_GetItemText($hWnd, $I)
    Next
    $oChangeDict($CurSel) = $changeseltext
    EndFunc ;==>Move_LV_Entry_up

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

    Func Move_LV_Entry_down($step)
    Local $hWnd, $changeseltext, $count
    If Not IsHWnd($hListView) Then
    $hWnd = GUICtrlGetHandle($hListView)
    Else
    $hWnd = $hListView
    EndIf
    $CurSelList = _GUICtrlListView_GetSelectedIndices($hWnd)
    If $CurSelList = "" Then Return SetError(1, 0, -1)
    $CurSel = GUICtrlRead($Changed_Funcs_Combo)
    $count = _GUICtrlListView_GetItemCount($hWnd) - 1
    If $CurSel = "" Or $CurSelList = $count Then
    ControlFocus($hGUI, "", $hWnd)
    Return 0
    EndIf
    _GUICtrlListView_BeginUpdate($hWnd)
    If Not $step Then
    $new = _GUICtrlListView_InsertItem($hWnd, _GUICtrlListView_GetItemText($hWnd, $CurSelList), $CurSelList + 2, _GUICtrlListView_GetItemImage($hWnd, $CurSelList))
    $del = _GUICtrlListView_DeleteItem($hWnd, $CurSelList)
    $sel = _GUICtrlListView_SetItemSelected($hWnd, $CurSelList + 1, True, True)
    Else
    _GUICtrlListView_InsertItem($hWnd, _GUICtrlListView_GetItemText($hWnd, $CurSelList), $count + 1, _GUICtrlListView_GetItemImage($hWnd, $CurSelList))
    _GUICtrlListView_DeleteItem($hWnd, $CurSelList)
    _GUICtrlListView_SetItemSelected($hWnd, $count + 1, True, True)
    EndIf
    _GUICtrlListView_EndUpdate($hWnd)
    ControlFocus($hGUI, "", $hWnd)
    $changeseltext = ""
    For $I = 0 To _GUICtrlListView_GetItemCount($hWnd) - 1
    $changeseltext &= "&datasepchar;" & _GUICtrlListView_GetItemText($hWnd, $I)
    Next
    $oChangeDict($CurSel) = $changeseltext
    EndFunc ;==>Move_LV_Entry_down

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

    Func Add_Link()
    Local $sLink, $LinkDesc, $sString
    While True
    $sLink = InputBox("Link hinzufügen", "Bitte geben Sie die Adresse des Links ein", $sLink, " M")
    If @error = 1 Then Return 0
    $test = StringRegExp($sLink, "^(http(?:s)?\:\/\/[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,6}(?:\/?|(?:\/[\w\-]+)*)(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$")
    If $test Then
    ExitLoop
    Else
    If MsgBox(262161, "Fehler", "Die eingebene Adresse ist kein Link!") = 2 Then Return 0
    EndIf
    WEnd
    $LinkDesc = InputBox("Beschreibung hinzufügen (Optional)", "Bitte geben Sie eine Beschreibung zum Link an")
    If @error = 1 Then $LinkDesc = $sLink
    $sString = "" & $LinkDesc & ""
    WinActivate($hGUI)
    ControlFocus($hGUI, "", $Input_Text)
    ControlCommand($hGUI, "", $Input_Text, "EditPaste", $sString)
    EndFunc ;==>Add_Link

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

    ; #FUNCTION# ====================================================================================================
    ; Description ...: _ConvertEntities
    ; Parameters ....: $sURL - IN - The Text to convert
    ; Return values .: Success - Converted string
    ; Author ........: Stephen Podhajecki {gehossafats at netmdc. com}
    ; Remarks .......: Replaces HTML escape sequences with character representation
    ; Based on information found here: http://www.theukwebdesigncompany.com/artic...-characters.php
    ; nbsp is changed to 32 instead of 160
    ; Related .......:
    ; ====================================================================================================
    Func _ConvertEntities($sURL, $fEncode = True)
    Local $aEntities[96][2] = [["&quot;", 34],["&amp;", 38],["&lt;", 60],["&gt;", 62],["&nbsp;", 3],["&nbsp;", 32] _
    ,["&iexcl;", 161],["&cent;", 162],["&pound;", 163],["&curren;", 164],["&yen;", 165],["&brvbar;", 166] _
    ,["&sect;", 167],["&uml;", 168],["&copy;", 169],["&ordf;", 170],["&not;", 172],["&shy;", 173] _
    ,["&reg;", 174],["&macr;", 175],["&deg;", 176],["&plusmn;", 177],["&sup2;", 178],["&sup3;", 179] _
    ,["&acute;", 180],["&micro;", 181],["&para;", 182],["&middot;", 183],["&cedil;", 184],["&sup1;", 185] _
    ,["&ordm;", 186],["&raquo;", 187],["&frac14;", 188],["&frac12;", 189],["&frac34;", 190],["&iquest;", 191] _
    ,["&Agrave;", 192],["&Aacute;", 193],["&Atilde;", 195],["&Auml;", 196],["&Aring;", 197],["&AElig;", 198] _
    ,["&Ccedil;", 199],["&Egrave;", 200],["&Eacute;", 201],["&Ecirc;", 202],["&Igrave;", 204],["&Iacute;", 205] _
    ,["&Icirc;", 206],["&Iuml;", 207],["&ETH;", 208],["&Ntilde;", 209],["&Ograve;", 210],["&Oacute;", 211] _
    ,["&Ocirc;", 212],["&Otilde;", 213],["&Ouml;", 214],["&times;", 215],["&Oslash;", 216],["&Ugrave;", 217] _
    ,["&Uacute;", 218],["&Ucirc;", 219],["&Uuml;", 220],["&Yacute;", 221],["&THORN;", 222],["&szlig;", 223] _
    ,["&agrave;", 224],["&aacute;", 225],["&acirc;", 226],["&atilde;", 227],["&auml;", 228],["&aring;", 229] _
    ,["&aelig;", 230],["&ccedil;", 231],["&egrave;", 232],["&eacute;", 233],["&ecirc;", 234],["&euml;", 235] _
    ,["&igrave;", 236],["&iacute;", 237],["&icirc;", 238],["&iuml;", 239],["&eth;", 240],["&ntilde;", 241] _
    ,["&ograve;", 242],["&oacute;", 243],["&ocirc;", 244],["&otilde;", 245],["&ouml;", 246],["&divide;", 247] _
    ,["&oslash;", 248],["&ugrave;", 249],["&uacute;", 250],["&ucirc;", 251],["&uuml;", 252],["&thorn;", 254]]
    If $fEncode Then
    For $x = 0 To UBound($aEntities) - 1
    $sURL = StringReplace($sURL, $aEntities[$x][0], Chr($aEntities[$x][1]), 0, 1)
    Next
    For $x = 32 To 255
    $sURL = StringReplace($sURL, "&#" & $x & ";", Chr($x))
    Next
    Else
    For $x = 0 To UBound($aEntities) - 1
    $sURL = StringReplace($sURL, Chr($aEntities[$x][1]), $aEntities[$x][0], 0, 1)
    Next
    EndIf
    Return $sURL
    EndFunc ;==>_ConvertEntities

    [/autoit][/autoit]

    Die zugehörige IncludeDatei findet ihr in der Zip Datei.
    Ihr könnt es aber auch testen, indem ihr die Zeilen 24-26 auskommentiert und auch das Include rausnehmt, dort werden nur Icons geladen.

    Derzeit kann das Changelog in HTML und BBCode exportiert werden.
    Beispiele dafür sind ebenfalls in der Zip Datei enthalten.

    Solltet ihr Fragen, Änderungswünsche oder Vorschläge haben, postet sie bitte hier, ich würde mich drüber freuen.

    --TODO--
    Import einer bestehender Changelogdatei.
    Standard GNU Changelog Datei
    Automatische Erkennung von Änderungen

    Dateien

    Changelog_Creator.zip 1,34 MB – 489 Downloads
  • Timeout beim DB Restore verhindern

    • TheLuBu
    • 21. März 2013 um 15:38

    Passe deine Connect Funktion mal so an,
    $iTimeOut gibt die Sekunden an, die eine Abfrage maximal dauern darf (in diesem Fall 4 Minuten)

    Spoiler anzeigen
    [autoit]

    Func _SQLCon($scIP, $scUser, $scPass, $scDB, $iTimeOut = 240)
    Local $sqlCon
    $sqlCon = ObjCreate("ADODB.Connection")
    $sqlCon.Open("Provider=SQLOLEDB; Data Source=" & $scIP & "; User ID=" & $scUser & "; Password=" & $scPass & "; database=" & $scDB & ";")
    $sqlCon.CommandTimeout = $iTimeOut
    If @error Then Return SetError(1, 0, 0)
    Return $sqlCon
    EndFunc ;==>_SQLCon

    [/autoit]
  • RosettaCode Sammelthread

    • TheLuBu
    • 21. März 2013 um 12:05

    James Sorry, das habe ich nicht gesehen ;)

    Aber warum werden die Beispiele von hier nicht bei Rosettacode veröffentlicht?
    Hier muss man sich durch minimum 4 Seiten klicken und schauen, ob das Projekt, was man sich auf Rosettacode ausgesucht hat, nicht schon bearbeitet wurde.
    Postet doch die Beispiele hier und bei Rosetta Code, wenn es Unstimmigkeiten gibt, kann man die ja besprechen bzw. eine bessere / aktualisierte Version auch bei Rosettacode hochladen

  • Alle Pixel einer PNG-Datei die nicht einem bestimmter Farbe entsprechen auf Transparent setzen

    • TheLuBu
    • 12. März 2013 um 15:11

    Hi Autobert,
    Bei mir gibt deine Consolenausgabe das hier zurück

    Code
    0/0: 00000000FFC6ECFF
    0/1: 00000000FFC6ECFF
    0/2: 00000000FFC6ECFF

    Habe dann dazu Zeile 14 in

    [autoit]

    If $sHex='00000000FFC11E1E' Then

    [/autoit]

    geändert und habe jetzt Berlin in dem neu erstellten Bild erhalten.

    Ich benutze Win 7 32 Bit, AutoIt : 3.3.8.1

  • RosettaCode Sammelthread

    • TheLuBu
    • 12. März 2013 um 11:33

    Art: Neu-Implementierung
    Task: http://rosettacode.org/wiki/Box_the_compass
    Beteiligte: TheLuBu
    Skript:

    Spoiler anzeigen
    [autoit]

    Local $avArray[33] = [0.0, 16.87, 16.88, 33.75, 50.62, 50.63, 67.5, 84.37, 84.38, 101.25, 118.12, 118.13, 135.0, _
    151.87, 151.88, 168.75, 185.62, 185.63, 202.5, 219.37, 219.38, 236.25, 253.12, 253.13, 270.0, 286.87, 286.88, _
    303.75, 320.62, 320.63, 337.5, 354.37, 354.38]

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

    For $i = 0 To UBound($avArray) - 1
    Boxing_the_compass($avArray[$i])
    Next

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

    Func Boxing_the_compass($Degree)
    Local $namearray[33] = ["North", "North by east", "North-northeast", "Northeast by north", "Northeast", _
    "Northeast by east", "East-northeast", "East by north", "East", "East by south", "East-southeast", _
    "Southeast by east", "Southeast", "Southeast by south", "South-southeast", "South by east", "South", _
    "South by west", "South-southwest", "Southwest by south", "Southwest", "Southwest by west", "West-southwest", _
    "West by south", "West", "West by north", "West-northwest", "Northwest by west", "Northwest", "Northwest by north", _
    "North-northwest", "North by west", "North"]
    ConsoleWrite(StringFormat("%-2s", Mod(Floor($Degree / 11.25 + 0.5), 32)) & " : " & _
    StringFormat("%-20s", $namearray[Mod(Floor($Degree / 11.25 + 0.5), 32)]) & " : " & $Degree & @CRLF)
    EndFunc ;==>Boxing_the_compass

    [/autoit]

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™