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

  • UEZ hat Geburtstag

    • UEZ
    • 17. Februar 2011 um 20:52

    Danke auch denen, die nach meinem Beitrag gepostet haben und vielleicht noch posten werden!

    Danke an i2c für die schöne Animation! Mit GDI+ würde das nicht so schön aussehen! ;)

    Ich habe Dali als Avatar ausgewählt, weil er ein bissl Gaga im Kopf war. :D

    Mit Feiern ist heute nichts, da ich immer noch auf der Arbeit bin... 8|

    Gruß,
    UEZ

  • UEZ hat Geburtstag

    • UEZ
    • 17. Februar 2011 um 17:12

    VIELEN, VIELEN DANK FÜR DIE GLÜCKWÜNSCHE! :love:

    Prost auf weitere gute Zusammenarbeit und Happy Coding :party:

    autoBert: vielen Dank für das Geburtstagsskript! 8o

    Gruß,
    UEZ

    PS: midlife crisis nähert sich... :P

  • Frage zu StringRegExp

    • UEZ
    • 16. Februar 2011 um 18:28

    Vielleicht hilft dir das hier weiter: http://www.autoitscript.com/forum/topic/85…hacker-project/

    Gruß,
    UEZ

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

    • UEZ
    • 15. Februar 2011 um 15:26

    Hast recht. Das Handle ist 0, wenn die Datei nicht geöffnet werden kann!

    Gruß,
    UEZ

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

    • UEZ
    • 15. Februar 2011 um 09:01
    Zitat von funkey

    Vielen Dank UEZ für die 2 Skripte. Hab mir mal die Hauptfunktion von Tail für mich passend umgeschrieben.

    Spoiler anzeigen
    [autoit]


    Func _GetTailOfFile($filename, $bytes = 512, $save = 0)
    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, 2)
    If Not $hFile Then
    $em = "ERROR: unable to open file. Might be open by another process."
    Return SetError(1, "", $em)
    EndIf
    _WinAPI_SetFilePointer($hFile, -$bytes, 2)
    _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $bytes, $nBytes)
    _WinAPI_CloseHandle($hFile)
    $data = BinaryToString(DllStructGetData($tBuffer, 1))
    $tBuffer = ""

    If $save Then
    $hSave = FileOpen($save, 2)
    If $hSave = -1 Then
    $em = "ERROR: " & $save & " could not be created!"
    Return SetError(1, "", $em)
    EndIf
    FileWrite($hSave, $data)
    FileClose($hSave)
    EndIf
    Return $data
    EndFunc ;==>GetTailOfFile

    [/autoit]
    Alles anzeigen

    Ich habe auch ein _WinAPI_CloseHandle($hFile) beim Fehler Rücksprung vergessen -> zwischen Zeile 9 und 10 würde ich noch ein _WinAPI_CloseHandle($hFile) einbauen!

    Zitat von Großvater

    Moin UEZ,

    schau mal da: CreateFile

    Die Parameter dwDesiredAccess und dwShareMode regeln die Möglichkeiten für mehrere gleichzeitige Zugriffe auf eine Datei, soweit die Berechtigungen das überhaupt zulassen. Wenn z.B. eine Anwendung die Datei mit GENERIC_WRITE schreibend geöffnet hat und Du versuchst, sie mit GENERIC_READ lesend zu öffnen, brauchst Du zumindest den Sharemode FILE_SHARE_WRITE, sonst:


    Wenn ich das MSDN richtig verstehe, muss allerdings auch die andere Anwendung im CreateFile zumindest den Sharemode FILE_SHARE_READ gesetzt haben, sonst:


    In meinem Tool (nicht AU3) habe ich den Sharemode generell auf 0x7 (FILE_SHARE_READ + FILE_SHARE_WRITE + FILE_SHARE_DELETE) gesetzt. Es läuft immer mit Administratorrechten und kann so jederzeit auf die mich interessierenden Logdateien zugreifen, ohne dass sich die Anwendungen gegenseitig stören.

    Ob und ggf. welche Sharemodes die AU3-Funktion FileOpen() setzt, weiß ich nicht.

    Alles anzeigen

    Danke für die Quelle! Öffne ich die Datei mit _WinAPI_CreateFile($filename, 2, 4), so wird nichts angezeigt; mit _WinAPI_CreateFile($filename, 2, 7) geht's wieder. Jetzt muss ich testen, ob ich das File öffnen kann, wärend Robocopy fleißig in die Datei schreibt.

    Gruß,
    UEZ

  • Frage zu StringRegExp

    • UEZ
    • 14. Februar 2011 um 23:59

    Sind jetzt in deinem Beispiel beide Strings gleich?

    Gruß,
    UEZ

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

    • UEZ
    • 14. Februar 2011 um 20:55

    Keine Ahnung! Die WinAPI Funktion habe ich zuerst gesehen!

    Kann denn FileSetPos() auch gesperrte Dateien öffnen (habe noch nicht getestet)?

    Gruß,
    UEZ

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

    • UEZ
    • 14. Februar 2011 um 20:47
    Zitat von Großvater

    Hallo UEZ,

    ich habe mir etwas Ähnliches aus schierer Verzweiflung auch schon gebastelt.

    [autoit]

    Local $hFile = _WinAPI_CreateFile($filename, 2, 2)

    [/autoit]


    Ich denke, Du solltest zumindest $iShare = 4 (Write) setzen, sonst kann es leicht zu Konflikten kommen, wenn das Programm der LOG-Datei noch läuft. Die UDF "verwurstelt" ja die Werte der Windowskonstanten.

    Vielen Dank für dein Feedback! :rolleyes:

    Ich verstehen aber den Nutzen von $iShare -> 4 (Sharing mode of an object: Write) nicht ganz. Denn ich öffnen "nur" die Datei, warum sollte ich den sharing mode auf 4 setzen?

    Mit dieser Methode kann ich leider keine gesperrten Dateien öffnen, egal ob $iShare 4 ist oder nicht! Ich weiß nicht, wie das Notepad macht, denn Notepad kann z.B. die Logs von Robocopy öffnen, obwohl Robocopy noch läuft!

    Vielleicht kannst du das mit dem $iShare Parameter näher erklären.

    Gruß,
    UEZ

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

    • UEZ
    • 13. Februar 2011 um 21:40

    Genau ;)

    Gruß,
    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 – 712 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

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™