Advertisement
jdm001

JimmerScripts - Directory Jumper Bar

Jul 11th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. #SingleInstance Force
  3. ; #Warn  ; Enable warnings to assist with detecting common errors.
  4. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  5. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  6.  
  7. Menu Tray, Icon, shell32.dll, 85
  8.  
  9. Gui -Caption -MinimizeBox -MaximizeBox -SysMenu +AlwaysOnTop +ToolWindow
  10.  
  11. Gui Add, Text, x30 y3 w196 h17 +0x200, Directories To Jump Back?
  12. Gui Add, Edit, vBACK x160 y3 w23 h15 Center +Number, 01
  13.  
  14. Gui Add, Text, x185 y3 w180 h17 +0x200, How Many Folders Forward?
  15. Gui Add, Edit, vFWD x320 y3 w15 h15 Center +Number, 1
  16.  
  17. Gui Font, s6
  18. Gui Add, Button, gHELPME x0 y0 w29 h20, Help
  19. Gui Font
  20. Gui Add, Button, gDJUMP x340 y0 w150 h20, DIRECTORY JUMP
  21. Gui Add, Button, gXCLOSE x505 y0 w13 h20, X
  22. Gui Add, Text, x495 y3, ยง
  23. Gui Color, 0x80FF80
  24. Gui Show, x372 y5 w520 h20, Directory Jumper
  25.  
  26.  
  27. OnMessage( 0x200, "WM_MOUSEMOVE" )
  28. Return
  29.  
  30. WM_MOUSEMOVE( wparam, lparam, msg, hwnd )
  31. {
  32.     if wparam = 1 ; LButton
  33.         PostMessage, 0xA1, 2,,, A ; WM_NCLBUTTONDOWN
  34. }
  35.  
  36.  
  37. IsItFoF:
  38. sel := Explorer_GetSelected()
  39. SplitPath, sel, OutFileName
  40. ;MsgBox, `tSelection is `n[%sel%] `n`n `tHighlighted File is `n[%OutFileName%]
  41. IfInString, OutFileName, .
  42.     {
  43.     HighlightedItem := 1  ; File detected
  44.     Return
  45.     }
  46.     Else
  47.     {
  48.     HighlightedItem := 0  ; Folder detected
  49.     Return
  50.     }
  51. return
  52.  
  53.  
  54. DJUMP:
  55. {
  56. Gui, Submit, nohide
  57. WinActivate, ahk_class CabinetWClass
  58.  
  59. Loop, %BACK%
  60.     {
  61.     SendInput, !{Up}
  62.     }
  63.  
  64. Send, {Down}
  65.  
  66. Loop, %FWD%
  67.     {
  68.     Send, {Enter}
  69.     GoSub, IsItFoF
  70.     If (HighlightedItem=1)
  71.     {
  72.     MsgBox, File Detected - Stopping
  73.     Break
  74.     }
  75.     Else
  76.     {
  77.         SoundBeep, SoundBeep, SoundBeep
  78.     Return
  79.     }
  80.     }
  81.  
  82. Return
  83. }
  84.  
  85. HELPME:
  86. {
  87. MsgBox, , Directory Jumper, `tDirectory Jumper`nDirectory Jumper is a program that will jump into the next folder in a directory (or any number of subdirectories) and go into the next directory in a list.`nThis is great when you have to enter many subdirectories of the same location.`n`n`n`tTo use this program-`nTo use DirectoryJumper enter the amount of directories to go back and then the amount of directories to jump forward into.`n`nThe Jump Forward Box - This box is almost always 1 unless for some reason you want to go to every other directory (enter 2) or every 3rd directory etc.`n`nThe Jump Back Box - This is the main box. This tells Directory Jumper how many folders back it needs to go before it can go to the next directory.  If this number is 1, it goes up one folder and then goes into the next folder.  If each item has its own subfolder(s) you can increase this number to accommodate. `n`nFor Example- You have one directory with a ton of sub directories.  Each of those directories has a sub directory that you want to enter.  The BACK number should be 2 (so that it jumps up from the sub directory back into the main directory housing what you are investigating) and the FWD number should be the default 1 (Unless you want to check every other folder in that main investigation directory)`n`n`nThe X button just exits the program.  Otherwise Directory Jumper will remain in the taskbar tray and only become visable when you are in a directory in Windows Explorer. `n`nYou can also move the window wherever you want by click and holding on any text field.  It works well to the side of the Windows Explorer toolbar next to VIEW.
  88. Return
  89. }
  90.  
  91. Explorer_GetSelected(hwnd="")
  92. {
  93.     return Explorer_Get(hwnd,true)
  94. }
  95.  
  96. Explorer_GetWindow(hwnd="")
  97. {
  98.     WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
  99.     WinGetClass class, ahk_id %hwnd%
  100.    
  101.     if (process!="explorer.exe")
  102.         return
  103.     if (class ~= "(Cabinet|Explore)WClass")
  104.     {
  105.         for window in ComObjCreate("Shell.Application").Windows
  106.             if (window.hwnd==hwnd)
  107.                 return window
  108.     }
  109.     else if (class ~= "Progman|WorkerW")
  110.         return "desktop" ; desktop found
  111. }
  112.  
  113. Explorer_Get(hwnd="",selection=false)
  114. {
  115.     if !(window := Explorer_GetWindow(hwnd))
  116.         return ErrorLevel := "ERROR"
  117.     if (window="desktop")
  118.     {
  119.         ControlGet, hwWindow, HWND,, SysListView321, ahk_class Progman
  120.         if !hwWindow ; #D mode
  121.             ControlGet, hwWindow, HWND,, SysListView321, A
  122.         ControlGet, files, List, % ( selection ? "Selected":"") "Col1",,ahk_id %hwWindow%
  123.         base := SubStr(A_Desktop,0,1)=="\" ? SubStr(A_Desktop,1,-1) : A_Desktop
  124.         Loop, Parse, files, `n, `r
  125.         {
  126.             path := base "\" A_LoopField
  127.             IfExist %path% ; ignore special icons like Computer (at least for now)
  128.                 ret .= path "`n"
  129.         }
  130.     }
  131.     else
  132.     {
  133.         if selection
  134.             collection := window.document.SelectedItems
  135.         else
  136.             collection := window.document.Folder.Items
  137.         for item in collection
  138.             ret .= item.path "`n"
  139.     }
  140.     return Trim(ret,"`n")
  141. }
  142.  
  143.  
  144. GuiEscape:
  145. GuiClose:
  146. XCLOSE:
  147. {
  148. ExitApp
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement