Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Example:
- ; F1::NewFolderFromSelection()
- ; Put in Lib\NewFolderFromSelection.ahk
- NewFolderFromSelection()
- {
- cwd := files := ""
- hWnd := WinActive("A")
- WinGetClass wClass, % "ahk_id" hWnd
- if (wClass = "CabinetWClass") {
- WinGetText wText, A
- RegExMatch(wText, "Address: \K.+", cwd)
- files := NewFolderFromSelection_Folder(hWnd)
- } else if (wClass = "WorkerW") {
- cwd := A_Desktop
- files := NewFolderFromSelection_Desktop(hWnd)
- }
- if !files.Count()
- return
- InputBox newFolder, New folder name:,,, 200, 100
- if (!newFolder)
- return
- FileCreateDir % cwd "\" newFolder
- for _,file in files
- FileMove % file, % cwd "\" newFolder
- }
- NewFolderFromSelection_Desktop(hWnd)
- {
- ControlGet selection, List, Selected, SysListView321
- files := []
- loop Parse, selection, `n
- files.Push(A_Desktop "\" StrSplit(A_LoopField, "`t")[1])
- return files
- }
- NewFolderFromSelection_Folder(hWnd)
- {
- selected := ""
- for window in ComObjCreate("Shell.Application").Windows {
- if (hWnd != window.hWnd)
- continue
- selected := window.Document.SelectedItems
- break
- }
- if (!selected)
- return
- files := []
- for item in selected {
- files.Push(item.Path)
- }
- return files
- }
Add Comment
Please, Sign In to add comment