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

  • SMF - Search My Files [2011-Feb-13]

    • UEZ
    • 13. Februar 2011 um 21:28

    Echt klasse Code! :thumbup:

    Ist es möglich in der Haupt GUI nur eine Level im Baum zu selektieren? Z.B. will ich nur auf C:\ Root suchen (im Prinzip nicht rekursiv). Klicke ich auf C: dann wird alles selektiert.

    Während des Suchens kann ich im Suchfenster verschiedene Buttons anklicken (Search, Progress, Results, etc.), aber da passiert nichts, die GUI wird nur "refreshed"!

    Gruß,
    UEZ

  • StringRegExp - kurze Hilfe bitte

    • UEZ
    • 13. Februar 2011 um 13:33

    Hier noch eine Variante:

    [autoit]


    $werte = StringRegExp(ClipGet(), ".*\s\t(\d.*)", 3)

    [/autoit]

    Gruß,
    UEZ

  • StringRegExp - kurze Hilfe bitte

    • UEZ
    • 12. Februar 2011 um 20:51

    Probiere mal

    [autoit]


    $werte = StringRegExp(ClipGet(), ".*\s\n*.(\d.*)", 3)

    [/autoit]

    Br,
    UEZ

  • StringRegExp - kurze Hilfe bitte

    • UEZ
    • 12. Februar 2011 um 20:37

    Wie soll das Ergebnis aussehen? Zeile 2-8 in ein Array?

    Gruß,
    UEZ

  • StringStripWS bei StdoutRead

    • UEZ
    • 11. Februar 2011 um 12:10

    Ist auch eine Modifikation deines Skriptes, nur das du die Whitespaces Blanks heraus haben wolltest!

    Deins hat noch die Blanks, meins nicht!

    Gruß,
    UEZ

  • StringStripWS bei StdoutRead

    • UEZ
    • 11. Februar 2011 um 11:57

    Probiere es mal so:

    [autoit]


    #include <Array.au3>
    Dim $iPID = Run(@ComSpec & " /c " & "netsh wlan show networks mode=bssid", "", @SW_HIDE, 0x2)
    Dim $sLine = ""

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

    While 1
    $Line = StdoutRead($iPID)
    If @error Then ExitLoop
    $sLine &= StringStripWS($Line, 5)
    WEnd
    Dim $TempFileArray = StringSplit($sLine, @CR, 2)

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

    ;~ For $i = 1 To $TempFileArray[0]
    ;~ $TempFileArray[$i] = StringStripWS($TempFileArray[$i], 7)
    ;~ Next

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

    _ArrayDisplay($TempFileArray)

    [/autoit]

    Gruß,
    UEZ

  • Head - Tail v0.65 Build 2011-03-15 Beta

    • UEZ
    • 11. Februar 2011 um 10:35

    In unserem Server File Migrationsprojekt kopieren wir per Robocopy Ordner und Dateien von einem Server zum Anderen und lassen die Ausgabe von Robocopy in eine Logdatei schreiben.
    Zum größten Teil werden diese Logfiles relative groß und wenn man das Resultat des Copyjobs sehen möchte, muss man die Logdateien öffnen, um das Resultat zu sehen, welches immer am Ende steht.
    Da die Logfiles meistens sehr groß werden können, ich hatte schon mal über 300 MB, dauert das Öffnen relativ lange, um nur die gewünschte Stelle (die letzten Zeilen) in der Logdatei zu sehen.
    Da ich aus meiner Studienzeit die Unix Befehle Head und Tail kenne, dachte ich, man könnte sie ja auch in AutoIt implementieren, um schnell die gewünschte Info zu bekommen.

    Head und Tail kann man aus der CMD als Command Line Tool einsetzen oder als GUI, wenn man direkt die Exe Datei per Mausklick startet.

    Limitierung: gesperrte Dateien kann man leider nicht öffnen.

    Hier die Command Line Parameter für Tail (Head ist analog):

    Code
    Usage:  Tail -f <file to load> [-b <bytes>] [-s filename to save]
                 [-c] [-g] [-h] [-v]
    
    
    
    
    Mandatory:
    
    
            -f      <file to open>
    
    
    Options:
    
    
            -b      Bytes to read from end of the file. Default is 512.
                    Must be greater than 0 and smaller than 8MB!
            -s      Save output to a file. If file already exists it will be
                    overwritten  without confirmation!
                    Not working together with parameter -c!
            -c      Read file continuously
            -g      Enable GUI using commandline parameter
            -h      Displays this page
            -v      program version information
    Alles anzeigen

    Head zeigt den "Kopf" und Tail das Ende einer Datei an.

    Um die Command Line Version zu benutzen, müssen die Skripte kompiliert sein!

    Head.au3

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Change2CUI=y
    #AutoIt3Wrapper_Res_Description=Head displays n bytes from the header of a file
    #AutoIt3Wrapper_Res_Fileversion=0.6.5.0
    #AutoIt3Wrapper_Res_LegalCopyright=UEZ 2011
    #AutoIt3Wrapper_Res_Language=1033
    #AutoIt3Wrapper_Res_Field=Coded by|UEZ
    #AutoIt3Wrapper_Res_Field=Build|2011-03-15 beta
    #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
    #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_UPX_Parameters=--ultra-brute --crp-ms=999999 --all-methods --all-filters
    #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
    #AutoIt3Wrapper_Run_After=Upack.exe %out% -c6 -f273 -red
    ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

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

    Opt("MustDeclareVars", 1)
    #include <EditConstants.au3>
    #include <File.au3>
    #include <GUIConstantsEx.au3>
    #include <Process.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    Global Const $name = "Head ", $ver = "v0.65 ", $build = "Build 2011-03-15 beta ", $coder = "by UEZ"
    Global $filename, $bytes = 512, $gui = False, $save = False, $hGUI, $hEdit, $i, $var

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

    If _ProcessGetName(_WinAPI_GetParentProcess(@AutoItPID)) = "cmd.exe" Then
    If Not $CmdLine[0] Then Help()
    CheckParameter()
    Else
    $var = WinList()
    For $i = 1 To $var[0][0]
    If $var[$i][0] <> "" And BitAND(WinGetState($var[$i][1]), 2) Then
    If WinGetProcess($var[$i][0], "") = @AutoItPID Then
    WinSetState($var[$i][1], "", @SW_HIDE)
    ExitLoop
    EndIf
    EndIf
    Next
    GUI(0)
    EndIf

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

    If $gui Then
    GUI($filename)
    Else
    PrintHeadofFile($filename)
    EndIf
    Exit

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

    Func GUI($filename)
    Local $nMsg
    If Not $filename Then
    $filename = FileOpenDialog("Select a file", "", "All Files (*.*)")
    If @error Then Exit MsgBox(16, "Error", "No file selected! Closing...", 10)
    Else
    If Not FileExists($filename) Then Exit MsgBox(16, "ERROR ", $filename & " not found! Please check filename and try again.")
    EndIf
    $hGUI = GUICreate($name & $ver & $build & $coder, 800, 600)
    $hEdit = GUICtrlCreateEdit("", 0, 0, 800, 600, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSendMsg($hEdit, $EM_LIMITTEXT, -1, 0)
    GUICtrlSetFont($hEdit, 12, 400, 0, "Courier New")
    GUICtrlSetBkColor($hEdit, 0xFFFFFF)
    GUISetState(@SW_SHOW)
    $gui = True
    PrintHeadofFile($filename)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd
    EndFunc ;==>GUI

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

    Func PrintHeadofFile($filename)
    Local $data, $em, $hSave
    Local Const $fsize = FileGetSize($filename)
    If FileGetSize($filename) < $bytes Then $bytes = $fsize
    If $bytes > 0x7FFFFF Then $bytes = 512
    Local $hFile = FileOpen($filename, 0)
    If $hFile = -1 Then
    $em = "ERROR: unable to open file. The file may has been locked by another process."
    If Not $gui Then
    ConsoleWrite(@CRLF & $em & @CRLF & @CRLF)
    Exit
    Else
    GUICtrlSetData($hEdit, $em)
    Return
    EndIf
    EndIf
    $data = FileRead($hFile, $bytes)
    FileClose($hFile)
    If Not $gui Then
    ConsoleWrite(@CRLF & $data & @CRLF & @CRLF)
    Else
    GUICtrlSetData($hEdit, $data)
    EndIf
    If $save Then
    $hSave = FileOpen($save, 2)
    If $hSave = -1 Then Exit ConsoleWrite(@CRLF & "ERROR: " & $save & " could not be created!" & @CRLF & @CRLF)
    FileWrite($hSave, $data)
    FileClose($hSave)
    EndIf
    $data = ""
    EndFunc

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

    ;~ Func PrintHeadOfFile($filename)
    ;~ Local $nBytes, $data, $em, $hSave
    ;~ Local Const $fsize = FileGetSize($filename)
    ;~ If FileGetSize($filename) < $bytes Then $bytes = $fsize
    ;~ If $bytes > 0x7FFFFF Then $bytes = 512
    ;~ Local $tBuffer = DllStructCreate("byte[" & $bytes & "]")
    ;~ Local $hFile = _WinAPI_CreateFile($filename, 2, 7)
    ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hFile = ' & $hFile & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    ;~ If Not $hFile Then
    ;~ $em = "ERROR: unable to open file. The file may has been locked by another process."
    ;~ If Not $gui Then
    ;~ ConsoleWrite(@CRLF & $em & @CRLF & @CRLF)
    ;~ Exit
    ;~ Else
    ;~ GUICtrlSetData($hEdit, $em)
    ;~ Return
    ;~ EndIf
    ;~ EndIf
    ;~ _WinAPI_SetFilePointer($hFile, 0)
    ;~ _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $bytes, $nBytes)
    ;~ _WinAPI_CloseHandle($hFile)
    ;~ $data = BinaryToString(DllStructGetData($tBuffer, 1))
    ;~ $tBuffer = ""
    ;~ If Not $gui Then
    ;~ ConsoleWrite(@CRLF & $data & @CRLF & @CRLF)
    ;~ Else
    ;~ GUICtrlSetData($hEdit, $data)
    ;~ EndIf
    ;~ If $save Then
    ;~ $hSave = FileOpen($save, 2)
    ;~ If $hSave = -1 Then Exit ConsoleWrite(@CRLF & "ERROR: " & $save & " could not be created!" & @CRLF & @CRLF)
    ;~ FileWrite($hSave, $data)
    ;~ FileClose($hSave)
    ;~ EndIf
    ;~ EndFunc ;==>PrintHeadOfFile

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

    Func CheckParameter()
    Local $i, $u = UBound($CmdLine)
    If $CmdLine[1] = "-v" Then Version()
    If $CmdLine[1] = "-h" Then Help()
    If $u = 2 Then Help()
    While $i < $u
    If $i < $u - 1 Then
    If $CmdLine[$i] = "-f" Then $filename = $CmdLine[$i + 1]
    If $CmdLine[$i] = "-b" Then $bytes = $CmdLine[$i + 1]
    If $CmdLine[$i] = "-s" Then $save = $CmdLine[$i + 1]
    EndIf
    If $CmdLine[$i] = "-g" Then $gui = True
    $i += 1
    WEnd
    If $bytes < 1 Then Help()
    If $filename = "" Then Exit ConsoleWrite(@CRLF & "ERROR: Value for parameter -f is missing!" & @CRLF & @CRLF)
    If Not FileExists($filename) Then Exit ConsoleWrite(@CRLF & "ERROR: " & $filename & " not found! Please check filename and try again." & @CRLF & @CRLF)
    $filename = _PathFull($filename)
    EndFunc ;==>CheckParameter

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

    Func Help()
    ConsoleWrite(@CRLF & _
    "Usage:" & @TAB & _
    "Head -f <file to load> [-b <bytes>] [-s filename to save] [-g] [-h] [-v]" & @CRLF & @CRLF & @CRLF & _
    "Mandatory:" & @CRLF & @CRLF & _
    @TAB & "-f" & @TAB & "<file to open>" & @CRLF & @CRLF & _
    "Options:" & @CRLF & @CRLF & _
    @TAB & "-b" & @TAB & "Bytes to read from beginning of the file. Default is " & $bytes & "." & @CRLF & @TAB & @TAB & "Must be greater than 0 and smaller than 8MB!" & @CRLF & _
    @TAB & "-s" & @TAB & "Save output to a file. If file already exists it will be" & @CRLF & @TAB & @TAB & "overwritten without confirmation!" & @CRLF & _
    @TAB & "-g" & @TAB & "Enable GUI using commandline parameter" & @CRLF & _
    @TAB & "-h" & @TAB & "Displays this page" & @CRLF & _
    @TAB & "-v" & @TAB & "program version information" & @CRLF & @CRLF)
    Exit
    EndFunc ;==>Help

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

    Func Version()
    ConsoleWrite(@CRLF & $name & $ver & $build & $coder & @CRLF & @CRLF & @CRLF)
    Exit
    EndFunc ;==>Version

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

    Func _WinAPI_GetParentProcess($PID = 0) ;from WinAPIEx.au3 by Yashied
    If Not $PID Then
    $PID = _WinAPI_GetCurrentProcessID()
    If Not $PID Then
    Return SetError(1, 0, 0)
    EndIf
    EndIf
    Local $hSnapshot = DllCall('kernel32.dll', 'ptr', 'CreateToolhelp32Snapshot', 'dword', 0x00000002, 'dword', 0)
    If (@error) Or (Not $hSnapshot[0]) Then
    Return SetError(1, 0, 0)
    EndIf
    Local $tPROCESSENTRY32 = DllStructCreate('dword Size;dword Usage;dword ProcessID;ulong_ptr DefaultHeapID;dword ModuleID;dword Threads;dword ParentProcessID;long PriClassBase;dword Flags;wchar ExeFile[260]')
    Local $pPROCESSENTRY32 = DllStructGetPtr($tPROCESSENTRY32)
    Local $Ret, $Result = 0
    $hSnapshot = $hSnapshot[0]
    DllStructSetData($tPROCESSENTRY32, 'Size', DllStructGetSize($tPROCESSENTRY32))
    $Ret = DllCall('kernel32.dll', 'int', 'Process32FirstW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
    While (Not @error) And ($Ret[0])
    If DllStructGetData($tPROCESSENTRY32, 'ProcessID') = $PID Then
    $Result = DllStructGetData($tPROCESSENTRY32, 'ParentProcessID')
    ExitLoop
    EndIf
    $Ret = DllCall('kernel32.dll', 'int', 'Process32NextW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
    WEnd
    _WinAPI_CloseHandle($hSnapshot)
    If Not $Result Then
    Return SetError(1, 0, 0)
    EndIf
    Return $Result
    EndFunc ;==>_WinAPI_GetParentProcess

    [/autoit]

    Tail.au3

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Change2CUI=y
    #AutoIt3Wrapper_Res_Description=Tail displays n bytes from the tail of a file
    #AutoIt3Wrapper_Res_Fileversion=0.6.5.0
    #AutoIt3Wrapper_Res_LegalCopyright=UEZ 2011
    #AutoIt3Wrapper_Res_Language=1033
    #AutoIt3Wrapper_Res_Field=Coded by|UEZ
    #AutoIt3Wrapper_Res_Field=Build|2011-03-15 beta
    #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
    #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_UPX_Parameters=--ultra-brute --crp-ms=999999 --all-methods --all-filters
    #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
    #AutoIt3Wrapper_Run_After=Upack.exe %out% -c6 -f273 -red
    ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

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

    #include <EditConstants.au3>
    #include <File.au3>
    #include <FileConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <Process.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    Opt("MustDeclareVars", 1)

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

    Global Const $name = "Tail ", $ver = "v0.65 ", $build = "Build 2011-03-15 beta ", $coder = "by UEZ"
    Global $filename, $hFile, $hGUI, $hEdit, $i, $var, $bytes = 512, $gui = False, $save = False, $cont = False, $go = True
    Global $fsize_old, $fsize_new

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

    If _ProcessGetName(_WinAPI_GetParentProcess(@AutoItPID)) = "cmd.exe" Then
    If Not $CmdLine[0] Then Help()
    CheckParameter()
    Else
    $var = WinList()
    For $i = 1 To $var[0][0]
    If $var[$i][0] <> "" And BitAND(WinGetState($var[$i][1]), 2) Then
    If WinGetProcess($var[$i][0], "") = @AutoItPID Then
    WinSetState($var[$i][1], "", @SW_HIDE)
    ExitLoop
    EndIf
    EndIf
    Next
    GUI(0)
    EndIf

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

    If $gui Then
    GUI($filename)
    Else
    PrintTailOfFile($filename)
    EndIf
    Exit

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

    Func GUI($filename)
    Local $nMsg
    If Not $filename Then
    $filename = FileOpenDialog("Select a file", "", "All Files (*.*)")
    If @error Then Exit MsgBox(16, "Error", "No file selected! Closing...", 10)
    Else
    If Not FileExists($filename) Then Exit MsgBox(16, "ERROR ", $filename & " not found! Please check filename and try again.")
    EndIf
    $hGUI = GUICreate($name & $ver & $build & $coder, 800, 600)
    $hEdit = GUICtrlCreateEdit("", 0, 0, 800, 600, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSendMsg($hEdit, $EM_LIMITTEXT, -1, 0)
    GUICtrlSetFont($hEdit, 12, 400, 0, "Courier New")
    GUICtrlSetBkColor($hEdit, 0xFFFFFF)
    GUISetState(@SW_SHOW)
    $gui = True
    PrintTailOfFile($filename)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd
    EndFunc ;==>GUI

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

    Func PrintTailOfFile($filename)
    Local $pos, $data, $em, $hSave
    Local Const $fsize = FileGetSize($filename)
    If FileGetSize($filename) < $bytes Then $bytes = $fsize
    If $bytes > 0x7FFFFF Then $bytes = 512
    $hFile = FileOpen($filename)
    If $hFile = -1 Then
    $em = "ERROR: unable to open file. The file may has been locked by another process."
    PrintError($em)
    EndIf
    $pos = FileSetPos($hFile, -$bytes, $FILE_END)
    If Not $pos Then
    $em = "ERROR: unable to set file position."
    PrintError($em)
    EndIf
    $data = FileRead($hFile)
    If Not $gui Then
    If Not $cont Then
    ConsoleWrite(@CRLF & $data & @CRLF & @CRLF)
    Else
    ConsoleWrite(@CRLF & $data)
    EndIf
    Else
    GUICtrlSetData($hEdit, $data)
    EndIf
    If $cont Then Cont()
    FileClose($hFile)
    If $save And Not $cont Then
    $hSave = FileOpen($save, 2)
    If $hSave = -1 Then Exit ConsoleWrite(@CRLF & "ERROR: " & $save & " could not be created!" & @CRLF & @CRLF)
    FileWrite($hSave, $data)
    FileClose($hSave)
    EndIf
    $data = ""
    EndFunc ;==>PrintTailOfFile

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

    Func PrintError($em)
    If Not $gui Then
    ConsoleWrite(@CRLF & $em & @CRLF & @CRLF)
    Exit
    Else
    GUICtrlSetData($hEdit, $em)
    Return
    EndIf
    EndFunc ;==>PrintError

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

    Func Cont()
    Local $data, $pos, $dll = DllOpen("user32.dll")
    FileClose($hFile)
    $fsize_old = FileGetSize($filename)
    While Sleep(250) * $go
    $fsize_new = FileGetSize($filename)
    $hFile = FileOpen($filename)
    If $fsize_new > $fsize_old Then
    $pos = FileSetPos($hFile, -($fsize_new - $fsize_old - 1), $FILE_END)
    $fsize_old = $fsize_new
    $data = FileRead($hFile)
    If Not $gui Then
    ConsoleWrite($data)
    Else
    GUICtrlSetData($hEdit, $data, 1)
    EndIf
    EndIf
    FileClose($hFile)
    If _IsPressed("1B", $dll) Then $go = False
    WEnd
    DllClose($dll)
    EndFunc

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

    ;~ Func PrintTailOfFile($filename)
    ;~ Local $nBytes, $data, $em, $hSave
    ;~ Local Const $fsize = FileGetSize($filename)
    ;~ If FileGetSize($filename) < $bytes Then $bytes = $fsize
    ;~ If $bytes > 0x7FFFFF Then $bytes = 512
    ;~ Local $tBuffer = DllStructCreate("byte[" & $bytes & "]")
    ;~ Local $hFile = _WinAPI_CreateFile($filename, 2, 7)
    ;~ If Not $hFile Then
    ;~ $em = "ERROR: unable to open file. The file may has been locked by another process."
    ;~ If Not $gui Then
    ;~ ConsoleWrite(@CRLF & $em & @CRLF & @CRLF)
    ;~ Exit
    ;~ Else
    ;~ GUICtrlSetData($hEdit, $em)
    ;~ Return
    ;~ EndIf
    ;~ EndIf
    ;~ _WinAPI_SetFilePointer($hFile, -$bytes, 2)
    ;~ _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $bytes, $nBytes)
    ;~ _WinAPI_CloseHandle($hFile)
    ;~ $data = BinaryToString(DllStructGetData($tBuffer, 1))
    ;~ $tBuffer = ""
    ;~ If Not $gui Then
    ;~ ConsoleWrite(@CRLF & $data & @CRLF & @CRLF)
    ;~ Else
    ;~ GUICtrlSetData($hEdit, $data)
    ;~ EndIf
    ;~ If $save Then
    ;~ $hSave = FileOpen($save, 2)
    ;~ If $hSave = -1 Then Exit ConsoleWrite(@CRLF & "ERROR: " & $save & " could not be created!" & @CRLF & @CRLF)
    ;~ FileWrite($hSave, $data)
    ;~ FileClose($hSave)
    ;~ EndIf
    ;~ EndFunc ;==>PrintTailOfFile

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

    Func CheckParameter()
    Local $i, $u = UBound($CmdLine)
    If $CmdLine[1] = "-v" Then Version()
    If $CmdLine[1] = "-h" Then Help()
    If $u = 2 Then Help()
    While $i < $u
    If $i < $u - 1 Then
    If $CmdLine[$i] = "-f" Then $filename = $CmdLine[$i + 1]
    If $CmdLine[$i] = "-b" Then $bytes = $CmdLine[$i + 1]
    If $CmdLine[$i] = "-s" Then $save = $CmdLine[$i + 1]
    EndIf
    If $CmdLine[$i] = "-c" Then $cont = True
    If $CmdLine[$i] = "-g" Then $gui = True
    $i += 1
    WEnd
    If $bytes < 1 Then Help()
    If $filename = "" Then Exit ConsoleWrite(@CRLF & "ERROR: Value for parameter -f is missing!" & @CRLF & @CRLF)
    If Not FileExists($filename) Then Exit ConsoleWrite(@CRLF & "ERROR: " & $filename & " not found! Please check filename and try again." & @CRLF & @CRLF)
    $filename = _PathFull($filename)
    EndFunc ;==>CheckParameter

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

    Func Help()
    ConsoleWrite(@CRLF & _
    "Usage:" & @TAB & _
    "Tail -f <file to load> [-b <bytes>] [-s filename to save]" & @CRLF & @TAB & " [-c] [-g] [-h] [-v]" & @CRLF & @CRLF & @CRLF & _
    "Mandatory:" & @CRLF & @CRLF & _
    @TAB & "-f" & @TAB & "<file to open>" & @CRLF & @CRLF & _
    "Options:" & @CRLF & @CRLF & _
    @TAB & "-b" & @TAB & "Bytes to read from end of the file. Default is " & $bytes & "." & @CRLF & @TAB & @TAB & "Must be greater than 0 and smaller than 8MB!" & @CRLF & _
    @TAB & "-s" & @TAB & "Save output to a file. If file already exists it will be" & @CRLF & @TAB & @TAB & "overwritten without confirmation!" & @CRLF & @TAB & @TAB & "Not working together with parameter -c!" & @CRLF & _
    @TAB & "-c" & @TAB & "Read file continuously" & @CRLF & _
    @TAB & "-g" & @TAB & "Enable GUI using commandline parameter" & @CRLF & _
    @TAB & "-h" & @TAB & "Displays this page" & @CRLF & _
    @TAB & "-v" & @TAB & "program version information" & @CRLF & @CRLF)
    Exit
    EndFunc ;==>Help

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

    Func Version()
    ConsoleWrite(@CRLF & $name & $ver & $build & $coder & @CRLF & @CRLF & @CRLF)
    Exit
    EndFunc ;==>Version

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

    Func _WinAPI_GetParentProcess($PID = 0) ;from WinAPIEx.au3 by Yashied
    If Not $PID Then
    $PID = _WinAPI_GetCurrentProcessID()
    If Not $PID Then Return SetError(1, 0, 0)
    EndIf
    Local $hSnapshot = DllCall('kernel32.dll', 'ptr', 'CreateToolhelp32Snapshot', 'dword', 0x00000002, 'dword', 0)
    If (@error) Or (Not $hSnapshot[0]) Then Return SetError(1, 0, 0)
    Local $tPROCESSENTRY32 = DllStructCreate('dword Size;dword Usage;dword ProcessID;ulong_ptr DefaultHeapID;dword ModuleID;dword Threads;dword ParentProcessID;long PriClassBase;dword Flags;wchar ExeFile[260]')
    Local $pPROCESSENTRY32 = DllStructGetPtr($tPROCESSENTRY32)
    Local $Ret, $Result = 0
    $hSnapshot = $hSnapshot[0]
    DllStructSetData($tPROCESSENTRY32, 'Size', DllStructGetSize($tPROCESSENTRY32))
    $Ret = DllCall('kernel32.dll', 'int', 'Process32FirstW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
    While (Not @error) And ($Ret[0])
    If DllStructGetData($tPROCESSENTRY32, 'ProcessID') = $PID Then
    $Result = DllStructGetData($tPROCESSENTRY32, 'ParentProcessID')
    ExitLoop
    EndIf
    $Ret = DllCall('kernel32.dll', 'int', 'Process32NextW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
    WEnd
    _WinAPI_CloseHandle($hSnapshot)
    If Not $Result Then Return SetError(1, 0, 0)
    Return $Result
    EndFunc ;==>_WinAPI_GetParentProcess

    [/autoit]

    Skripte + Exe Dateien als Download: Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    Die meisten werden Head und Tail nicht gebrauchen, aber vielleicht doch einige Wenige. :)

    Gruß,
    UEZ

    Dateien

    Head-Tail v0.65 Build 2011-03-15 beta (source + exe).7z 289,58 kB – 622 Downloads
  • Label Größe dynamisch anpassen

    • UEZ
    • 9. Februar 2011 um 09:40

    Ich wollte eigentlich mal kein GDI+ direkt verwenden.

    Alle anderen Controls werden auch entsprechend "gesized", also warum auch nicht ein Label Control? Anscheinend geht das nicht so einfach. Ich finde das optisch nicht schön, wenn man die Größe des Fensters verändert und nur das Label gleich bleibt.

    Suche weiter...

    Gruß,
    UEZ

  • Label Größe dynamisch anpassen

    • UEZ
    • 8. Februar 2011 um 23:19

    Hat jemand noch eine Idee, wie man die Darstellung noch besser hinbekommt? Siehe Post#8!

    Gruß,
    UEZ

  • Label Größe dynamisch anpassen

    • UEZ
    • 8. Februar 2011 um 01:03

    Das kommt der Sacher näher, aber die Schrift sieht nun mist aus:

    Spoiler anzeigen
    [autoit]


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

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

    _GDIPlus_Startup()
    Global $hGUI = GUICreate("Test", 800, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_MAXIMIZEBOX))
    Global $group = GUICtrlCreateGroup("", 224, 0, 569, 92)
    Global $pic = GUICtrlCreatePic("", 226, 8, 565, 82)
    GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $hBmp = CreateLogo("Label soll sich dyn. anpassen", "Impact")
    Global Const $STM_SETIMAGE = 0x0172
    GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBmp)
    GUISetState(@SW_SHOW)

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

    Global $aWDim = WinGetPos($hGUI)
    Global $w = $aWDim[2], $h = $aWDim[3]
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    _WinAPI_DeleteObject($hBmp)
    GUIDelete($hGUI)
    _GDIPlus_Shutdown()
    Exit
    Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
    EndSwitch
    WEnd

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

    Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $w) ; min X
    DllStructSetData($minmaxinfo, 8, $h) ; min Y
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_GETMINMAXINFO

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

    Func CreateLogo($text, $fname, $fsize = 60, $brushcolor = 0xFF000080)
    Local $hBrush = _GDIPlus_BrushCreateSolid($brushcolor)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $tLayout = _GDIPlus_RectFCreate (0, 0, 0, 0)
    Local $hFamily = _GDIPlus_FontFamilyCreate($fname)
    Local $hFont = _GDIPlus_FontCreate ($hFamily, $fsize, 0)
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle(AutoItWinGetTitle()))
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $text, $hFont, $tLayout, $hFormat)
    Local $width = Floor(DllStructGetData($aInfo[0], "Width") * 0.98)
    Local $height = Floor(DllStructGetData($aInfo[0], "Height") * 0.925)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($width, $height)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
    _GDIPlus_GraphicsClear($hContext, "0xFF" & Hex(_WinAPI_GetSysColor($COLOR_3DFACE), 6))
    _GDIPlus_GraphicsDrawStringEx ($hContext, $text, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_StringFormatDispose ($hFormat)
    _GDIPlus_BrushDispose ($hBrush)
    _GDIPlus_GraphicsDispose ($hContext)
    Local $hImage = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_ImageDispose($hBitmap)
    Return $hImage
    EndFunc

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

    Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[6]
    EndFunc ;==>_GDIPlus_BitmapCreateFromScan0

    [/autoit]

    Vielleicht bekomme es auch noch hin, dass die Schrift "sauber" aussieht.

    Ich weiß nicht, ob das noch besser geht!

    Gruß,
    UEZ

  • GDI+ Bitmap skalieren

    • UEZ
    • 7. Februar 2011 um 20:54

    Probiere es mal damit:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2011
    #include <GDIPlus.au3>

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

    $file = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*bmp;*gif,*.tif)")
    If @error Then Exit
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($file)
    $newBitmap = Scale_Image($hImage, 320, 256)
    _GDIPlus_ImageSaveToFile($newBitmap, @ScriptDir & "\Test.jpg")
    ShellExecute(@ScriptDir & "\Test.jpg")

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

    Func Scale_Image($hImage, $newW, $newH)
    Local $newImage = _GDIPlus_BitmapCreateFromScan0($newW, $newH)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($newImage)
    _GDIPlus_GraphicsSetInterpolationMode($hContext, 7)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $newW, $newH)
    _GDIPlus_GraphicsDispose($hContext)
    Return SetError(0, 0, $newImage)
    EndFunc

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

    Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[6]
    EndFunc ;==>_GDIPlus_BitmapCreateFromScan0

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

    Func _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGraphics, "int", $iInterpolationMode)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
    EndFunc ;==>_GDIPlus_GraphicsSetInterpolationMode

    [/autoit]

    Gruß,
    UEZ

  • SSD - Hilfe bei Kaufentscheidung

    • UEZ
    • 7. Februar 2011 um 20:47

    Na dann viel Spaß damit!

    Gruß,
    UEZ

  • Befindet sich Punkt in Polygon?

    • UEZ
    • 7. Februar 2011 um 15:33

    Vielleicht hilft dir dies weiter:

    Spoiler anzeigen
    [autoit]


    ;http://www.autoitscript.com/forum/index.php?showtopic=89034
    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    Opt('MustDeclareVars', 1)
    Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client

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

    Global $hGUI, $hBMPBuff, $hGraphicGUI, $hGraphic

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

    _Main()

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

    Func _Main()
    Local $msg, $aPos, $GuiSizeX = 400, $GuiSizeY = 300
    Local $aPoints[7][2], $aTriangle[5][2]
    Local $hButton
    ; Create GUI
    $hGUI = GUICreate("GDI+", $GuiSizeX, $GuiSizeY)

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

    GUISetState()

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

    _GDIPlus_Startup()
    ;Double Buffer
    $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY - 65, $hGraphicGUI)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff)
    ;End Double Buffer add-on 1 of 3

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

    _GDIPlus_GraphicsClear($hGraphic, 0xFFE8FFEF)

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

    $aPoints[0][0] = 5; Number of sides of Polygon
    $aPoints[1][0] = 100
    $aPoints[1][1] = 100
    $aPoints[2][0] = 200
    $aPoints[2][1] = 150
    $aPoints[3][0] = 200
    $aPoints[3][1] = 200
    $aPoints[4][0] = 150
    $aPoints[4][1] = 100
    $aPoints[5][0] = 70
    $aPoints[5][1] = 200
    $aPoints[6][0] = 100;Last point same as 1st point. Polygon is closed
    $aPoints[6][1] = 100
    _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints)

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

    Local $iRectX = 220, $iRectY = 25, $iRectWidth = 100, $iRectHth = 50
    _GDIPlus_GraphicsDrawRect($hGraphic, $iRectX, $iRectY, $iRectWidth, $iRectHth)

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

    Local $iElpsX = 220, $iElpsY = 180, $iElpsWidth = 130, $iElpsHth = 70
    _GDIPlus_GraphicsDrawEllipse($hGraphic, $iElpsX, $iElpsY, $iElpsWidth, $iElpsHth)

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

    $aTriangle[0][0] = 3; Number of sides of Polygon
    $aTriangle[1][0] = 30
    $aTriangle[1][1] = 30
    $aTriangle[2][0] = 150
    $aTriangle[2][1] = 40
    $aTriangle[3][0] = 50
    $aTriangle[3][1] = 100
    $aTriangle[4][0] = 30;Last point same as 1st point. Polygon is closed
    $aTriangle[4][1] = 30
    _GDIPlus_GraphicsFillPolygon($hGraphic, $aTriangle)

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

    $hButton = GUICtrlCreateButton("In Circle", 22, 240, 75, 20)

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

    Local $iCircleX = 20, $iCircleY = 210, $iCircleWidth = 80, $iCircleHth = 80
    _GDIPlus_GraphicsFillEllipse($hGraphic, $iCircleX, $iCircleY, $iCircleWidth, $iCircleHth)

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

    ConsoleWrite("Area of Polygon = " & _AreaPoly($aPoints) & @CRLF)
    Local $aCent = _CentroidPoly($aPoints)
    ConsoleWrite("Centroid of Polygon: cX = " & $aCent[0] & " cY = " & $aCent[1] & @CRLF)

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

    ; Create Double Buffer, doesn't need to be repainted on PAINT-Event
    GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3)
    GUIRegisterMsg(0x85, "MY_PAINT"); $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize.
    _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
    ;End Double Buffer add-on 2 of 3

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

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hGraphicGUI)
    _WinAPI_DeleteObject($hBMPBuff)
    _GDIPlus_Shutdown()
    Exit
    Case $hButton
    MsgBox(0, "", "Button Pressed. ")
    Case $GUI_EVENT_MOUSEMOVE
    $aPos = MouseGetPos()
    ToolTip("Mouse Position X: " & $aPos[0] & " Y: " & $aPos[1] & @CRLF & @CRLF & _
    "Cursor in Polygon: " & _PointInPoly($aPos[0], $aPos[1], $aPoints) & @CRLF & _
    "Cursor in Triangle: " & _PointInPoly($aPos[0], $aPos[1], $aTriangle) & @CRLF & _
    "Cursor in Ellipse: " & _PointInEllipse($aPos[0], $aPos[1], $iElpsX, $iElpsY, _
    $iElpsWidth, $iElpsHth) & @CRLF & _
    "Cursor in Circle: " & _PointInEllipse($aPos[0], $aPos[1], $iCircleX, $iCircleY, _
    $iCircleWidth, $iCircleHth) & @CRLF & _
    "Cursor in Rectangle: " & _WinAPI_PtInRectEx($aPos[0], $aPos[1], $iRectX, $iRectY, _
    $iRectX + $iRectWidth, $iRectY + $iRectHth) & @CRLF)
    Case $GUI_EVENT_PRIMARYUP
    $aPos = MouseGetPos()
    Select
    Case _PointInPoly($aPos[0], $aPos[1], $aPoints)
    ToolTip("")
    MsgBox(0, "", "Clicked in PolyGon")
    Case _WinAPI_PtInRectEx($aPos[0], $aPos[1], $iRectX, $iRectY, $iRectX + $iRectWidth, _
    $iRectY + $iRectHth)
    ToolTip("")
    MsgBox(0, "", "Clicked in Rectangle")
    Case _PointInEllipse($aPos[0], $aPos[1], $iElpsX, $iElpsY, $iElpsWidth, $iElpsHth)
    ToolTip("")
    MsgBox(0, "", "Clicked in Ellipse")
    Case _PointInPoly($aPos[0], $aPos[1], $aTriangle)
    ToolTip("")
    MsgBox(0, "", "Clicked in Triangle")
    Case _PointInEllipse($aPos[0], $aPos[1], $iCircleX, $iCircleY, $iCircleWidth, $iCircleHth)
    ToolTip("")
    MsgBox(0, "", "Clicked in Invisible Circle")

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

    EndSelect
    EndSwitch
    WEnd
    EndFunc ;==>_Main

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

    ; Returns the area of a polygon
    Func _AreaPoly($aPoints)
    Local $Med
    For $n = 1 To UBound($aPoints) - 2
    $Med += $aPoints[$n][0] * $aPoints[$n + 1][1] - $aPoints[$n + 1][0] * $aPoints[$n][1]
    Next
    Return $Med / 2
    EndFunc ;==>_AreaPoly

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

    ; Returns an array containing the x, y position of the centroid of a polygon.
    Func _CentroidPoly($aPoints)
    Local $Med, $aRet[2], $MedX, $MedY, $Area
    For $n = 1 To UBound($aPoints) - 2
    $MedX += ($aPoints[$n][0] + $aPoints[$n + 1][0]) * ($aPoints[$n][0] * $aPoints[$n + 1][1] - _
    $aPoints[$n + 1][0] * $aPoints[$n][1])
    $MedY += ($aPoints[$n][1] + $aPoints[$n + 1][1]) * ($aPoints[$n][0] * $aPoints[$n + 1][1] - _
    $aPoints[$n + 1][0] * $aPoints[$n][1])
    Next
    $Area = _AreaPoly($aPoints)
    $aRet[0] = $MedX / ($Area * 6)
    $aRet[1] = $MedY / ($Area * 6)
    Return $aRet
    EndFunc ;==>_CentroidPoly

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

    ; ($xPt, $yPt) - x, y position of the point to check
    ; $xTL, $yTL, Top left x Pos, top left Y position of the rectangle encompassing the ellipse.
    ; $w, $h - The width an height of ellipse
    ; Method: The distance from the 1st focal point to a point on the perimeter plus the distance from
    ; the second focal point to the same point on the perimeter is a constant and equals the width of
    ; the ellipse, the major axis. So, if the sum of the two distances form the point to check to the
    ; two foci is greater than the major axis, then the point is outside the ellipse.
    Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
    Local $bInside = False, $a = $w / 2, $b = $h / 2
    Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
    $c1X = $xc - ($a ^ 2 - $b ^ 2) ^ 0.5; 1st focal point x position
    $c2X = $xc + ($a ^ 2 - $b ^ 2) ^ 0.5; 2nd focal point x position
    $dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
    If $dist <= $w Then $bInside = Not $bInside
    Return $bInside
    EndFunc ;==>_PointInEllipse

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

    ; ($iX, $iY) - x, y position of the point to check
    ; ($iLeft, $iTop) - x, y position of the top left corner of rectangle
    ; ($iRight, $iBottom) - x, y position of the bottom right corner of rectangle
    ;
    Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iRight, $iBottom)
    Local $aResult
    Local $tRect = DllStructCreate($tagRECT)
    DllStructSetData($tRect, "Left", $iLeft)
    DllStructSetData($tRect, "Top", $iTop)
    DllStructSetData($tRect, "Right", $iRight)
    DllStructSetData($tRect, "Bottom", $iBottom)
    $aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY)
    If @error Then Return SetError(@error, 0, False)
    Return $aResult[0] <> 0
    EndFunc ;==>_WinAPI_PtInRectEx

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

    ; ($x, $y) - x, y position of the point to check
    ; $aPoints - An array of x,y values representing the nodes of a polygon.
    ; Finds the individual x values of the interestion of the individual sides of the polygon with the
    ; line y = $y (parallel with x-axis). If the number of x values found greater than $x is even, then
    ; the ($x, $y) point is outside the closed polygon. Plus, if $y is beyond the y values of the end
    ; points of individual sides of the polygon, the y = $y line will not interest with that side and will
    ; not be counted. Returns equivalent of, even number of intersections false, and, odd true(inside polygon).
    ; Requires Iif()function
    Func _PointInPoly($x, $y, $aPoints)
    Local $bEvenNum = False, $xOnLine, $yMin, $yMax
    For $i = 1 To $aPoints[0][0]
    $yMin = Iif($aPoints[$i + 1][1] < $aPoints[$i][1], $aPoints[$i + 1][1], $aPoints[$i][1])
    $yMax = Iif($aPoints[$i + 1][1] > $aPoints[$i][1], $aPoints[$i + 1][1], $aPoints[$i][1])
    $xOnLine = -($y * $aPoints[$i + 1][0] - $y * $aPoints[$i][0] - $aPoints[$i][1] * $aPoints[$i + 1][0] + _
    $aPoints[$i][0] * $aPoints[$i + 1][1]) / (-$aPoints[$i + 1][1] + $aPoints[$i][1])
    If ($x < $xOnLine) And ($y > $yMin) And ($y <= $yMax) Then $bEvenNum = Not $bEvenNum
    Next
    Return $bEvenNum
    EndFunc ;==>_PointInPoly

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

    ; Same as _Iif() function from Misc.au3 include file
    Func Iif($fTest, $vTrueVal, $vFalseVal)
    If $fTest Then
    Return $vTrueVal
    Else
    Return $vFalseVal
    EndIf
    EndFunc ;==>Iif

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

    ;Func to redraw on PAINT MSG
    Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
    ; Check, if the GUI with the Graphic should be repainted
    _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
    _WinAPI_RedrawWindow($hGUI, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME));,$RDW_ALLCHILDREN
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_PAINT

    [/autoit]

    Gruß,
    UEZ

  • Label Größe dynamisch anpassen

    • UEZ
    • 7. Februar 2011 um 15:21

    Ich habe mal den Code aus meinem ersten Post angepasst.

    So ähnlich soll es sein, aber vielleicht etwas eleganter.

    Gruß,
    UEZ

  • Label Größe dynamisch anpassen

    • UEZ
    • 7. Februar 2011 um 14:56

    Die Schrift soll immer im Verhältnis zum Group Control stehen, so dass die Größe der Schrift sich mit dem Group Control beim Vergrößern / Verkleinern anpasst.

    Beispiel: wenn ich das Fenster maximiere, so vergrößert sich das Group Control, aber die Schrift bleibt gleich (kleiner)!

    Ich hoffe, dass es jetzt ein wenig klarer ist.

    Andy: das mit den GUICtrlSetResizing() Einstellungen funzt nicht, da nur das Label verschoben, aber nicht entsprechend skaliert wird.

    autoBert: danach habe ich auch gesucht. Danke!

    Gruß,
    UEZ

  • Label Größe dynamisch anpassen

    • UEZ
    • 7. Februar 2011 um 14:02

    Gibt es eine Möglichkeit das Label dynamisch an die GUI bzw. ans Group Control anzupassen, so dass beim Vergrößern bzw. Verkleinern (inkl. maximieren/minimieren des Fensters) das Label enstprechend vergrößert / verkleinert wird?

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <StructureConstants.au3>
    #include <WindowsConstants.au3>
    Global $hGUI = GUICreate("Test", 800, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_TABSTOP))
    Global $group = GUICtrlCreateGroup("", 224, 0, 569, 92)
    Global $title = GUICtrlCreateLabel("Label soll sich dyn. anpassen", 228, 14, 559, 75)

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

    GUICtrlSetColor(-1, 0x000080)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)

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

    Resize_Font()

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

    Global $aWDim = WinGetPos($hGUI)
    Global $w = $aWDim[2], $h = $aWDim[3]
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
    GUIRegisterMsg($WM_SIZE, "WM_SIZE")

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUIDelete($hGUI)
    Exit
    Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
    Resize_Font()
    EndSwitch
    WEnd

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

    Func Resize_Font()
    $aPOS = ControlGetPos("", "", $group)
    GUICtrlSetFont($title, $aPOS[2] / 17, 400, 0, "Impact")
    EndFunc

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

    Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    Resize_Font()
    Return "GUI_RUNDEFMSG"
    EndFunc

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

    Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $w) ; min X
    DllStructSetData($minmaxinfo, 8, $h) ; min Y
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_GETMINMAXINFO

    [/autoit]


    Gruß,
    UEZ

  • Schnitzel hat Geburtstag!

    • UEZ
    • 6. Februar 2011 um 22:12

    Auch von mir ein Happy Birthday und alles Gute zum Geburtstag!

    Gruß,
    UEZ

  • SSD - Hilfe bei Kaufentscheidung

    • UEZ
    • 6. Februar 2011 um 21:39

    PC Welt hat in der Ausgabe 2/2011 SSD 2.5" im Test:

    1. OCZ Vertex 2 (60GB)
    2. G. Skill Phoenix (60GB)
    3. Super Talent Teradrive CT (60GB)
    4. Patriot Inferno (60GB)
    5. A-Data S599 (64GB)

    Alle mit dem SandForce Chipsatz.

    Ferner ist ein guter Bericht in der letzten Ausgabe von PC Magazin (2/2011, S. 56ff) veröffentlicht, wie man am besten SSD implementiert.

    SSD ist am besten für Win7 geeignet, da es von Haus aus die TRIM Befehle mitbringt.

    Gruß,
    UEZ

  • mathematik frage

    • UEZ
    • 6. Februar 2011 um 15:22

    Ich habe auch so was ähnliches in GDI+ Pixel Text Effect Beta Build 2010-10-21 benötigt, wo ich ein Wort aus Pixel in ein anderes Wort aus Pixel "morphe".

    Anfangs- und Endkoodinaten waren bekannt, nur müssen die Pixel sich zur Endkoordinate mit einer Geschwindigkeit x bewegen.

    Gruß,
    UEZ

  • [GDI+] Rect auf Bmp Tranzparent setzten

    • UEZ
    • 5. Februar 2011 um 22:32

    Nach der GUI und GDI+ Initialisierung:

    Spoiler anzeigen
    [autoit]


    ...
    Global Const $GW_CHILD = 5
    Global Const $GW_HWNDNEXT = 2
    Global $hRegion = _GDIPlus_RegionCreateFromRect(_GDIPlus_RectFCreate(0, 0, $width, $height))
    Global $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD)
    Global $aRect
    Do
    $aRect = ControlGetPos($hChild, "", 0)
    _GDIPlus_RegionCombineRect($hRegion, _GDIPlus_RectFCreate($aRect[0], $aRect[1], $aRect[2], $aRect[3]), 3)
    $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT)
    Until Not $hChild
    _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion)
    _GDIPlus_RegionDispose($hRegion)
    ...

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

    Func _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion, $iCombineMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipRegion", "hwnd", $hGraphics, "hwnd", $hRegion, "int", $iCombineMode)

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

    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
    EndFunc

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

    Func _GDIPlus_RegionCreateFromRect($tRectF)
    Local $pRectF, $aResult

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

    $pRectF = DllStructGetPtr($tRectF)
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateRegionRect", "ptr", $pRectF, "int*", 0)

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

    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[2]
    EndFunc

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

    Func _GDIPlus_RegionCombineRect($hRegion, $tRectF, $iCombineMode = 2)
    Local $pRectF, $aResult

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

    $pRectF = DllStructGetPtr($tRectF)
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCombineRegionRect", "hwnd", $hRegion, "ptr", $pRectF, "int", $iCombineMode)

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

    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
    EndFunc

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

    Func _GDIPlus_RegionDispose($hRegion)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteRegion", "hwnd", $hRegion)

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

    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
    EndFunc

    [/autoit]

    Funktioniert mit Group Controls leider nicht!

    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™