Hallo Autobert,
super, klappt prima.
Danke vielmals...
Liebe Grüße
Ilse ![]()
Hallo Autobert,
super, klappt prima.
Danke vielmals...
Liebe Grüße
Ilse ![]()
Hallo Autobert,
danke habe ich gemacht.
Ich hätte noch eine Frage zu dem Script.
Ich habe den Button Liste eingebaut.
Wie kann ich z.B. die Listview selbst füllen, also erweitern?
Also so:
1. ich öffne den ersten Ordner und lese files ein.
2. dann öffne ich einen anderen Ordner und hänge Files an...
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <Sound.au3>
#include <Array.au3>
If @AutoItVersion < '3.3.0.0' Then Exit MsgBox(16, 'Fehler', 'Funktioniert erst ab AutoIt-Version 3.3.0.0')
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global $htoPlay, $iStart
[/autoit] [autoit][/autoit] [autoit]$Musikordner = FileSelectFolder("Musik", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
[/autoit] [autoit][/autoit] [autoit]$timer = TimerInit()
$aReturn = _RecursiveFileListToArray($Musikordner, '\.mp3\z', 1) ; Alle Dateien mit der Erweiterung ".mp3" (im ausgewählten Ordner und Unterordnern)
ConsoleWrite(@error & @CRLF)
ConsoleWrite($aReturn[0] & @TAB & Round(TimerDiff($timer) / 1000, 3) & ' sek.' & @CRLF)
;_ArrayDisplay($aReturn, 'Alle Dateien mit der Erweiterung ".,mp3"')
$iWidth = @DesktopWidth
$iHeight = @DesktopHeight - 60
ConsoleWrite($iWidth & "/" & $iHeight)
$hGui = GUICreate("Form1", $iWidth, $iHeight, 0, 0)
$idMP3s = GUICtrlCreateListView(" |Pfad", 5, 5, $iWidth - 10, $iHeight - 50, _
BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $LVS_SINGLESEL), BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) ;$LVS_SHOWSELALWAYS
; wichtig ist der Stil $LVS_Report und der eweiterte Stil $LVS_EX_Checkboxes
$idNext = GUICtrlCreateButton("&Nächstes", 5, $iHeight - 30, 70)
$idPrev = GUICtrlCreateButton("&Zurück", 100, $iHeight - 30, 70)
$idopen = GUICtrlCreateButton("&Liste", 200, $iHeight - 30, 70)
$idPauseResume = GUICtrlCreateButton("&Pause", $iWidth / 2 - 75, $iHeight - 30, 70)
$idCopy = GUICtrlCreateButton("&Kopieren", $iWidth / 2 + 5, $iHeight - 30, 70)
$idMarkIt = GUICtrlCreateButton("&Markieren", $iWidth - 75, $iHeight - 30, 70)
For $i = 1 To $aReturn[0]
GUICtrlCreateListViewItem("|" & $aReturn[$i], $idMP3s)
;Achtung 1. Spalte hat keinen Inhalt (nur CheckBox)
Next
GUISetState()
$iAktuell = 1
_PlayIt()
While 1
_EventHandler()
WEnd
Func _EventHandler()
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $idNext, $idMarkIt
if $msg = $idMarkIt Then _GUICtrlListView_SetItemChecked($idMP3s, $iAktuell-1)
$iAktuell += 1
If $iAktuell <= $aReturn[0] Then _PlayIt()
Case $idPrev, $idMarkIt
if $msg = $idMarkIt Then _GUICtrlListView_SetItemChecked($idMP3s, $iAktuell-1)
$iAktuell -= 1
If $iAktuell <= $aReturn[0] Then _PlayIt()
Case $idopen
$Musikordner = FileSelectFolder("Musik", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
;$aReturn = _RecursiveFileListToArray($Musikordner, '\.mp3\z', 1) ; Alle Dateien mit der Erweiterung ".mp3" (im ausgewählten Ordner und Unterordnern)
Case $idPauseResume
If GUICtrlRead($idPauseResume) = "&Pause" Then
GUICtrlSetData($idPauseResume, "&Weiter")
If IsArray($htoPlay) Then _SoundPause($htoPlay)
While GUICtrlRead($idPauseResume) <> "&Pause"
_MySleep(50)
WEnd
If IsArray($htoPlay) Then _SoundResume($htoPlay)
Else
GUICtrlSetData($idPauseResume, "&Pause")
EndIf
Case $idCopy
$Speicherordner = FileSelectFolder("ausgewählte Musik speichern in ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 1)
For $i = 0 To _GUICtrlListView_GetItemCount($idMP3s) - 1
;Schleifenbeginn da das erste Item den Index 0 hat von 0 bis Anzahl -1
If _GUICtrlListView_GetItemChecked($idMP3s, $i) Then ; wenn geChecked (angehakt) dann
;_GUICtrlListView_GetItemSelected ;wenn markiert
$aItemText = _GUICtrlListView_GetItemTextArray($idMP3s, $i)
;Msgbox(4091,"",)
;Inhalt aller Spalten dieser Zeile dem Array $aItemText zuweisen
;FileCopy($Musikordner & "\" & $Array[$i],$Speicherordner & "\" & $Array[$i])
;$aItemText[0] enthält die Anzahl der Spalten
;$aItemText[1]
;$aItemText[2] Qiellpfad der MP3
ConsoleWrite($aItemText[2] & @CRLF)
FileCopy($aItemText[2],$Speicherordner)
; Automatisch an die Stelle hinscrollen
_GUICtrlListView_EnsureVisible($idMP3s, $i)
Sleep(Random(50, 250, 1)) ;löschen und kopier Befehl einfügen
EndIf
Next
EndSwitch
EndFunc ;==>_EventHandler
Func _PlayIt()
If IsArray($htoPlay) Then _SoundStop($htoPlay)
$htoPlay = _SoundOpen($aReturn[$iAktuell])
$iStart = TimerInit()
_GUICtrlListView_EnsureVisible($idMP3s, $iAktuell - 1)
_GUICtrlListView_SetItemSelected($idMP3s, $iAktuell-1)
ControlFocus($hGui,"",$idMP3s) ;<========
_SoundPlay($htoPlay)
AdlibRegister("_CheckTime")
EndFunc ;==>_PlayIt
Func _CheckTime()
Do
ConsoleWrite(Round(TimerDiff($iStart), 3) & @CRLF)
_EventHandler()
Until TimerDiff($iStart) >= 12000
AdlibUnRegister()
$iAktuell += 1
If $iAktuell <= $aReturn[0] Then _PlayIt()
EndFunc ;==>_CheckTime
Func _MySleep($iMSec)
Local $iStart = TimerInit()
Do
_EventHandler()
Until TimerDiff($iStart) >= $iMSec
EndFunc ;==>_MySleep
;===============================================================================
; Function Name: _RecursiveFileListToArray($sPath, $sPattern, $iFlag = 0, $iFormat = 1, $sDelim = @CRLF)
; Description:: gibt Verzeichnisse und/oder Dateien (rekursiv) zurück, die
; einem RegExp-Pattern entsprechen
; Parameter(s): $sPath = Startverzeichnis
; $sPattern = ein beliebiges RexExp-Pattern für die Auswahl
; $iFlag = Auswahl
; 0 = Dateien & Verzeichnisse
; 1 = nur Dateien
; 2 = nur Verzeichnisse
; $iFormat = Rückgabeformat
; 0 = String
; 1 = Array mit [0] = Anzahl
; 2 = Nullbasiertes Array
; $sDelim = Trennzeichen für die String-Rückgabe
; Requirement(s): AutoIt 3.3.0.0
; Return Value(s): Array/String mit den gefundenen Dateien/Verzeichnissen
; Author(s): Oscar (http://www.autoit.de)
; Anregungen von: bernd670 (http://www.autoit.de)
;===============================================================================
Func _RecursiveFileListToArray($sPath, $sPattern, $iFlag = 0, $iFormat = 1, $sDelim = @CRLF)
Local $hSearch, $sFile, $sReturn = ''
If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
$hSearch = FileFindFirstFile($sPath & '*.*')
If @error Or $hSearch = -1 Then Return SetError(1, 0, $sReturn)
While True
$sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If StringInStr(FileGetAttrib($sPath & $sFile), 'D') Then
If StringRegExp($sPath & $sFile, $sPattern) And ($iFlag = 0 Or $iFlag = 2) Then $sReturn &= $sPath & $sFile & '\' & $sDelim
$sReturn &= _RecursiveFileListToArray($sPath & $sFile & '\', $sPattern, $iFlag, 0)
ContinueLoop
EndIf
If StringRegExp($sFile, $sPattern) And ($iFlag = 0 Or $iFlag = 1) Then $sReturn &= $sPath & $sFile & $sDelim
WEnd
FileClose($hSearch)
If $iFormat Then Return StringSplit(StringTrimRight($sReturn, StringLen($sDelim)), $sDelim, $iFormat)
Return $sReturn
EndFunc ;==>_RecursiveFileListToArray
Geht das?
Liebe Grüße
Ilse ![]()
Hallo Autobert,
erstmal merci für das tolle Script.
Bin noch dabei alles etwas anzupassen...
Melde mich wieder...
Vielen vielen Dank
Liebe Grüße
Ilse ![]()
Hallo Autobert,
merci für deine Hilfe.
Huh... soweit bin ich noch nicht. Ob ich das schaffe...
aber gute Idee...
Weißt du vielleicht, wie ich das ganze pausieren lassen kann?
Ich meine eine Pause im Loop!
Liebe Grüße
Ilse ![]()
Hallo zusammen,
Ich habe in einem Ordner mehrere mp3 Dateien.
Es gibt auch Unterordner...
Folgendes möchte ich machen:
Ich möchte die mp3 Dateien kurz anhören (z.B. 10 Sekunden)
und dann sollte das nächste Lied angespielt werden.
Drücke ich z.B. die Space-Taste, dann soll das aktuelle Lied
in den Speicherordner "kopiert" werden.
Hier meine Versuche
#include <File.au3>
#include <Array.au3>
#include <Sound.au3>
Dim $Array
HotKeySet("{Space}", "_Copy")
$Zeit = 10
$Musikordner = FileSelectFolder("Musik", @ScriptDir)
$Speicherordner = FileSelectFolder("Musik speichern in ", @ScriptDir, 1)
$Array = _FileListToArray($Musikordner, "*.mp3")
[/autoit] [autoit][/autoit] [autoit]_ArrayDisplay($Array)
[/autoit] [autoit][/autoit] [autoit]For $i = 1 To UBound($Array) - 1
;MsgBox(0, "", $Array[$i])
SplashTextOn("Titel",$Array[$i])
Sleep(300)
$Song = _SoundOpen($Musikordner & "\" & $Array[$i])
[/autoit] [autoit][/autoit] [autoit]_SoundPlay($Song, 0)
[/autoit] [autoit][/autoit] [autoit]Sleep(4000)
[/autoit] [autoit][/autoit] [autoit]_SoundClose($Song)
SplashOff()
Next
Func _Copy()
FileCopy($Musikordner & "\" & $Array[$i],$Speicherordner & "\" & $Array[$i])
MsgBox(4096, "Kopiert", $Array[$i],1)
EndFunc ;==>_Copy
Die mp3 Dateien werden nacheinander angezeigt.
Ich wollte das auch mit SplashText anzeigen
solange das Lied läuft...
Edit... läuft jetzt...
2 Fragen habe ich noch:
Weiß jemand wie man da einen Loop einbauen kann?
Beispiel:
Ich höre das Lied! Dann setze ich den 1. Punkt und später das Loop Ende.
So daß eine Schleife läuft bis man abbricht!
Wie kann man eine Pause einbauen?
Liebe Grüße
Ilse ![]()
chesstiger
Syntaxproblem, aber wieso?
_ImageResize($sInImage,$outfolder,$iW,$iH)
name22
mit läuft einmal, meinte ich das allererste Script
ohne FileListToArray....
GDIPlus_Shutdown ist nun draußen...
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <File.au3>
#include <Array.au3>
;~ $sInImage = FileOpenDialog("Bilder",@WindowsDir & "\", "Bilder (*.jpg)", 1 + 4 )
;~ $outfolder = @ScriptDir & "\19_Resize.jpg"
DirCreate(@ScriptDir & "\Resized")
Global $sInImage = FileSelectFolder("Select folder with pictures", "", 4) & "\"
Global $outfolder = @ScriptDir & "\Resized"
$iW = InputBox("Bildbreite", "Bitte geben Sie die Breite ein.", "", "")
$iH = InputBox("Bildhöhe", "Bitte geben Sie die Höhe ein.", "", "")
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $aFiles = _FileListToArray($sInImage, "*.???", 0)
For $i = 1 To $aFiles[0]
If StringRegExp($aFiles[$i], "(?i).*\.png|.*\.jpg|.*\.bmp", 0) Then _ImageResize($sInImage & $aFiles[$i], $iw,$ih, $outfolder)
;MsgBox(0,"",$aFiles[$i])
Next
_GDIPlus_Shutdown()
[/autoit] [autoit][/autoit] [autoit]ShellExecute($outfolder)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
_ImageResize($sInImage,$outfolder,$iW,$iH)
If @error Then MsgBox(0,"Fehler",@error)
Func _ImageResize($sInImage, $outfolder, $iW, $iH)
Local $sOP, $sOF, $sInExt, $Ext, $hBitmap, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
Local $sType = "BMP|GIF|ICO|JPG|JPEG|PNG|TIF|TIFF"
If Not FileExists($sInImage) Then Return SetError(1, 0, 0)
$sInExt = StringUpper(StringTrimLeft($sInImage, StringInStr($sInImage, ".", 0, -1)))
If Not StringRegExp($sInExt, "\A(" & $sType & ")\z", 0) Then Return SetError(2, 0, 0)
;OutFile path, to use later on.
$sOP = StringLeft($outfolder, StringInStr($outfolder, "\", 0, -1))
If Not FileExists($sOP) Then Return SetError(3, 0, 0)
;OutFile name, to use later on.
$sOF = StringTrimLeft($outfolder, StringInStr($outfolder, "\", 0, -1))
;OutFile extension , to use for the encoder later on.
$Ext = StringUpper(StringTrimLeft($outfolder, StringInStr($outfolder, ".", 0, -1)))
If Not StringRegExp($Ext, "\A(" & $sType & ")\z", 0) Or $Ext = "ICO" Then Return SetError(4, 0, 0)
If Not IsInt($iW) And Not IsInt($iH) Then Return SetError(5, 0, 0)
[/autoit] [autoit][/autoit] [autoit]; WinAPI to create blank bitmap at the width and height to put your resized image on.
$hBitmap = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
;Get the handle of blank bitmap you created above as an image
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
;Load the image you want to resize.
$hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
;Get the graphic context of the blank bitmap
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
;Draw the loaded image onto the blank bitmap at the size you want
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)
;Get the encoder of to save the resized image in the format you want.
$CLSID = _GDIPlus_EncodersGetCLSID($Ext)
;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
Do
$i += 1
Until (Not FileExists($sOP & $i & "_" & $sOF))
;Prefix the number to the begining of the output filename
$outfolder = $sOP & $i & "_" & $sOF
;Save the new resized image.
_GDIPlus_ImageSaveToFileEx($hImage1, $outfolder, $CLSID)
;Clean up and shutdown GDIPlus.
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteObject($hBitmap)
;_GDIPlus_Shutdown()
Return SetError(0, 0, 1)
EndFunc ;==>_ImageResize
aber es läuft trotzdem nicht!
Liebe Grüße
Ilse ![]()
Hallo,
geht aber immer noch nicht!
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <File.au3>
#include <Array.au3>
;~ $sInImage = FileOpenDialog("Bilder",@WindowsDir & "\", "Bilder (*.jpg)", 1 + 4 )
;~ $sOutImage = @ScriptDir & "\19_Resize.jpg"
DirCreate(@ScriptDir & "\Resized")
Global $sInImage = FileSelectFolder("Select folder with pictures", "", 4) & "\"
Global $outfolder = @ScriptDir & "\Resized"
$iW = InputBox("Bildbreite", "Bitte geben Sie die Breite ein.", "", "")
$iH = InputBox("Bildhöhe", "Bitte geben Sie die Höhe ein.", "", "")
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $aFiles = _FileListToArray($sInImage, "*.???", 0)
For $i = 1 To $aFiles[0]
If StringRegExp($aFiles[$i], "(?i).*\.png|.*\.jpg|.*\.bmp", 0) Then _ImageResize($sInImage & $aFiles[$i], $iw,$ih, $outfolder)
;MsgBox(0,"",$aFiles[$i])
Next
_GDIPlus_Shutdown()
ShellExecute($outfolder)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
_ImageResize($sInImage, $outfolder, $iW, $iH)
If @error Then MsgBox(0,"",@error)
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
Local $sOP, $sOF, $sInExt, $Ext, $hBitmap, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
Local $sType = "BMP|GIF|ICO|JPG|JPEG|PNG|TIF|TIFF"
If Not FileExists($sInImage) Then Return SetError(1, 0, 0)
$sInExt = StringUpper(StringTrimLeft($sInImage, StringInStr($sInImage, ".", 0, -1)))
If Not StringRegExp($sInExt, "\A(" & $sType & ")\z", 0) Then Return SetError(2, 0, 0)
;OutFile path, to use later on.
$sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
If Not FileExists($sOP) Then Return SetError(3, 0, 0)
;OutFile name, to use later on.
$sOF = StringTrimLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
;OutFile extension , to use for the encoder later on.
$Ext = StringUpper(StringTrimLeft($sOutImage, StringInStr($sOutImage, ".", 0, -1)))
If Not StringRegExp($Ext, "\A(" & $sType & ")\z", 0) Or $Ext = "ICO" Then Return SetError(4, 0, 0)
If Not IsInt($iW) And Not IsInt($iH) Then Return SetError(5, 0, 0)
[/autoit] [autoit][/autoit] [autoit]; WinAPI to create blank bitmap at the width and height to put your resized image on.
$hBitmap = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
;Get the handle of blank bitmap you created above as an image
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
;Load the image you want to resize.
$hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
;Get the graphic context of the blank bitmap
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
;Draw the loaded image onto the blank bitmap at the size you want
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)
;Get the encoder of to save the resized image in the format you want.
$CLSID = _GDIPlus_EncodersGetCLSID($Ext)
;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
Do
$i += 1
Until (Not FileExists($sOP & $i & "_" & $sOF))
;Prefix the number to the begining of the output filename
$sOutImage = $sOP & $i & "_" & $sOF
;Save the new resized image.
_GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)
;Clean up and shutdown GDIPlus.
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
Return SetError(0, 0, 1)
EndFunc ;==>_ImageResize
Ich habe _GDIPlus_Startup() Zeile 16 gestartet und später wieder geschlossen.
Es kommt die Msgbox 2
und der Zielordner ist leer!
Mit nur einer Datei (Post 1) geht das Script!
Grüße Ilse
Hallo Chesstiger,
habe das mal probiert.
Leider klappt es immer noch nicht!
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <File.au3>
#include <Array.au3>
;~ $sInImage = FileOpenDialog("Bilder",@WindowsDir & "\", "Bilder (*.jpg)", 1 + 4 )
;~ $sOutImage = @ScriptDir & "\19_Resize.jpg"
DirCreate(@ScriptDir & "\Resized")
Global $sInImage = FileSelectFolder("Select folder with pictures", "", 4) & "\"
Global $outfolder = @ScriptDir & "\Resized"
$iW = InputBox("Bildbreite", "Bitte geben Sie die Breite ein.", "", "")
$iH = InputBox("Bildhöhe", "Bitte geben Sie die Höhe ein.", "", "")
Global $aFiles = _FileListToArray($sInImage, "*.???", 0)
For $i = 1 To $aFiles[0]
If StringRegExp($aFiles[$i], "(?i).*\.png|.*\.jpg|.*\.bmp", 0) Then _ImageResize($sInImage & $aFiles[$i], $iw,$ih, $outfolder)
;MsgBox(0,"",$aFiles[$i])
Next
_GDIPlus_Shutdown()
ShellExecute($outfolder)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
_ImageResize($sInImage, $outfolder, $iW, $iH)
If @error Then MsgBox(0,"",@error)
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
Local $sOP, $sOF, $sInExt, $Ext, $hBitmap, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
Local $sType = "BMP|GIF|ICO|JPG|JPEG|PNG|TIF|TIFF"
If Not FileExists($sInImage) Then Return SetError(1, 0, 0)
$sInExt = StringUpper(StringTrimLeft($sInImage, StringInStr($sInImage, ".", 0, -1)))
If Not StringRegExp($sInExt, "\A(" & $sType & ")\z", 0) Then Return SetError(2, 0, 0)
;OutFile path, to use later on.
$sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
If Not FileExists($sOP) Then Return SetError(3, 0, 0)
;OutFile name, to use later on.
$sOF = StringTrimLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
;OutFile extension , to use for the encoder later on.
$Ext = StringUpper(StringTrimLeft($sOutImage, StringInStr($sOutImage, ".", 0, -1)))
If Not StringRegExp($Ext, "\A(" & $sType & ")\z", 0) Or $Ext = "ICO" Then Return SetError(4, 0, 0)
If Not IsInt($iW) And Not IsInt($iH) Then Return SetError(5, 0, 0)
[/autoit] [autoit][/autoit] [autoit]; WinAPI to create blank bitmap at the width and height to put your resized image on.
$hBitmap = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
;Get the handle of blank bitmap you created above as an image
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
;Load the image you want to resize.
$hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
;Get the graphic context of the blank bitmap
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
;Draw the loaded image onto the blank bitmap at the size you want
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)
;Get the encoder of to save the resized image in the format you want.
$CLSID = _GDIPlus_EncodersGetCLSID($Ext)
;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
Do
$i += 1
Until (Not FileExists($sOP & $i & "_" & $sOF))
;Prefix the number to the begining of the output filename
$sOutImage = $sOP & $i & "_" & $sOF
;Save the new resized image.
_GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)
;Clean up and shutdown GDIPlus.
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
Return SetError(0, 0, 1)
EndFunc ;==>_ImageResize
Bilder werden in Msgbox angezeigt
aber es kommt eine Fehlermeldung!
Liebe Grüße
Ilse ![]()
Hallo zusammen,
ich habe eine Frage zu folgendem Script.
Wie kann man alle Dateien in einem Ordner
auf einmal resizen?
#include <GDIPlus.au3>
#include <WinAPI.au3>
$sInImage = FileOpenDialog("Bilder",@WindowsDir & "\", "Bilder (*.jpg)", 1 + 4 )
$sOutImage = @ScriptDir & "\19_Resize.jpg"
$iH = InputBox("Bildhöhe", "Bitte geben Sie die Höhe ein.", "", "")
$iW = InputBox("Bildbreite", "Bitte geben Sie die Breite ein.", "", "")
_GDIPlus_Startup()
_ImageResize($sInImage, $sOutImage, $iW, $iH)
If @error Then MsgBox(0,"",@error)
; #FUNCTION# =========================================================================================
; Name...........: _ImageResize
; Description....: Resize an image and optionally convert it to the format you want.
; Syntax.........: _ImageResize($sInImage, $sOutImage, $iW, $iH)
; Parameters ....: $sInImage - Full path to the image to resize / convert.
; In types: *.bmp, *.gif, *.ico, *.jpg, *.jpeg, *.png, *.tif, *.tiff
; $sOutImage - Full path where to save the resized / converted image.
; Out types: *.bmp, *.gif, *.jpg, *.jpeg, *.png, *.tif, *.tiff
; $iW - Width to resize image to.
; $iH - Height to resize image to.
; Return values .: Success - Return 1 and @error 0
; Failure - Return 0 and @error 1~5
; @error 1 = In File does not exist
; @error 2 = In File format not supported
; @error 3 = Out File path does not exist
; @error 4 = Out file format not supported
; @error 5 = Resize Width or Height not an integer
; Author ........: smashly
; ====================================================================================================
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
Local $sOP, $sOF, $sInExt, $Ext, $hBitmap, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
Local $sType = "BMP|GIF|ICO|JPG|JPEG|PNG|TIF|TIFF"
If Not FileExists($sInImage) Then Return SetError(1, 0, 0)
$sInExt = StringUpper(StringTrimLeft($sInImage, StringInStr($sInImage, ".", 0, -1)))
If Not StringRegExp($sInExt, "\A(" & $sType & ")\z", 0) Then Return SetError(2, 0, 0)
;OutFile path, to use later on.
$sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
If Not FileExists($sOP) Then Return SetError(3, 0, 0)
;OutFile name, to use later on.
$sOF = StringTrimLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
;OutFile extension , to use for the encoder later on.
$Ext = StringUpper(StringTrimLeft($sOutImage, StringInStr($sOutImage, ".", 0, -1)))
If Not StringRegExp($Ext, "\A(" & $sType & ")\z", 0) Or $Ext = "ICO" Then Return SetError(4, 0, 0)
If Not IsInt($iW) And Not IsInt($iH) Then Return SetError(5, 0, 0)
[/autoit] [autoit][/autoit] [autoit]; WinAPI to create blank bitmap at the width and height to put your resized image on.
$hBitmap = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
;Get the handle of blank bitmap you created above as an image
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
;Load the image you want to resize.
$hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
;Get the graphic context of the blank bitmap
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
;Draw the loaded image onto the blank bitmap at the size you want
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)
;Get the encoder of to save the resized image in the format you want.
$CLSID = _GDIPlus_EncodersGetCLSID($Ext)
;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
Do
$i += 1
Until (Not FileExists($sOP & $i & "_" & $sOF))
;Prefix the number to the begining of the output filename
$sOutImage = $sOP & $i & "_" & $sOF
;Save the new resized image.
_GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)
;Clean up and shutdown GDIPlus.
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
Return SetError(0, 0, 1)
EndFunc ;==>_ImageResize
Liebe Grüße
Ilse ![]()
Hallo Nothing,
genau so, funktioniert prima. Super...
Dank Dir
Liebe Grüße
Ilse ![]()
Hallo,
ich brauch mal wieder die Profis...
Es sollen Checkboxen, Namen und Bilder gemacht werden.(alles in einer Zeile)
Die Checkboxen und Namen sind ok!
Wird das ganze mit einem Bild erweitert,
dann stimmt StringSplit nicht mehr, es werden zusätzliche Checkboxen gemacht!
Alles in einer Reihe OK!
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 800, 443, 192, 124)
$btnCheckbox = GUICtrlCreateButton("Checkbox", 504, 400, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
Global $Wahl,$reihenAnzahl,$spaltenNr,$arPic
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnCheckbox
_Namen()
EndSwitch
WEnd
Func _Namen()
Dim $Links = 25
Dim $oben = 30
Dim $Zwischen = 50
Dim $Zeilen = 4
Dim $Abstand = 300
Dim $Namebreite = 100
Dim $Namehoehe = 10
;Diese Fassung ist OK!
$Wahl &= "c1 Name1|"
$Wahl &= "d2 Name2|"
$Wahl &= "e3 Name3|"
$Wahl &= "n4 Name4|"
;Diese Fassung ist falsch, das Bild soll in die gleiche Reihe!
[/autoit] [autoit][/autoit] [autoit];~ $Wahl &= "c1 Name1|Bild1.jpg|"
;~ $Wahl &= "d2 Name2|Bild2.jpg|"
;~ $Wahl &= "e3 Name3|Bild3.jpg|"
;~ $Wahl &= "n4 Name4|Bild4.jpg|"
$WahlSplit = StringSplit($Wahl, "|")
Global $Checkbox[$WahlSplit[0]]
Global $CheckboxName[$WahlSplit[0]]
Global $arProgress[$WahlSplit[0]]
For $i = 0 To $WahlSplit[0]-2
If $i > 2 Then
If Mod($i - 1, $reihenAnzahl) = 0 Then $spaltenNr += 1
EndIf
$chkName = StringTrimLeft($WahlSplit[$i +1 ], 3)
$Checkbox[$i+1] = GUICtrlCreateCheckbox($chkName, $Links + Int($i / $Zeilen) * $Abstand, $oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
$arProgress[$i+1] = GUICtrlCreateProgress($Links + 100 + Int($i / $Zeilen) * $Abstand, $Oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
;Msgbox(0,"",$WahlSplit[2])
$arPic = GUICtrlCreatePic($WahlSplit[$i+1],$Links + 100 + Int($i / $Zeilen) * $Abstand, $Oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
GUICtrlSetFont($Checkbox[$i], 10, 500, 0, "Arial")
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit]Mit weiterer Spalte ist das ganze falsch
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 800, 443, 192, 124)
$btnCheckbox = GUICtrlCreateButton("Checkbox", 504, 400, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
Global $Wahl,$reihenAnzahl,$spaltenNr,$arPic
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnCheckbox
_Namen()
EndSwitch
WEnd
Func _Namen()
Dim $Links = 25
Dim $oben = 30
Dim $Zwischen = 50
Dim $Zeilen = 4
Dim $Abstand = 300
Dim $Namebreite = 100
Dim $Namehoehe = 10
;Diese Fassung ist OK!
;~ $Wahl &= "c1 Name1|"
;~ $Wahl &= "d2 Name2|"
;~ $Wahl &= "e3 Name3|"
;~ $Wahl &= "n4 Name4|"
;Diese Fassung ist falsch, das Bild soll in die gleiche Reihe!
[/autoit] [autoit][/autoit] [autoit]$Wahl &= "c1 Name1|Bild1.jpg|"
$Wahl &= "d2 Name2|Bild2.jpg|"
$Wahl &= "e3 Name3|Bild3.jpg|"
$Wahl &= "n4 Name4|Bild4.jpg|"
$WahlSplit = StringSplit($Wahl, "|")
Global $Checkbox[$WahlSplit[0]]
Global $CheckboxName[$WahlSplit[0]]
Global $arProgress[$WahlSplit[0]]
For $i = 0 To $WahlSplit[0]-2
If $i > 2 Then
If Mod($i - 1, $reihenAnzahl) = 0 Then $spaltenNr += 1
EndIf
$chkName = StringTrimLeft($WahlSplit[$i +1 ], 3)
$Checkbox[$i+1] = GUICtrlCreateCheckbox($chkName, $Links + Int($i / $Zeilen) * $Abstand, $oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
$arProgress[$i+1] = GUICtrlCreateProgress($Links + 100 + Int($i / $Zeilen) * $Abstand, $Oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
;Msgbox(0,"",$WahlSplit[2])
$arPic = GUICtrlCreatePic($WahlSplit[$i+1],$Links + 100 + Int($i / $Zeilen) * $Abstand, $Oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
GUICtrlSetFont($Checkbox[$i], 10, 500, 0, "Arial")
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit]Komme einfach nicht weiter
Liebe Grüße
Ilse ![]()
Hallo RedHead,
super, klappt endlich.
Liebe Grüße
Ilse ![]()
Hallo zusammen,
vielleicht schaut Ihr euch das einfach mal an.
Es werden Controls erstellt, allerdings die erste Spalte
stimmt nie! Die ist immer eins tiefer!
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 800, 443, 192, 124)
$btnCheckbox = GUICtrlCreateButton("Checkbox", 504, 400, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
Global $Wahl,$reihenAnzahl,$spaltenNr
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnCheckbox
_Namen()
EndSwitch
WEnd
Func _Namen()
Dim $Links = 25
Dim $oben = 30
Dim $Zwischen = 50
Dim $Zeilen = 4
Dim $Abstand = 300
Dim $Namebreite = 100
Dim $Namehoehe = 10
$Wahl &= "c1 Name1|"
$Wahl &= "d2 Name2|"
$Wahl &= "e3 Name3|"
$Wahl &= "n4 Name4|"
$Wahl &= "n5 Name5|"
$Wahl &= "f6 Name6|"
$Wahl &= "p7 Name7|"
$Wahl &= "p8 Name8|"
$Wahl &= "r9 Name9|"
$WahlSplit = StringSplit($Wahl, "|")
Global $Checkbox[$WahlSplit[0]]
Global $CheckboxName[$WahlSplit[0]]
Global $arProgress[$WahlSplit[0]]
For $i = 1 To $WahlSplit[0]-1
If $i > 2 Then
If Mod($i - 1, $reihenAnzahl) = 0 Then $spaltenNr += 1
EndIf
$chkName = StringTrimLeft($WahlSplit[$i], 3)
$Checkbox[$i] = GUICtrlCreateCheckbox($chkName, $Links + Int($i / $Zeilen) * $Abstand, $oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
$arProgress[$i] = GUICtrlCreateProgress($Links + 100 + Int($i / $Zeilen) * $Abstand, $Oben + Mod($i, $Zeilen) * $Zwischen, $Namebreite, $Namehoehe)
GUICtrlSetFont($Checkbox[$i], 10, 500, 0, "Arial")
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit]Bin gespannt, was diesmal falsch war...
Liebe Grüße
Ilse ![]()
Hallo UEZ,
suuuuuper, genau so.
Liebe Grüße
Ilse ![]()
Hallo,
folgendes Problem krieg ich nicht gelöst...
Ich probiers mal mit der Erklärung:
1. Die Form startet in einer bestimmten Größe. OK
2. Dann kann man Controls erstellen. OK
so und nun...
Wird die Form in der Größe verändert, dann werden
die erstellten Objekte (die bereits existieren) dieser großen Form angepasst. OK
Aber, existieren die Objekte noch nicht (also der Benutzer vergrößert zuerst die Form)
und dann werden die Objekte erstellt, dann stimmen die Verhältnisse nicht mehr.
Beispiel
[autoit]
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>
$Form1 = GUICreate("Form1", 625, 443, 192, 124, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$btnerstellen = GUICtrlCreateButton("erstellen", 72, 16, 75, 25, $WS_GROUP)
$btndelete = GUICtrlCreateButton("löschen", 160, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
Global $Checkbox, $i, $Checkbox1, $Checkbox2, $Checkbox3
[/autoit][autoit][/autoit][autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnerstellen
_erstellen()
Case $btndelete
_delete()
EndSwitch
WEnd
func _erstellen()
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 72, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 72, 88, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 168, 56, 97, 17)
endfunc
func _delete()
GUICtrlDelete($Checkbox1)
GUICtrlDelete($Checkbox2)
GUICtrlDelete($Checkbox3)
endfunc
Wie kann man das mit resize lösen?
EDIT:
Wie kann ich meine Controls relativ zur Guigröße erstellen?
Ich glaube, da liegt das Problem.
Denn sie werden ja immer mit den Ursprungskoordinaten erstellt.
Ich habe mit diesen Parametern probiert
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 72, 56, 97, 17)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
klappt leider nicht so wie es soll!
Liebe Grüße
Ilse ![]()
Hallo Tweaky,
ich habe zig Varianten hinter mir...
Vielen Dank
Liebe Grüße
Ilse ![]()
Hallo,
ich habe ein Problem mit Stringsplit.
Wie kann man bei einem String
(das einen ., ?, !)
das oder benutzen. Also or...
Global $stringl= StringSplit($string, ".", 2); Text mit Punkt getrennt, oder ?, oder !
Meine Versuche mit "or" haben nicht funktioniert!
Grüße
Ilse ![]()
Hallo Raupi,
merci für die Lösung.
ABER:
Folgendes, wenn die Anzahl der Spalten nicht bekannt ist
dann klappt das nicht mehr!
Beispiel:
Wenn ich 10 oder mehr Checkboxen mit Namen habe, davon sollen 4 ausgewählt werden
dann sollen daraus 4 Spalten gemacht werden.
EDIT
@Kasey
hm ich glaube mit dem Befehl
[autoit]
_GUICtrlListView_AddColumn($ListView1, "--")
komm ich weiter...!
Merci
Grüße
Ilse ![]()
Hallo,
ich möchte gerne die Spaltenüberschriften
in meinem Listview per Code ändern.
Klappt alles nicht wie gewollt....
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 465, 231, 192, 124)
$ListView1 = GUICtrlCreateListView("--", 8, 16, 442, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
$Button1 = GUICtrlCreateButton("Spalten", 8, 176, 91, 41, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$Spalte1 = "Nr 1"
$Spalte2 = "Nr 2"
$Spalte3 = "Nr 3"
$Spalte4 = "Nr 4"
$Spalte5 = "Nr 5"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
;$ListView1 = GUICtrlCreateListView($Spalte1&"|"&$Spalte2, 8, 16, 442, 150)
;GUICtrlSetData($ListView1,$Spalte1&"|"&$Spalte2&"|")
EndSwitch
WEnd
Liebe Grüße
Ilse ![]()
Hallo Xor,
schau dir das mal bitte an:
die 1 soll durch die Schriftart Wingdings ersetzt werden
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 459, 215, 192, 124)
$ListView1 = GUICtrlCreateListView("Ordner|Monat", 24, 24, 250, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
$ListView1_0 = GUICtrlCreateListViewItem("1|Januar", $ListView1)
$Button1 = GUICtrlCreateButton("Start", 280, 24, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
EndSwitch
WEnd
Da komm ich einfach nicht weiter....
Liebe Grüße
Ilse ![]()