Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#include <winapi.au3> #include <winapishellex.au3> #include <File.au3> #include <_Array.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GUITreeview.au3> #include <WinAPIFiles.au3> ;Opt("GUIOnEventMode", 1); DOsent work bcuz _treeview -.- Local $_getSciteDir = _getSciteDir() Local $_GetTrashCan = @ScriptDir & "\___TrashCan" Local $SciteWidth = 1024, $SciteHeight = 768, $LastSciteWidth, $LastSciteHeight Local $hTreeView, $hTreeClickType Local $hGUI = GUICreate("Test", $SciteWidth, $SciteHeight, -1, -1, $WS_SIZEBOX + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX, $WS_EX_ACCEPTFILES) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY"); Keep rightclick on same ID Local $hTreeView = GUICtrlCreateTreeView(0, 0, $SciteWidth, $SciteHeight); _guictrltreeview gör någon konstig bug GUICtrlSetResizing($hTreeView , $GUI_DOCKAUTO) Local $sRoot = "C:\Autoit\Livia Spelmotor" Local $hContextMenu = GUICtrlCreateContextMenu($hTreeView) Local $hContextItem_renameFile = GUICtrlCreateMenuItem("Test", $hContextMenu) Local $hContextItem_deleteFile = GUICtrlCreateMenuItem("Remove", $hContextMenu) Local $hItems = _GuictrlTreeview__FileListToArrayRec($hTreeView, $sRoot, ".au3", "BackUp;.git") ;Set same colours as Scite SciTEUser SciTEUserSciTEUserSciTEUserSciTEUserSciTEUser ;_GUICtrlTreeView_SetIcon ;_GUICtrlTreeView_SetBkColor($hTreeView, 0x272822) ;GUICtrlSetColor($hTreeView, 0xFFFFFF) GUISetState() Local $CurClickEvent = Null While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop Case $hContextItem_renameFile _App_EditFileName() Case $hContextItem_deleteFile _App_DeleteFile() EndSwitch ;Specialevent for "double click If $CurClickEvent == $NM_DBLCLK Then ;_App_DeleteFile() Local $Get = _GetSelectedTreeViewItem() Local $CallBack = _SciteGOTO($Get[2]) ConsoleWrite("#"&$CallBack&@CRLF) ;TEST $CurClickEvent= Null EndIf #cs $wSize = WinGetClientSize($hGUI) If $LastSciteWidth <> $wSize[0] Then $LastSciteWidth = $wSize[0] _WinAPI_MoveWindow($h_HWND, $hTreeWidth, 0, $LastSciteWidth - $hTreeWidth, $LastSciteHeight, True) EndIf If $LastSciteHeight <> $wSize[1] Then $LastSciteHeight = $wSize[1] _WinAPI_MoveWindow($h_HWND, $hTreeWidth, 0, $LastSciteWidth - $hTreeWidth, $LastSciteHeight, True) EndIf #ce WEnd Func _SciteGOTO($s_au3, $iLine = 1, $s_scite = Default) If Not FileExists($s_au3) Then Return SetError(1, 0, "") If $iLine < 1 Then Return SetError(2, 0, "") If $s_scite = Default Then $s_scite = $_getSciteDir & "SciTE.exe" EndIf If Not FileExists($s_scite) Then Return SetError(3, 0, "") $s_au3 = StringReplace($s_au3, "\", "\\") Run($s_scite & ' "-open:' & $s_au3 & '" -goto:' & $iLine) If @error Then Return SetError(4, 0, "") Return True EndFunc ;==>_SciteGOTO Func _App_DeleteFile() Local $aData = _GetSelectedTreeViewItem(); 0 hwnd, 1 id 2 Full file path Local $hItem = $aData[0] Local $aListID = $aData[1] Local $originalFilePath = $aData[2] Local $ShortName = _Misc_GetFileName($originalFilePath, False) Local $ErrText = "" Local $Success = True Local $sFileType = FileGetAttrib($originalFilePath) ; Move the original to our fake trashcan (User has to delete the files himself) If $sFileType == "D" Then Local $TrashFileName = StringFormat("%s\%s_%s", $_GetTrashCan, $ShortName, @HOUR & @MIN & @MSEC) Local $MsgBox = MsgBox(4, "", StringFormat("Are you sure you want to delete this DIRECTORY '%s'?", $ShortName)) Else Local $TrashFileName = StringFormat("%s\%s_%s.deleted", $_GetTrashCan, $ShortName, @HOUR & @MIN & @MSEC) Local $MsgBox = MsgBox(4, "", StringFormat("Are you sure you want to delete this file '%s' ?", $ShortName)) EndIf If $MsgBox <> 6 Then Return False If $sFileType == "D" Then ; Remove parent from hItems _Array_Remove($hItems, $aListID) Local $aFileList = _FileListToArrayRec($originalFilePath, "*.au3", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) ; Remove children of parents hItems (If there is any) If IsArray($aFileList) Then Do Local $Complete = True For $i = 1 To $hItems[0] - 1 For $j = 1 To $aFileList[0] If $hItems[$i] == $aFileList[$j] Then _Array_Remove($hItems, $i) $Complete = False ExitLoop EndIf If Not $Complete Then ExitLoop Next Next Until $Complete == True EndIf ;Move the entire directory $dir_copy1 = DirCopy($originalFilePath, $TrashFileName) if $dir_copy1 Then DirRemove($originalFilePath, 1) Else $ErrText &= StringFormat("Failed to copy file from '%s' => '%s'", $originalFilePath, $TrashFileName) & @CRLF $Success = False EndIf Else Local $copy_2 = FileCopy($originalFilePath, $TrashFileName) If Not $copy_2 Then $ErrText &= StringFormat("Failed to copy file from '%s' => '%s'", $originalFilePath, $TrashFileName) & @CRLF $Success = False EndIf ;Delete the original Local $delete_1 = FileDelete($originalFilePath) If Not $delete_1 Then $ErrText &= StringFormat("Failed to delete original file '%s' ", $originalFilePath) & @CRLF $Success = False EndIf EndIf If Not $Success Then Return MsgBox(0, "Failed to delete the file.", $ErrText) _GUICtrlTreeView_Delete($hTreeView, $hItem) EndFunc ;==>_App_DeleteFile Func _App_EditFileName() Local $aData = _GetSelectedTreeViewItem(); 0 hwnd, 1 id 2 Full file path Local $hItem = $aData[0] Local $aListID = $aData[1] Local $originalFilePath = $aData[2] Local $ShortName = _Misc_GetFileName($originalFilePath) Local $Success = True Local $ErrText = "" If _WinAPI_FileInUse($originalFilePath) Then $ErrText &= StringFormat("The file '%s' is currently in use by another program for read\writing", $ShortName) & @CRLF $Success = False EndIf Do Local $NewFileName = InputBox("New name", StringFormat("Rename %s", $ShortName), $ShortName, "", -1, 130) ;If user aborts If $NewFileName == "" Or $NewFileName == $ShortName Then Return False If StringRight($NewFileName, 4) <> ".au3" Then $ErrText &= StringFormat("The file '%s' has an invalid file-extension", $NewFileName) & @CRLF $Success = False Else $Success = True EndIf ;Get the new full file name Local $aTmp = StringSplit($originalFilePath, "\") $aTmp[$aTmp[0]] = $NewFileName _ArrayDelete($aTmp, 0) Local $NewFilePath = _ArrayToString($aTmp, "\") ; check if new file exists If FileExists($NewFilePath) Then $ErrText &= StringFormat("The file '%s' already exists..", $NewFileName) & @CRLF $Success = False EndIf If Not FileExists($originalFilePath) Then $ErrText &= StringFormat("The file '%s' you are trying to change dosent exist anymore... ", $originalFilePath) & @CRLF $Success = False EndIf If Not $Success Then MsgBox(0, "Failed to change filename", $ErrText) Until $Success == True ; Copy the file with a new name Local $copy_1 = FileCopy($originalFilePath, $NewFilePath) If Not $copy_1 Then $ErrText &= StringFormat("Failed to rename file from '%s' => '%s'", $originalFilePath, $NewFilePath) & @CRLF $Success = False EndIf ; Move the original to our fake trashcan (User has to delete the files himself) Local $TrashFileName = StringFormat("%s\%s_%s.deleted", $_GetTrashCan, $ShortName, @HOUR & @MIN & @MSEC) Local $copy_2 = FileCopy($originalFilePath, $TrashFileName) If Not $copy_2 Then $ErrText &= StringFormat("Failed to copy file from '%s' => '%s'", $originalFilePath, $TrashFileName) & @CRLF $Success = False EndIf ;Delete the original Local $delete_1 = FileDelete($originalFilePath) If Not $delete_1 Then $ErrText &= StringFormat("Failed to delete original file '%s' ", $originalFilePath) & @CRLF $Success = False EndIf If Not $Success Then Return MsgBox(0, "Failed to change filename, it exist some damage.", $ErrText) ;Visually change the name _GUICtrlTreeView_SetText($hTreeView, $aData[0], _Misc_GetFileName($NewFileName, False)) ;Updates the Actual list $hItems[$aListID] = $NewFilePath EndFunc ;==>_App_EditFileName Func _GetSelectedTreeViewItem(); 0 hItem, 1 Index, 2 Full file path $iIndex = 0 Local $aRet[3] $hItem = _GUICtrlTreeView_GetFirstItem($hTreeView) For $i = 0 To _GUICtrlTreeView_GetCount($hTreeView) - 1 If _GUICtrlTreeView_GetSelected($hTreeView, $hItem) Then $iIndex = $i + 1 ExitLoop EndIf $hItem = _GUICtrlTreeView_GetNext($hTreeView, $hItem) Next $aRet[0] = $hItem $aRet[1] = $iIndex $aRet[2] = $hItems[$iIndex] Return $aRet EndFunc ;==>_GetSelectedTreeViewItem Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") $CurClickEvent = $iCode Switch $iIDFrom Case $hTreeView Switch $iCode Case $NM_DBLCLK $CurClickEvent = $iCode Case $NM_RCLICK Local $tPoint = _WinAPI_GetMousePos(True, $hWndFrom), $tHitTest $tHitTest = _GUICtrlTreeView_HitTestEx($hWndFrom, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2)) If BitAND(DllStructGetData($tHitTest, "Flags"), $TVHT_ONITEM) Then _GUICtrlTreeView_SelectItem($hWndFrom, DllStructGetData($tHitTest, 'Item')) EndIf Case $TVN_ENDLABELEDITA, $TVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMHDR & ";" & $tagTVITEMEX, $lParam) If DllStructGetData($tInfo, "Text") <> 0 Then Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text")) _GUICtrlTreeView_SetText($hTreeView, _GUICtrlTreeView_GetSelection($hTreeView), DllStructGetData($tBuffer, "Text")) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _getSciteDir() Local $s_AutoIt_InstallPath = RegRead('HKLM\SOFTWARE\AutoIt v3\Autoit', 'InstallDir') Local $s_Scite_InstallPath = StringFormat("%s\%s\", $s_AutoIt_InstallPath, "SciTE") Return $s_Scite_InstallPath EndFunc ;==>_getSciteDir Func _Misc_GetFileName($sFilePath, $KeepExtension = True) ; Gets the filename Local $StringSPlit = StringSplit($sFilePath, "\") If Not $KeepExtension Then Return StringRegExpReplace($StringSPlit[$StringSPlit[0]], "\.(.*?)[a-zA-Z1234567890_-]{1,}+", "") Return $StringSPlit[$StringSPlit[0]] EndFunc ;==>_Misc_GetFileName Func _GuictrlTreeview__FileListToArrayRec($hTreeView, $sRoot, $sAcceptedFiles = ".", $sExcludedFolders = "") Local $aReturn[1];All files stored here in 1D array Local $AcceptedFiles = StringSplit($sAcceptedFiles, ";") Local $ExcludedFolders = StringSplit($sExcludedFolders, ";") $FileListToArray = _FileListToSortedArray($sRoot, $AcceptedFiles, $ExcludedFolders) ; Dummy icon control. Local $hImageList = _GUIImageList_Create(16, 16, 5, 1) _GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList) _GUICtrlTreeView_BeginUpdate($hTreeView) _SortedArrayToTreeView($aReturn, $FileListToArray, 0, $hImageList) _GUICtrlTreeView_EndUpdate($hTreeView) Return $aReturn EndFunc ;==>_GuictrlTreeview__FileListToArrayRec Func _SortedArrayToTreeView(ByRef $aReturn, ByRef $sSourceFolder, $hItem, $hImageList) Local $sCurFileName = "unkown :P", $aFileList, $newItem, $hIcon, $aCurFileList, $hIcon_Index For $i = 2 To $sSourceFolder[0]; Last arg of array push lets us start from 2 instead so we can save 2 for stuff ; Current "file array" $aFileList = $sSourceFolder[$i] ; Get Type If IsArray($aFileList) Then $aCurFileList = $aFileList[1] _Array_Push($aReturn, $aCurFileList) Else $aCurFileList = $aFileList _Array_Push($aReturn, $aCurFileList) EndIf ; Get short name $sCurFileName = _________GetFileName($aCurFileList) ; Get icon of file $hIcon = _WinAPI_ShellExtractAssociatedIcon($aCurFileList, 1) $hIcon_Index = _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) ; Check if "Folder" If IsArray($aFileList) Then ;Ghetto get the folder name $newItem = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sCurFileName, $hIcon_Index, $hIcon_Index) _SortedArrayToTreeView($aReturn, $aFileList, $newItem, $hImageList) Else ;(THIS WILL IGNORE EMPTY DIRECTORYS) SEARCH FOR THIS If Not $sCurFileName Then Else; Regular file _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sCurFileName, $hIcon_Index, $hIcon_Index) EndIf EndIf Next EndFunc ;==>_SortedArrayToTreeView ;// Fuck yeah... Func _FileListToSortedArray($sSourceFolder, $AcceptedFiles, $ExcludedFolders) Local $newTree[1] Local $sFile, $sCurFullFilePath, $DeniedFolder, $DeniedFile ; Force a trailing \ If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\" ; Add basedir to array _Array_Push($newTree, $sSourceFolder) ; Start the search Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*") ; If no files found then return If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Now run through the contents of the folder While 1 ; reset $DeniedFolder = False $DeniedFile = False ; Get next match $sFile = FileFindNextFile($hSearch) $sCurFullFilePath = $sSourceFolder & $sFile If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Check if a folder If @extended Then ; If so then call the function recursively ;Check if exluced folder For $i = 1 To $ExcludedFolders[0] If StringInStr($sFile, $ExcludedFolders[$i]) Then $DeniedFolder = True Next If $DeniedFolder Then ContinueLoop ;Fix empty dirs (THIS WILL IGNORE EMPTY DIRECTORYS) SEARCH FOR THIS Local $try = _FileListToSortedArray($sCurFullFilePath, $AcceptedFiles, $ExcludedFolders) If IsArray($try) Then _Array_Push($newTree, $try) EndIf Else ; If a file than write path and name For $i = 1 To $AcceptedFiles[0] If Not StringInStr($sFile, $AcceptedFiles[$i]) Then $DeniedFile = True Next If $DeniedFile Then ContinueLoop _Array_Push($newTree, $sCurFullFilePath) EndIf WEnd ;Sort this nigga _ArraySort($newTree, 0, 2) Return $newTree EndFunc ;==>_FileListToSortedArray Func _________GetFileName($sFilePath) If Not StringInStr($sFilePath, "\") Then Return False; $sFilePath (THIS WILL IGNORE EMPTY DIRECTORYS) SEARCH FOR THIS Local $StringSplit = StringSplit($sFilePath, "\") If StringRegExp($StringSplit[$StringSplit[0]], "\.(.*?)[a-zA-Z1234567890_-]{1,}+") Then Return $StringSplit[$StringSplit[0]] Return $StringSplit[$StringSplit[0] - 1] EndFunc ;==>_Misc_GetFileName
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
SNLINE list
mIRC | 45 min ago | 1.15 KB
Die 7 wichtigsten Aktionen diese Woche
1 hour ago | 4.17 KB
Untitled
1 hour ago | 13.34 KB
Untitled
3 hours ago | 13.59 KB
VNC SCRIPT 2/2: autoinput.vbs
VBScript | 12 hours ago | 0.23 KB
VNC SCRIPT 1/2: vncauto.bat
Batch | 12 hours ago | 0.72 KB
videoscheomedia
XML | 14 hours ago | 1.00 KB
Untitled
19 hours ago | 14.91 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!