AutoHotkey: Refresh the treeinfo.wc of certain drives

From TotalcmdWiki
Revision as of 18:45, 6 June 2008 by White (talk | contribs) (Added category AutoHotkey scripts)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Scheduled refresh

You got some real huge disks and want to refresh the treeinfo.wc overnight, thus you need a program you can put into the scheduler.

This script uses the code for the cm_gotodriveX command to switch to all drives you want to refresh the treeinfo.wc. So you may add some drives or alter the driveletters. The 2063 code means 'open Drive c:\', 2064 means 'open drive d:\' and so on. In my example the trees of drives c:\ d:\ e:\ and i:\ are refreshed.


;start Totalcmd.exe
run "Your\Path\to\\totalcmd.exe" 
;wait until TC-window has opened WinWaitActive, ahk_class TTOTAL_CMD
{ ;open a new tab PostMessage, 1075, 3001, , , ahk_class TTOTAL_CMD ;open drive c:\ PostMessage, 1075, 2063, , , ahk_class TTOTAL_CMD ;wait until the filewindow is read sleep, 1000 ;Open the treewindow PostMessage, 1075, 500, , , ahk_class TTOTAL_CMD ;refresh tree send {F2} ;close the treewindow send {Enter} ;wait until the window has closed WinWaitClose, ahk_class TCHANGETREEDLG
;open next drive PostMessage, 1075, 2064, , , ahk_class TTOTAL_CMD sleep, 1000 PostMessage, 1075, 500, , , ahk_class TTOTAL_CMD send {F2} send {Enter} WinWaitClose, ahk_class TCHANGETREEDLG
;open next drive PostMessage, 1075, 2065, , , ahk_class TTOTAL_CMD sleep, 1000 PostMessage, 1075, 500, , , ahk_class TTOTAL_CMD send {F2} send {Enter} WinWaitClose, ahk_class TCHANGETREEDLG
;open next drive PostMessage, 1075, 2069, , , ahk_class TTOTAL_CMD sleep, 1000 PostMessage, 1075, 500, , , ahk_class TTOTAL_CMD send {F2} send {Enter} WinWaitClose, ahk_class TCHANGETREEDLG
;close the Tab PostMessage, 1075, 3007, , , ahk_class TTOTAL_CMD
;make TC active WinActivate, ahk_class TTOTAL_CMD ;and when active WinWaitActive, ahk_class TTOTAL_CMD ;send the Close TC command PostMessage, 1075, 24340, , , ahk_class TTOTAL_CMD
}

return


Save this script with extension *.ahk (e.g. refresh.ahk), install Autohotkey and call the script with Windows scheduler.

You may remove all lines beginning with a ";", because these are only comments to understand what the script does.


Refresh treeinfo files by hotkey

Use this script if you want to refresh the treeinfo files when pressing a hotkey, Ctrl+Alt+r in this case.

 ~^!r::                                                    ;Ctrl+Alt+r hotkey
 IfWinActive, ahk_class TTOTAL_CMD                         ;check if TC is active
 {
   drives = cdefgjk                                        ;drives you want to refresh, lowercase letters only!
   If drives is not lower                                  ;error interception
   {
     MsgBox, The variable "drives" may contain lowercase letters only, edit please!`nScript will exit now. Byebye!
     Exit
   }
   PostMessage, 1075, 3001, , , ahk_class TTOTAL_CMD       ;open a new tab
   Loop, Parse, drives                                     ;parse drives variable
   {
     Transform, drive, Asc, %A_LoopField%                  ;driveletter to ascii conversion
     drive += 1964                                         ;add 1964 to get cm_GotoDriveX
     PostMessage, 1075, %drive%, , , ahk_class TTOTAL_CMD  ;open drive
     PostMessage, 1075, 500, , , ahk_class TTOTAL_CMD      ;open the treewindow
     WinWaitActive, ahk_class TCHANGETREEDLG               ;wait till it appears
     Send, {F2}                                            ;refresh tree
     Send, {Enter}                                         ;close the treewindow
     WinWaitClose, ahk_class TCHANGETREEDLG                ;wait until it has closed
   }
   PostMessage, 1075, 3007, , , ahk_class TTOTAL_CMD       ;close the tab
 }
 Return



------
Back to AutoHotkey