Guest User

QuickSwitch.ahk

a guest
Dec 25th, 2020
257
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance Force
  2. #NoEnv
  3. ;#Warn  ; Enable warnings to assist with detecting common errors.
  4. SendMode Input
  5. SetBatchLines -1
  6. SetWorkingDir %A_ScriptDir%
  7.  
  8.  
  9. #IfWinActive ahk_class #32770       ; Open/Save dialog
  10.  
  11. ^g::                                ; Control-g
  12. {
  13.     $WinID := WinExist("A")
  14.  
  15. ;---------------[ File Explorer ]----------------------------------------
  16.  
  17.     For $Exp in ComObjCreate("Shell.Application").Windows   {
  18.         $This := $Exp.Document.Folder.Self.Path
  19.         Menu ContextMenu, Add,  %$This%, Choice
  20.         Menu ContextMenu, Icon, %$This%, shell32.dll, 5
  21.     }
  22.  
  23. ;   Clean up
  24.     $Exp := ""
  25.  
  26. ;---------------[ Total Commander ]--------------------------------------
  27.  
  28. ;   Total Commander internal codes
  29.     cm_CopySrcPathToClip  := 2029
  30.     cm_CopyTrgPathToClip  := 2030
  31.  
  32.     ClipSaved := ClipboardAll
  33.     Clipboard := ""
  34.  
  35.     SendMessage 1075, %cm_CopySrcPathToClip%, 0, , ahk_class TTOTAL_CMD
  36.  
  37.     If (ErrorLevel = 0) {
  38.             Menu ContextMenu, Add
  39.             Menu ContextMenu, Add,  %clipboard%, Choice
  40.             Menu ContextMenu, Icon, %clipboard%, shell32.dll, 5
  41.     }
  42.  
  43.     SendMessage 1075, %cm_CopyTrgPathToClip%, 0, , ahk_class TTOTAL_CMD
  44.  
  45.     If (ErrorLevel = 0) {
  46.             Menu ContextMenu, Add,  %clipboard%, Choice
  47.             Menu ContextMenu, Icon, %clipboard%, shell32.dll, 5
  48.     }
  49.  
  50.  
  51.     Clipboard := ClipSaved
  52.     ClipSaved := ""
  53.  
  54. ;---------------
  55.  
  56.     Menu ContextMenu, Show
  57.     Menu ContextMenu, Delete
  58.  
  59. }
  60.  
  61. #IfWinActive
  62. Return
  63.  
  64.  
  65.  
  66. ;_____________________________________________________________________________
  67. ;
  68.                     Choice:
  69. ;_____________________________________________________________________________
  70. ;
  71.  
  72.     $FolderPath := A_ThisMenuItem
  73. ;   MsgBox Folder = %$FolderPath%
  74.  
  75.  
  76.     Gosub FeedExplorerOpenSave
  77.        
  78. return
  79.  
  80.  
  81. ;_____________________________________________________________________________
  82. ;
  83.                     FeedExplorerOpenSave:
  84. ;_____________________________________________________________________________
  85. ;    
  86.  
  87.     WinActivate, ahk_id %$WinID%
  88.  
  89.  
  90. ;   Read the current text in the "File Name:" box (= $OldText)
  91.     ControlGetText $OldText, Edit1, A
  92.     ControlFocus Edit1, A
  93.  
  94.  
  95. ;   Go to Folder
  96.     Loop, 5
  97.     {
  98.         ControlSetText, Edit1, %$FolderPath%, ahk_id %$WinID%       ; set
  99.         Sleep, 50
  100.         ControlGetText, $CurControlText, Edit1, ahk_id %$WinID%     ; check
  101.         if ($CurControlText = $FolderPath)
  102.             break
  103.     }
  104.  
  105.     Sleep, 50
  106.     ControlSend Edit1, {Enter}, A
  107.     Sleep, 50
  108.  
  109.  
  110. ;   Insert original filename
  111.     If !$OldText
  112.         return
  113.  
  114.     Loop, 5
  115.     {
  116.         ControlSetText, Edit1, %$OldText%, A        ; set
  117.         Sleep, 50
  118.         ControlGetText, $CurControlText, Edit1, A       ; check
  119.         if ($CurControlText = $OldText)
  120.             break
  121.     }
  122.  
  123. return
  124.  
RAW Paste Data