This is AHK script that will parse wincmd.ini and create TC's favorite menu. Start with CTRL + W
Screenshot:
http://i2.turboimage...0504/screen.jpg
v0.2
- Full TC's favorites menu
- If called inside active dialog (save, open, browse):
- if path is choosen, change the path IN dialog
- if plugin is choosen, start or activate TC and switch to the plugin
- If called on ANY active window that is NOT the dialog activate or open TC
- If called on TC, redirect to TCs own dialog to be able to see configuration enteries (removed since 0.4)
v0.3
- removed several "setup" options.
- icons in menus (12x12, first pixel color defines transparent color)
- Properties dialog (call with CTRL + ENTER on menu item): you can set title, command and icon (icon requires restart for now, it will not be transparent in preview)
v0.4
- removed Dialogs setup option. Now works on all open/save dialogs no matter the title
- little improvement of Properties dialog
- handling of pseudo environement variables ($...) (call TC)
- removed calling TCs own dialog when working in TC.
SETUP
Edit path to ini and executable or define %COMMANDER_PATH%.
Please report bugs if you find them.
PS: Some icons here: http://urlgreyhot.co...rces/mini_icons
Post more links if you find them.
;************************************************************************* ; TC FavMenu 0.4 ; ; ; Created by majkinetor ! Jun 2006 ; ; code.r-moth.com www.r-moth.com r-moth.deviantart.com ;************************************************************************* ;-============================ SETUP ==================================== tcExe = %COMMANDER_PATH%\TotalCmd.exe tcIni = %COMMANDER_PATH%\wincmd.ini ;============================= AUTOEXECUTE =============================== SetKeyDelay, -1 DetectHiddenWindows, on #SingleInstance force Menu tray, icon, %SystemRoot%\System32\shell32.dll, 44 g_sub_cnt = 0 ;AHK submenu counter g_mnu_cnt = 0 ;TC menu counter CreateFullMenu() Gui, Add, Edit, veTitle x16 y22 w200 h18, Gui, Add, Edit, veCommand x16 y72 w270 h20, Gui, Add, Edit, veIcon x17 y119 w248 h20, Gui, Add, Text, x16 y5 w80 h16, Title Gui, Add, Text, x16 y55 w80 h16, Path Gui, Add, Picture, BackgroundTrans AltSubmit vpicIcon x16 y102 w16 h16 Gui, Add, Button, gOnBrowseClick x267 y121 w18 h17, .. Gui, Add, Button, gOnSaveClick x104 y155 w104 h19, &Save Gui, Add, Button, gOnNavClick x255 y23 w15 h15, < Gui, Add, Button, vbtnUp gOnNavClick x270 y23 w15 h15, > ;Gui, Show, x370 y313 h185 w299, Generated using SmartGUI Creator 3.5.1 OnMessage(0x100, "OnKeyDown") OnMessage(0x18, "OnShowWindow") Return OnSaveClick: Gui, Submit IniWrite, %eTitle%, %tcIni%, DirMenu, menu%g_mnu_cnt% IniWrite, cd %eCommand%, %tcIni%, DirMenu, cmd%g_mnu_cnt% IniWrite, %eIcon%, %tcIni%, DirMenu, icon%g_mnu_cnt% if (A_ThisMenuItem != eTitle) Menu, %A_ThisMenu%, Rename, %A_ThisMenuItem%, %eTitle% command%i%_%j% := "cd " . eCommand return OnBrowseClick: FileSelectFile, picIcon, 3, , Select Icon, Icons (*.ico) GuiControl, Text, picIcon, %picIcon% GuiControl, Text, eIcon, %picIcon% return GuiClose: Gui, Hide return OnKeyDown(wparam, lparam) { if (wparam = "27") Gui, Hide } OnShowWindow(wparam, lparam) { global if (! wparam) return IniRead, mnu, %tcIni%, DirMenu, menu%g_mnu_cnt%, & IniRead, cmd, %tcIni%, DirMenu, cmd%g_mnu_cnt%, & IniRead, ico, %tcIni%, DirMenu, icon%g_mnu_cnt%, & if (ico = "&") ico := "" StringMid cmd, cmd, 4 GuiControl, Text, eTitle, %mnu% GuiControl, Text, eCommand, %cmd% GuiControl, Text, eIcon, %ico% GuiControl, Text, picIcon, %ico% } OnNavClick: oldval := g_mnu_cnt plusminus: if (A_GuiControl = "btnUp") g_mnu_cnt += 1 else g_mnu_cnt -= 1 IniRead, mnu, %tcIni%, DirMenu, menu%g_mnu_cnt%, & if (mnu = "&") { g_mnu_cnt := oldval return } if (mnu = "-") or (mnu = "--") goto plusminus OnShowWindow(true, 0) return return ;------------------------------------------------------------------------ ;------------------------------------------------------------------------ ^w:: ;handle Total COmmander; call its own menu ;IfWinActive ahk_class TTOTAL_CMD ;{ ; SendTCCommand("cm_DirectoryHotlist") ; return ;} MouseGetPos, mouseX, mouseY Menu, sub1, show, %mouseX%, %mouseY% return ;------------------------------------------------------------------------- CreateMenu() { local separator, cmd_cnt, submenu_id, sub_num, mnu, cmd, ico separator := false cmd_cnt = 0 g_sub_cnt += 1 sub_num = %g_sub_cnt% submenu_id = sub%sub_num% Loop { ;read next menu item g_mnu_cnt += 1 IniRead, mnu, %tcIni%, DirMenu, menu%g_mnu_cnt%, & IniRead, cmd, %tcIni%, DirMenu, cmd%g_mnu_cnt%, & IniRead, ico, %tcIni%, DirMenu, icon%g_mnu_cnt%, & if (mnu = "&") break ;is it separator ? if (mnu = "-") { if ( separator = true ) continue separator := true Menu, %submenu_id%, add cmd_cnt += 1 continue } ;not a separator, determine what is it from next 2 charachters StringMid, c1, mnu, 1, 1 StringMid, c2, mnu, 2, 1 ; "--" exit condition (end of submenu), return this menu to the caller if (c2 = "-") return %submenu_id% ; "-....." submenu, create it if (c1 = "-") { StringMid, name, mnu, 2, 100 Menu, %submenu_id%, add, %name%, % ":" . CreateMenu() cmd_cnt += 1 if FileExist(ico) Menu_AssignBitmap( submenu_id, cmd_cnt, ico ) continue } mnu = %mnu% Menu, %submenu_id%, add, %mnu%, MenuHandler cmd_cnt += 1 command%sub_num%_%cmd_cnt% := cmd menu_order%sub_num%_%cmd_cnt% := g_mnu_cnt if FileExist(ico) Menu_AssignBitmap( submenu_id, cmd_cnt, ico ) separator := false } } ;----------- MenuHandler: ;-- calculate item and position j := A_ThisMenuItemPos StringReplace i, A_ThisMenu, sub, keys := % command%i%_%j% g_mnu_cnt := % menu_order%i%_%j% ;-- handle property window GetKeyState, state, Control if (state = "D") { Gui, Show, x370 y313 h185 w299, Properties return } ;-- remove "cd " StringMid keys, keys, 4 ;--%$name% -\ ;-- \\\plugin - call total commander unconditionaly ;-- path - send keys if dialog else call TC StringGetPos tmp1, keys, \\\ StringGetPos tmp2, keys, `%$ if (tmp1 != -1) or (tmp2 != -1) { openTC(keys) return } if (DialogWindowActive() ) { SendRaw %keys% Send {ENTER} return } ;-- not property, not dialog, let TC handle it openTc(keys) return ;-------------------------------------------------------------------------- SendTCCommand(xsTCCommand) { loop Read, %COMMANDER_PATH%\TOTALCMD.INC { StringSplit asCommands, A_LoopReadLine, = if (asCommands1 = xsTCCommand) { StringSplit asCommandsValues, asCommands2, `; Break } } if (asCommandsValues1 > 0) PostMessage 1075, %asCommandsValues1%, 0, , ahk_class TTOTAL_CMD } ;-------------------------------------------------------------------------- OpenTc(keys) { global if not WinExist("ahk_class TTOTAL_CMD") { Run %tcExe% WinWait, ahk_class TTOTAL_CMD } WinActivate ahk_class TTOTAL_CMD SendTCCommand("cm_editpath") SendRaw, %keys% Send, {ENTER} } ;-------------------------------------------------------------------------- CreateFullMenu() { global ifWinExist ahk_class TTOTAL_CMD1 { SendTCCommand("cm_CopySrcPathToClip") if StrPos Menu sub1, add, %clipboard% , FullMenuHandler SendTCCommand("cm_CopyTrgPathToClip") Menu sub1, add, %clipboard% , FullMenuHandler Menu sub1, add } CreateMenu() } ;--------------------------------------------------------------------------- FullMenuHandler: SendRaw %A_ThisMenuItem% Send {ENTER} return ;====================== INCLUDES =========================================== /* p_menu = "MenuName" (e.g., Tray, etc.) p_item = 1, ... p_bm_unchecked, */ Menu_AssignBitmap( p_menu, p_item, p_bm_unchecked) { static h_menuDummy if h_menuDummy= { Menu, menuDummy, Add Menu, menuDummy, DeleteAll Gui, 99:Menu, menuDummy Gui, 99:Show, Hide, guiDummy old_DetectHiddenWindows := A_DetectHiddenWindows DetectHiddenWindows, on Process, Exist h_menuDummy := DllCall( "GetMenu", "uint", WinExist( "guiDummy ahk_class AutoHotkeyGUI ahk_pid " ErrorLevel ) ) if ReportError( ErrorLevel or h_menuDummy = 0, "Menu_AssignBitmap: GetMenu", "h_menuDummy = " h_menuDummy ) return, false DetectHiddenWindows, %old_DetectHiddenWindows% Gui, 99:Menu Gui, 99:Destroy } Menu, menuDummy, Add, :%p_menu% h_menu := DllCall( "GetSubMenu", "uint", h_menuDummy, "int", 0 ) if ReportError( ErrorLevel or h_menu = 0, "Menu_AssignBitmap: GetSubMenu", "h_menu = " h_menu ) return, false success := DllCall( "RemoveMenu", "uint", h_menuDummy, "uint", 0, "uint", 0x400 ) if ReportError( ErrorLevel or ! success, "Menu_AssignBitmap: RemoveMenu", "success = " success ) return, false Menu, menuDummy, Delete, :%p_menu% if ( p_bm_unchecked ) { hbm_unchecked := DllCall( "LoadImage" , "uint", 0 , "str", p_bm_unchecked , "uint", 2 ; IMAGE_ICON , "int", 0 , "int", 0 , "uint", 0x10 | 0x20 ) ; LR_LOADFROMFILE|LR_LOADTRANSPARENT if ReportError( ErrorLevel or ! hbm_unchecked, "Menu_AssignBitmap: LoadImage: unchecked", "hbm_unchecked = " hbm_unchecked ) return, false VarSetCapacity(sICONINFO, 20, 0) ;4 + 2*4+ 2*4 = 20 InsertInteger(1, sICONINFO, 0) res := DllCall( "GetIconInfo", "Uint", hbm_unchecked, "str", sICONINFO) if ReportError( ErrorLevel or ! res, "Menu_AssignBitmap: GetIconInfo: ", "res = " res ) return, false hbm_unchecked := ExtractInteger(sICONINFO, 16, true) } success := DllCall( "SetMenuItemBitmaps" , "uint", h_menu , "uint", p_item-1 , "uint", 0x400 ; MF_BYPOSITION , "uint", hbm_unchecked , "uint", 0 ) if ReportError( ErrorLevel or ! success, "Menu_AssignBitmap: SetMenuItemBitmaps", "success = " success ) return, false return, true } ReportError( p_condition, p_title, p_extra ) { if p_condition MsgBox, ( LTrim [Error] %p_title% EL = %ErrorLevel%, LE = %A_LastError% %p_extra% ) return, p_condition } ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4) { Loop %pSize% ; Build the integer by adding up its bytes. result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1) if (!pIsSigned OR pSize > 4 OR result < 0x80000000) return result ; Signed vs. unsigned doesn't matter in these cases. ; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart: return -(0xFFFFFFFF - result + 1) } InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) { Loop %pSize% ; Copy each byte in the integer into the structure as raw binary data. DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF) } DialogWindowActive() { WinGet, active_hwnd, ID, A { if ( IsDialog( active_hwnd ) ) return 1 else return 0 } return 0 } ;------------------------------------------------------------------------------------------------ IsDialog(dlg) { local toolbar, edit, combo, button toolbar := FindWindowExID(dlg, "ToolbarWindow32", "0x440") ;windows XP if (toolbar = "0") toolbar := FindWindowExID(dlg, "ToolbarWindow32", "0x001") ;windows 2k edit := FindWindowExID(dlg, "Edit", "0x480") ; edit field combo := FindWindowExID(dlg, "ComboBoxEx32", "0x47C") ; comboboxex field button := FindWindowExID(dlg, "Button", "0x001") ; second button if (toolbar && (combo || edit) && button) return 1 else return 0 } ;------------------------------------------------------------------------------------------------ ; Iterate through controls with the same class, find the one with ctrlID and return its handle ; Used for finding a specific control on a dialog FindWindowExID(dlg, className, ctrlId) { local ctrl, id ctrl = 0 Loop { ctrl := DllCall("FindWindowEx", "uint", dlg, "uint", ctrl, "str", className, "uint", 0 ) if (ctrlId = "0") { return ctrl } if (ctrl != "0") { id := DllCall( "GetDlgCtrlID", "uint", ctrl ) if (id = ctrlId) return ctrl } else return 0 } }
Soon
- Sorce and Target paths as first 2 items in the menu
- Check for TC paths in registry if %COMMANDER_PATH% not defined
* TC History in submenu (maybe)