eine kleiner Dateimanager, den ich für Arbeit programmiert habe.
Code: Select all
info=
(
Easy-OneFile
OpenSource for all
View Window Left ALT & a
)
Progress, ZX50 ZY50 b c10 fs10 w250 zh0 B CWyellow CTblack,Wait..,%info% ,,
sleep,3800
Progress,off
Fontsize:=10
Fontsize2:=Fontsize+2
Buttonzize:=Fontsize+10
Hotkey,IfWinActive,Easy-OneFile
hotkey,TAB,TABFocus
hotkey,return,run
Gui,Margin,0,0
gui, +resize
gui,font,S%Fontsize% Arial Normal
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ifnotexist,qsv-config.txt
{
qsv_config=
(
## Please edit this , leftside Buttonname, rightside Path.
ED-ED-II = J:\ed-ed-II
Zertifikate = R:\Messmaschine\Prüfmittel-ALLES\PM-Zertifikate
QS = R:\Messmaschine\QS-Bilder
Work = J:\WORK
)
fileappend,%qsv_config%,qsv-config.txt
runwait,notepad.exe qsv-config.txt
}
listfolders :=[]
listbuttonname :=[]
button:=1
Loop, read,qsv-config.txt
{
regexmatch( A_LoopReadLine,"(.*?)\s*\=\s*(.*)",ok)
if ok1
{
gui,add,button,xs section xm w120 h%Buttonzize% v%button% gallbutton ,%ok1%
listbuttonname.push(ok1)
listfolders.push(ok2)
button++
}
}
Gui,Margin,0,10
gui,add,button,xs section xm w120 vmail gallbutton h%Buttonzize% ,E-Mail
Gui,Margin,0,0
gui,add,button,xs section xm w120 vsclip gallbutton h%Buttonzize%,Pic-CLP
gui,add,button,xs section xm w120 vedit gallbutton h%Buttonzize%,Edit
gui,add,button,xs section xm w120 vdel gallbutton h%Buttonzize%,Delete
gui,add,button,xs section xm w120 vmov gallbutton h%Buttonzize%,Move
gui,add,button,xs section xm w120 vcop gallbutton h%Buttonzize%,Copy
gui,add,button,xs section xm w120 vrena gallbutton h%Buttonzize%,Rename
lvrow:=button*2
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
gui,font,S10 Arial Normal
Gui, Add, Edit,x0 y0 w0 h0,config
gui,font,S%Fontsize% Arial Normal
Gui, Add, ListView,ys y0 r%lvrow% w800 vMyListView gMyListView -Hdr -multi,Name|Type|Date|Date
gui, add, edit,x0 section vlastline w900 +ReadOnly,Hallo
ImageListID1 := IL_Create(10)
ImageListID2 := IL_Create(10, 10, true) ; A list of large icons to go with the small ones.
LV_SetImageList(ImageListID1)
LV_SetImageList(ImageListID2)
Gui,Show,,Easy-OneFile
;#Start with first
folder:=listfolders[1]
button:=listbuttonname[1]
gosub ButtonLoadFolder2
LV_ModifyCol(3, "SortDesc")
ControlSetText,Edit2,%Folder%,Easy-OneFile
gosub starthide
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
copy:
mode=copy
file:=lvgetfile()
showdestgui()
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
move:
mode=move
file:=lvgetfile()
showdestgui()
return
allbutton:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ifexist,%A_GuiControl%
{
if file
{
if mode=copy
{
filecopy,%file%,%A_GuiControl%,1
soundbeep,2000,100
gui,2: destroy
mode=
LV_Delete()
gosub ButtonLoadFolder2
GuiControl, +Redraw, MyListView
LV_ModifyCol(3, "SortDesc")
return
}
if mode=move
{
FileMove,%file%,%A_GuiControl%,1
soundbeep,2000,100
gui,2: destroy
mode=
LV_Delete()
gosub ButtonLoadFolder2
GuiControl, +Redraw, MyListView
LV_ModifyCol(3, "SortDesc")
return
}
}
}
;---------------------------------------------------------
if A_GuiControl=rena
{
file:=lvgetfile()
if file
{
SplitPath, file, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
InputBox,ui,Rename, Please enter new File Name,,600,,,,,,%OutFileName%
if ui
{
FileMove,%file%,%OutDir%\%ui%,1
LV_Delete()
gosub ButtonLoadFolder2
GuiControl, +Redraw, MyListView
LV_ModifyCol(3, "SortDesc")
return
}
}
}
if A_GuiControl=--CANCEL--
{
gui,2: destroy
mode=
soundbeep,400,200
return
}
if A_GuiControl=mov
{
mode=move
file:=lvgetfile()
showdestgui()
return
}
if A_GuiControl=cop
{
mode=copy
file:=lvgetfile()
showdestgui()
return
}
if A_GuiControl=Mail
goto mail
if A_GuiControl=sclip
goto savepic
if A_GuiControl=edit
{
file:=lvgetfile()
try run,edit %file%
catch
return
}
if A_GuiControl=del
{
file:=lvgetfile()
ifexist,%file%
{
SplitPath, file, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
MsgBox, 4,, Would you like to delete? (press Yes or No)`n`n%OutFileName%`n`n%OutDir%
IfMsgBox Yes
{
FileDelete,%file%
LV_Delete()
gosub ButtonLoadFolder2
GuiControl, +Redraw, MyListView
LV_ModifyCol(3, "SortDesc")
}
}
return
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LV_Delete()
folder:=listfolders[A_GuiControl]
button:=listbuttonname[A_GuiControl]
gosub ButtonLoadFolder2
LV_ModifyCol(3, "SortDesc")
ControlSetText,Edit2,%Folder%,Easy-OneFile
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonLoadFolder2:
Critical
SetBatchLines, -1
Process, Priority,,Realtime
; Check if the last character of the folder name is a backslash, which happens for root
; directories such as C:\. If it is, remove it to prevent a double-backslash later on.
LastChar := SubStr(Folder, 0)
if (LastChar = "\")
Folder := SubStr(Folder, 1, -1) ; Remove the trailing backslash.
; Calculate buffer size required for SHFILEINFO structure.
sfi_size := A_PtrSize + 8 + (A_IsUnicode ? 680 : 340)
VarSetCapacity(sfi, sfi_size)
; Gather a list of file names from the selected folder and append them to the ListView:
GuiControl, -Redraw, MyListView ; Improve performance by disabling redrawing during load.
Loop %Folder%\*.*
{
FileName := A_LoopFileFullPath ; Must save it to a writable variable for use below.
SplitPath, FileName,,, FileExt ; Get the file's extension.
if FileExt in EXE,ICO,ANI,CUR
{
ExtID := FileExt ; Special ID as a placeholder.
IconNumber := 0 ; Flag it as not found so that these types can each have a unique icon.
}
else ; Some other extension/file-type, so calculate its unique ID.
{
ExtID := 0 ; Initialize to handle extensions that are shorter than others.
Loop 7 ; Limit the extension to 7 characters so that it fits in a 64-bit value.
{
ExtChar := SubStr(FileExt, A_Index, 1)
if not ExtChar ; No more characters.
break
; Derive a Unique ID by assigning a different bit position to each character:
ExtID := ExtID | (Asc(ExtChar) << (8 * (A_Index - 1)))
}
IconNumber := IconArray%ExtID%
}
if not IconNumber ; There is not yet any icon for this extension, so load it.
{
; Get the high-quality small-icon associated with this file extension:
if not DllCall("Shell32\SHGetFileInfo" . (A_IsUnicode ? "W":"A"), "Str", FileName
, "UInt", 0, "Ptr", &sfi, "UInt", sfi_size, "UInt", 0x101) ; 0x101 is SHGFI_ICON+SHGFI_SMALLICON
IconNumber := 9999999 ; Set it out of bounds to display a blank icon.
else ; Icon successfully loaded.
{
; Extract the hIcon member from the structure:
hIcon := NumGet(sfi, 0)
; Add the HICON directly to the small-icon and large-icon lists.
; Below uses +1 to convert the returned index from zero-based to one-based:
IconNumber := DllCall("ImageList_ReplaceIcon", "Ptr", ImageListID1, "Int", -1, "Ptr", hIcon) + 1
DllCall("ImageList_ReplaceIcon", "Ptr", ImageListID2, "Int", -1, "Ptr", hIcon)
; Now that it's been copied into the ImageLists, the original should be destroyed:
DllCall("DestroyIcon", "Ptr", hIcon)
; Cache the icon to save memory and improve loading performance:
IconArray%ExtID% := IconNumber
}
}
FormatTime, TimeString,%A_LoopFileTimeCreated%,MM.dd.yy
LV_Add("Icon" . IconNumber, A_LoopFileName, FileExt,A_LoopFileTimeModified,TimeString)
}
GuiControl, +Redraw, MyListView ; Re-enable redrawing (it was disabled above).
LV_ModifyCol() ; Auto-size each column to fit its contents.o reveal its header.
LV_ModifyCol(1,640)
LV_ModifyCol(2,50)
LV_ModifyCol(3,0)
LV_ModifyCol(5,120)
Process, Priority,,Normal
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonSwitchView:
if not IconView
GuiControl, +Icon, MyListView ; Switch to icon view.
else
GuiControl, +Report, MyListView ; Switch back to details view.
IconView := not IconView ; Invert in preparation for next time.
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MyListView:
if ( A_GuiEvent = "ColClick" And A_EventInfo = 4 )
{
If Sort
LV_ModifyCol(3, "Sort")
else
LV_ModifyCol(3, "SortDesc")
Sort := not Sort
}
if (A_GuiEvent = "DoubleClick") ; There are many other possible values the script can check.
{
LV_GetText(FileName, A_EventInfo, 1) ; Get the text of the first field.
LV_GetText(FileDir, A_EventInfo, 2) ; Get the text of the second field.
Run %folder%\%FileName%,, UseErrorLevel
if ErrorLevel
MsgBox Could not open "%FileDir%\%FileName%".
}
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
run:
ControlGetFocus,lv,Easy-OneFile
if lv=SysListView321
{
file:=lvgetfile()
Run %file%,, UseErrorLevel
if ErrorLevel
MsgBox Could not open "%FileDir%\%FileName%".
}
else
send,{return}
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lvgetfile()
{
global folder
FocusedRowNumber := LV_GetNext(0, "F") ; Find the focused row.
if not FocusedRowNumber ; No row is focused.
return
LV_GetText(FileName, FocusedRowNumber, 1)
tt=%folder%\%FileName%
return tt
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
showdestgui()
{
global listfolders,clv,Fontsize
gui,2: destroy
gui,2: font,S%Fontsize% Arial Normal
gui,2: margin,0,0
Gui,2:Show,,Copy to ...
Count := listfolders.Count()
gui,2:add,button,w500 gallbutton,--CANCEL--
Loop % count
{
Gui,2:default
lv:= listfolders[A_Index]
gui,2:add,button,w500 gallbutton,%lv%
Gui,2:Show,AutoSize,Copy to ...
}
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2GuiClose:
gui,2: destroy
mode=
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!q::
ExitApp
GuiClose:
Gui,hide
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TABFocus:
if tabfoc=left
{
ControlFocus,button1,Easy-OneFile
tabfoc=right
return
}
else
{
ControlFocus,SyslistView321,Easy-OneFile
tabfoc=left
return
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
starthide:
!a::
if WinExist("Easy-OneFile")
Gui,hide
else
{
Gui,show,,Easy-OneFile
sleep,100
ControlFocus,button1,Easy-OneFile
}
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mail:
if Outlook !
{
run,Outlook.exe
Outlook := ""
while !Outlook
try Outlook := ComObjActive("Outlook.Application")
catch
Sleep 200
}
file:=lvgetfile()
email := Outlook.Application.CreateItem(0)
email.To := ""
;email.SentOnBehalfOfName := ""
email.Body := "Regards My Name"
email.Subject := ""
email.Display
email.Attachments.add(file)
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
savepic:
hBM := 0
hBM := CB_hBMP_Get()
If ( hBM )
{
ui=
InputBox,ui,File-Name, Please enter a File-Name.
if ui
{
SelectedFile=%folder%/%ui%.bmp
GDIP("Startup")
SavePicture(hBM,SelectedFile)
GDIP("Shutdown")
DllCall( "DeleteObject", "Ptr",hBM )
LV_Delete()
gosub ButtonLoadFolder2
GuiControl, +Redraw, MyListView
LV_ModifyCol(3, "SortDesc")
}
}
Return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CB_hBMP_Get() { ; By SKAN on D297 @ bit.ly/2L81pmP
Local OK := [0,0,0,0]
OK.1 := DllCall( "OpenClipboard", "Ptr",0 )
OK.2 := OK.1 ? DllCall( "IsClipboardFormatAvailable", "UInt",8 ) : 0 ; CF_BITMAP
OK.3 := OK.2 ? DllCall( "GetClipboardData", "UInt", 2, "Ptr" ) : 0
OK.4 := OK.1 ? DllCall( "CloseClipboard" ) : 0
Return OK.3 ? DllCall( "CopyImage", "Ptr",OK.3, "Int",0, "Int",0, "Int",0, "UInt",0x200C, "Ptr" )
+ ( ErrorLevel := 0 ) : ( ErrorLevel := !OK.2 ? 1 : 2 ) >> 2
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SavePicture(hBM, sFile) { ; By SKAN on D293 @ bit.ly/2L81pmP
Local V, pBM := VarSetCapacity(V,16,0)>>8, Ext := LTrim(SubStr(sFile,-3),"."), E := [0,0,0,0]
Local Enc := 0x557CF400 | Round({"bmp":0, "jpg":1,"jpeg":1,"gif":2,"tif":5,"tiff":5,"png":6}[Ext])
E[1] := DllCall("gdi32\GetObjectType", "Ptr",hBM ) <> 7
E[2] := E[1] ? 0 : DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Ptr",hBM, "UInt",0, "PtrP",pBM)
NumPut(0x2EF31EF8,NumPut(0x0000739A,NumPut(0x11D31A04,NumPut(Enc+0,V,"UInt"),"UInt"),"UInt"),"UInt")
E[3] := pBM ? DllCall("gdiplus\GdipSaveImageToFile", "Ptr",pBM, "WStr",sFile, "Ptr",&V, "UInt",0) : 1
E[4] := pBM ? DllCall("gdiplus\GdipDisposeImage", "Ptr",pBM) : 1
Return E[1] ? 0 : E[2] ? -1 : E[3] ? -2 : E[4] ? -3 : 1
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GDIP(C:="Startup") { ; By SKAN on D293 @ bit.ly/2L81pmP
Static SI:=Chr(!(VarSetCapacity(Si,24,0)>>16)), pToken:=0, hMod:=0, Res:=0, AOK:=0
If (AOK := (C="Startup" and pToken=0) Or (C<>"Startup" and pToken<>0)) {
If (C="Startup") {
hMod := DllCall("LoadLibrary", "Str","gdiplus.dll", "Ptr")
Res := DllCall("gdiplus\GdiplusStartup", "PtrP",pToken, "Ptr",&SI, "UInt",0)
} Else {
Res := DllCall("gdiplus\GdiplusShutdown", "Ptr",pToken )
DllCall("FreeLibrary", "Ptr",hMod), hMod:=0, pToken:=0
}}
Return (AOK ? !Res : Res:=0)
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GuiSize:
Critical
SetBatchLines, -1
if (A_EventInfo = 1)
return
Process, Priority,,Realtime
Anchor("MyListView","wh")
Anchor("lastline","yw")
w:= A_GuiWidth
LV_ModifyCol(1,270-w)
Process, Priority,,Normal
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Anchor(c, a, r = false) { ; v3.5.1 - Titan
static d
Critical
SetBatchLines, -1
GuiControlGet, p, Pos, %c%
If !A_Gui or ErrorLevel
Return
i = x.w.y.h./.7.%A_GuiWidth%.%A_GuiHeight%.`n%A_Gui%:%c%=
StringSplit, i, i, .
d .= (n := !InStr(d, i9)) ? i9 :
Loop, 4
x := A_Index, j := i%x%, i6 += x = 3
, k := !RegExMatch(a, j . "([\d.]+)", v) + (v1 ? v1 : 0)
, e := p%j% - i%i6% * k, d .= n ? e . i5 : ""
, RegExMatch(d, RegExReplace(i9, "([[\\\^\$\.\|\?\*\+\(\)])", "\$1")
. "(?:([\d.\-]+)/){" . x . "}", v)
, l .= InStr(a, j) ? j . v1 + i%i6% * k : ""
r := r ? "Draw" :
GuiControl, Move%r%, %c%, %l%
}