AutoHotkey: TC Fav Menu: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
No edit summary
 
(Added category AutoHotkey)
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''TC FavMenu 1.0 beta07 '''<br>
[[Image:FavMenu1.jpg|thumb|150px|right|Screenshot of FavMenu editor]]
  ''for Windows XP & 2K''<br>


This is Total Commander utility.<br>
'''TC Fav Menu'''<br>
''for Windows XP & 2K''<br>
 
This is a Total Commander utility.<br>
It will make TC favorites available in the system.<br>
It will make TC favorites available in the system.<br>
It will also make TC Favorites to become Open/Save dialog enhancer (for standard dialogs)<br>
It will also make TC Favorites to become Open/Save dialog enhancer (for standard dialogs)<br>




[[Features and Installation]]
* [[AutoHotkey: TC Fav Menu: Features and Installation|Features and Installation]]
 
 
<pre>
g_title = TC FavMenu 1.0b7
;*************************************************************************
; TC FavMenu
;
;
; Created by majkinetor ! Jun 2006
;
; code.r-moth.com www.r-moth.com r-moth.deviantart.com
;*************************************************************************
#NoEnv
 
TC_FAVMENU_Init()
return
 
;==========================================================================
 
TC_FAVMENU_Init()
{
global
 
DetectHiddenWindows, on
#SingleInstance force
SetKeyDelay, -1
 
 
OnMessage(0x18,  "MessageMonitor")  ;wm_show
OnMessage(0x100, "MessageMonitor")  ;wm_key
cm_editpath = 2912
cm_CopySrcPathToClip = 2029
cm_CopyTrgPathToClip = 2030
cm_FocusLeft = 4001
cm_FocusRight = 4002
cm_OpenNewTab = 3001
 
 
if ( ! GetConfigData() )
Setup_Create()
else
CheckConfigData()
 
SetTrayMenu()
}
 
;--------------------------------------------------------------------------
 
MenuHotKey:
CreateFullMenu()
ShowMenu()
DeleteMenu()
return
 
;--------------------------------------------------------------------------
 
ShowMenu()
{
global  tcPos
 
if (tcPos = 2)
{
posX := A_CaretX
posY := A_CaretY
}
 
if (tcPos = 3)
{
h := WinExist("A")
WinGetPos, , , win_w, win_h, ahk_id %h%
 
posX := win_w /2
posY := win_h /2
}
 
Menu, sub1, show, %posX%, %posY%
}
 
;---------------------------------------------------------------------------
 
CreateMenu()
{
global
local separator, cmd_cnt, submenu_id, sub_num, mnu, cmd, ico, delta, name
 
 
cmd_cnt = 0
g_sub_cnt += 1
 
if (g_sub_cnt = 1)
delta := g_dynamic
 
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
 
menuproc:
;is it separator ?
if (mnu = "-")
{
Menu, %submenu_id%, add
cmd_cnt += 1
continue
}
 
; "--" exit condition (end of submenu), return this menu to the caller
if (mnu = "--")
return %submenu_id%
 
 
; if "-....." submenu, create it (recursion step)
StringMid, c1, mnu, 1, 1
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 + delta, ico )
 
continue
}
 
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 + delta, ico )
}
 
return true
}
 
;--------------------------------------------------------------------------
 
CreateFullMenu()
{
global g_dynamic, command0_2, command0_1
 
 
ifWinExist ahk_class TTOTAL_CMD
{
hwnd := WinExist()
if (hwnd = WinActive())
goto skipdyn
 
GetTCPanels(tc_left, tc_right)
command0_1 := tc_left
command0_2 := tc_right
 
g_dynamic := AddTcPanels(tc_left, tc_right)
}
 
skipdyn:
if (! CreateMenu() )
{
MsgBox, ,TC Fav Menu, Can not create menu, unable to read wincmd.ini.`nApplication will exit now.
ExitApp
}
}
 
;---------------------------------------------------------------------------
 
DeleteMenu()
{
global
 
if (g_sub_cnt = 0 )
return
 
loop
{
if (g_sub_cnt = 0)
break
 
Menu, sub%g_sub_cnt%, Delete
g_sub_cnt -= 1
}
 
g_mnu_cnt = 0
g_dynamic = 0
}
 
;---------------------------------------------------------------------------
 
FullMenuHandler:
if ( DialogWindowActive() )
{
tmp := command0_%A_ThisMenuItemPos%
StringGetPos idx, tmp,\\\
if (idx = -1)
{
SetDialogPath(tmp)
return
}
}
 
; if dialog is not active, just activate TC & panel
if (A_ThisMenuItemPos = 1)
SendTCCommand(cm_FocusLeft, false )
else
SendTCCommand(cm_FocusRight, false )
 
WinActivate ahk_class TTOTAL_CMD
 
return
 
;--------------------------------------------------------------------------
 
MenuHandler:
;-- calculate position of selected item in commands array
j := A_ThisMenuItemPos
if (A_ThisMenu = "sub1")
j -= g_dynamic
 
 
StringReplace i, A_ThisMenu, sub,
keys := % command%i%_%j%
g_mnu_cnt := % menu_order%i%_%j%
 
;-- check modifiers
GetKeyState, stateC, Control
GetKeyState, stateS, Shift
if (stateC = "D")
{
if (properties_visible)
return
properties_mnu_cnt := g_mnu_cnt
Properties_Create()
return
}
 
if (stateS = "D")
bOpenTab := true
else
bOpenTab := false
 
;-- is it file ?
StringLeft, tmp, keys, 3
if (tmp != "cd ")
{
ShellExecute(keys)
return
}
 
;-- remove "cd " (all other commands start with this word)
StringMid keys, keys, 4
 
 
;-- \\\plugin - call total commander unconditionaly
;-- path      - send keys if dialog else call TC
StringGetPos tmp, keys, \\\
if (tmp != -1)
goto open_tc
 
if ( DialogWindowActive() )
{
if (IsPseudoVar(keys))
keys := ConvertPseudoPath(keys)
SetDialogPath(keys)
return
}
 
;-- not the property, not the dialog, let the TC handle it
 
open_tc:
if (bOpenTab)
SendTCCommand(cm_OpenNewTab)
openTc(keys)
return
 
;---------------------------------------------------------------------------
 
ShellExecute(ppath)
{
global g_title
 
if (IsPseudoVar(ppath))
ppath := ConvertPseudoPath(ppath)
 
expath := ExpandEnvVars(ppath)
 
Run %expath%, ,UseErrorLevel
if (ErrorLevel = "ERROR")
MsgBox, 64, %g_title%, Invalid menu item. Command can not be executed:`n%ppath%`n`nExpanded to:`n%expath%
 
return
}
 
;---------------------------------------------------------------------------
 
ExpandEnvVars(ppath)
{
VarSetCapacity(dest, 2000)
DllCall("ExpandEnvironmentStrings", "str", ppath, "str", dest, int, 1999, "Cdecl int")
return dest
}
 
;---------------------------------------------------------------------------
 
IsQuoted(str)
{
StringLeft  sl, str, 1
StringRight sr, str, 1
if (sr = """") && (sl = sr)
return true
else
return false
}
 
;====================== INCLUDES ===========================================
 
; ######################################################################
; ## ExpandIncludes: 1. occurance of "GUI_Properties.ahk"
; -- #include GUI_Properties.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "GUI_Properties.ahk"
; ######################################################################
Properties_Create()
{
global
;title
Gui, Add, Text, x16 y5 w80 h16, Title
Gui, Add, Edit, veTitle x16 y22 w200 h18
 
;nav buttons
Gui, Add, Button, gProperties_OnNavClick x255 y23 w15 h15, <
Gui, Add, Button, vbtnUp gProperties_OnNavClick x270 y23 w15 h15, >
 
;path
Gui, Add, Text, x16 y55 w80 h16, Command
Gui, Add, Edit, veCommand x16 y72 w270 h20,
 
;icon
Gui, Add, Text, x16 y102 w80 h16, Icon
Gui, Add, Picture, BackgroundTrans AltSubmit vpicIcon x46 y102 w16 h16
Gui, Add, Edit, veIcon x17 y119 w248 h20,
Gui, Add, Button, gProperties_OnBrowseClick x267 y121 w18 h17, ..
 
Gui, Add, Button, gProperties_OnSaveClick x16 y155 w104 h19, &Save
 
 
Gui, Show, x370 y313 h185 w299, Properties
properties_visible := true
}
 
;-----------------------------------------------------------------------------------
 
Properties_OnSaveClick:
Gui, Submit, NoHide
 
IniWrite, %eTitle%, %tcIni%, DirMenu, menu%properties_mnu_cnt%
 
if !IsQuoted(eCommand)
IniWrite, %eCommand%, %tcIni%, DirMenu, cmd%properties_mnu_cnt%
else
IniWrite, "%eCommand%", %tcIni%, DirMenu, cmd%properties_mnu_cnt%
 
IniWrite, %eIcon%, %tcIni%, DirMenu, icon%properties_mnu_cnt%
return
 
;-----------------------------------------------------------------------------------
 
Properties_OnKeyDown(wparam, lparam)
{
if (wparam = "27")
Properties_Close()
}
 
;-----------------------------------------------------------------------------------
 
Properties_OnBrowseClick:
FileSelectFile, picIcon, 3, , Select Icon, Icons (*.ico)
if Errorlevel = 1
return
GuiControl, Text, picIcon, %picIcon%
GuiControl, Text, eIcon, %picIcon%
return
 
;-----------------------------------------------------------------------------------
 
Properties_OnShowWindow(wparam, lparam)
{
global
if (! wparam)
return
 
IniRead, mnu, %tcIni%, DirMenu, menu%properties_mnu_cnt%, &
IniRead, cmd, %tcIni%, DirMenu, cmd%properties_mnu_cnt%, &
IniRead, ico, %tcIni%, DirMenu, icon%properties_mnu_cnt%, &
if (ico = "&")
ico := ""
 
GuiControl, Text, eTitle, %mnu%
GuiControl, Text, eCommand, %cmd%
GuiControl, Text, eIcon, %ico%
GuiControl, Text, picIcon, %ico%
}
 
;-----------------------------------------------------------------------------------
 
Properties_OnNavClick:
tmp := properties_mnu_cnt
if (A_GuiControl = "btnUp")
tmp += 1
else
tmp -= 1
 
IniRead, mnu, %tcIni%, DirMenu, menu%tmp%, &
 
if (mnu = "&")
return
properties_mnu_cnt := tmp
 
if (mnu = "-") or (mnu = "--")
goto Properties_OnNavClick
 
Properties_OnShowWindow(true, 0)
return
 
;-----------------------------------------------------------------------------------
 
Properties_Close()
{
global
 
Gui, Destroy
properties_visible := false
}
 
 
GuiClose:
Properties_Close()
return
; ######################################################################
; ########## END  pasting of "GUI_Properties.ahk"
; ######################################################################
; ######################################################################
; ######################################################################
; ## ExpandIncludes: 1. occurance of "GUI_Setup.ahk"
; -- #include GUI_Setup.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "GUI_Setup.ahk"
; ######################################################################
Setup_Create()
{
global
 
Gui, 2:-sysmenu
Gui, 2:Add, Text, x75 y10 w156 h17, Total Commander Exe && Ini
Gui, 2:Add, Edit, vSetup_eTcExe x23 y32 w260 h20
Gui, 2:Add, Edit, vSetup_eTcIni x23 y62 w260 h20
 
Gui, 2:Font, bold
Gui, 2:Add, Text, gSetup_OnBrowseClick vSetup_bExe x286 y35 w13 h14, >>
Gui, 2:Add, Text, gSetup_OnBrowseClick x286 y65 w13 h14, >>
Gui, 2:Font, norm
 
Gui, 2:Add, Text, x133 y94 w41 h17, Hotkey
Gui, 2:Add, Hotkey, vSetup_Hotkey x103 y112 w100 h30, !w
 
 
Gui, 2:Add, GroupBox, x16 y172 w270 h70, Display menu at
Gui, 2:Add, Radio, vSetup_rTcPos x26 y192 w60 h40, mouse position
Gui, 2:Add, Radio, Checked x106 y192 w70 h40, cursor position
Gui, 2:Add, Radio, x176 y192 w100 h40, center of active window
 
Gui, 2:Add, Button, gSetup_OnSaveClick x106 y262 w90 h25, &Save
Gui, 2:Add, StatusBar
 
setup_visible := true
Gui, 2:Show, x487 y302 h320 w315, Setup
}
 
Setup_OnBrowseClick:
if (A_GuiControl = "Setup_bExe")
FileSelectFile, tmp, 3, , Select TotalCmd.exe, TotalCmd.exe
else
FileSelectFile, tmp, 3, , Select wincmd.ini, wincmd.ini
 
if Errorlevel = 1
return
 
if (A_GuiControl = "Setup_bExe")
GuiControl, Text, Setup_eTcExe, %tmp%
else
GuiControl, Text, Setup_eTcIni, %tmp%
return
 
;-----------------------------------------------------------------------------------
 
Setup_Close()
{
global setup_visible
Gui, 2:Destroy
setup_visible := false
}
 
;-----------------------------------------------------------------------------------
 
Setup_OnSaveClick:
msg =
Gui 2:Submit, NoHide
 
tcExe := Setup_eTcExe
tcIni := Setup_eTcIni
 
if ( !FileExist(tcExe) )
msg = EXE doesn't exist.`n
 
if ( !FileExist(tcIni) )
msg = %msg% INI doesn't exist.`n
 
if ( Setup_HotKey = "")
msg = %msg% You must choose a hot key.`n
 
if (msg != "")
{
MsgBox %msg%
return
}
 
;remove previous hotkey (it will not exist on first run, so use errorlevel to avoid error)
Hotkey, %tcKey%,,UseErrorLevel Off
 
tcKey := Setup_HotKey
Hotkey %tcKey%, MenuHotKey, On
 
;everything is valid, save the data and quit the window
tcPos := Setup_rTcPos
SaveConfigData()
Setup_Close()
 
return
 
;-----------------------------------------------------------------------------------
 
Setup_OnKeyDown(wparam, lparam)
{
if (wparam = "27")
if ( ! GetConfigData() )
{
MsgBox No configuration. Program will exit.
ExitApp
}
else
Setup_Close()
 
}
 
;-----------------------------------------------------------------------------------
 
Setup_OnShowWindow(wparam, lparam)
{
global
if (! wparam)
return
 
; change existing configuration
if ( GetConfigData() )
{
GuiControl, Text, Setup_eTcExe, %tcExe%
GuiControl, Text, Setup_eTcIni, %tcIni%
GuiControl, Text, Setup_HotKey, %tcKey%
GuiControl, ,% "Button" . (tcPos+1), 1
 
 
SB_SetText("Change existing configuration")
return
}
 
;running for the first time
; no config -> try to find commander first
if (! FindCommander() )
{
SB_SetText("First run: Total Commander NOT found!")
return
}
 
; commander found, initialise controls with found data
GuiControl, Text, Setup_eTcExe, %tcExe%
GuiControl, Text, Setup_eTcIni, %tcIni%
SB_SetText("First run: Total Commander found !")
}
 
;-----------------------------------------------------------------------------------
 
2GuiClose:
{
Setup_Close()
}
; ######################################################################
; ########## END  pasting of "GUI_Setup.ahk"
; ######################################################################
; ######################################################################
 
; ######################################################################
; ## ExpandIncludes: 1. occurance of "msg_dispatch.ahk"
; -- #include msg_dispatch.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "msg_dispatch.ahk"
; ######################################################################
MessageMonitor(wparam, lparam, msg, hwnd)
{
h := DllCall("GetAncestor", "uint", hwnd, "uint", 2)
WinGetTitle title, ahk_id %h%
 
 
if title = Properties
Properties_Monitor(wparam, lparam, msg)
 
if (title = "Setup") || (title = "")
Setup_Monitor(wparam, lparam, msg)
 
}
 
;-----------------------------------------------------------------------------------
 
Properties_Monitor(wparam, lparam, msg)
{
if (msg = 0x100)
Properties_OnKeyDown(wparam, lparam)
 
if (msg = 0x18)
Properties_OnShowWindow(wparam, lparam)
}
 
;-----------------------------------------------------------------------------------
 
Setup_Monitor(wparam, lparam, msg)
{
 
if (msg = 0x100)
Setup_OnKeyDown(wparam, lparam)
 
if (msg = 0x18)
Setup_OnShowWindow(wparam, lparam)
}
; ######################################################################
; ########## END  pasting of "msg_dispatch.ahk"
; ######################################################################
; ######################################################################
; ######################################################################
; ## ExpandIncludes: 1. occurance of "menuIcons.ahk"
; -- #include menuIcons.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "menuIcons.ahk"
; ######################################################################
/* 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
}
; ######################################################################
; ########## END  pasting of "menuIcons.ahk"
; ######################################################################
; ######################################################################
; ######################################################################
; ## ExpandIncludes: 1. occurance of "structs.ahk"
; -- #include structs.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "structs.ahk"
; ######################################################################
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)
}
; ######################################################################
; ########## END  pasting of "structs.ahk"
; ######################################################################
; ######################################################################
; ######################################################################
; ## ExpandIncludes: 1. occurance of "dialogs.ahk"
; -- #include dialogs.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "dialogs.ahk"
; ######################################################################
DialogWindowActive()
{
WinGet, active_hwnd, ID, A
{
if ( IsDialog( active_hwnd ) )
return 1
else
return 0
}
 
return 0
}
 
;------------------------------------------------------------------------------------------------
 
IsDialog(dlg)
{
global d_input
 
 
toolbar := FindWindowExID(dlg, "ToolbarWindow32", "0x440")  ;windows XP
if (toolbar = "0")
toolbar := FindWindowExID(dlg, "ToolbarWindow32", "0x001")  ;windows 2k
 
combo  := FindWindowExID(dlg, "ComboBoxEx32", "0x47C") ; comboboxex field
button := FindWindowExID(dlg, "Button", "0x001")  ; second button
 
edit := FindWindowExID(dlg, "Edit", "0x480")  ; edit field
 
d_input := combo + edit
if (toolbar && (combo || edit) && button)
return 1
 
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
}
}
 
;--------------------------------------------------------------------------
 
SetDialogPath(path)
{
global d_input
 
ControlGetText d_text, ,ahk_id %d_input%
Sleep 100
 
ControlFocus, , ahk_id %d_input%
Sleep 100
 
SendRaw %path%
Send {ENTER}
 
Sleep 300
ControlSetText, ,%d_text%, ahk_id %d_input%
}
; ######################################################################
; ########## END  pasting of "dialogs.ahk"
; ######################################################################
; ######################################################################
; ######################################################################
; ## ExpandIncludes: 1. occurance of "pseudo.ahk"
; -- #include pseudo.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "pseudo.ahk"
; ######################################################################
ConvertPseudoPath(ppath)
{
StringGetPos idx, ppath, `%\
if (idx != -1)
{
StringMid part1, ppath, 3, idx-2
StringMid part2, ppath, % idx + 2, 256
}
else
StringMid part1, ppath, 3, % StrLen(ppath) - 3
 
return % GetCommonPath(part1) . part2
}
 
;-----------------------------------------------------------------------------------
 
GetCommonPath( csidl )
{
CSIDL_APPDATA=0x001A ; Application Data, new for NT4
CSIDL_COMMON_APPDATA=0x0023 ; All Users\Application Data
CSIDL_COMMON_DOCUMENTS=0x002e ; All Users\Documents
CSIDL_DESKTOP=0x0010 ; C:\Documents and Settings\username\Desktop
CSIDL_FONTS=0x0014 ; C:\Windows\Fonts
CSIDL_LOCAL_APPDATA=0x001C ; non roaming, user\Local Settings\Application Data
CSIDL_MYMUSIC=0x000d ; "My Music" folder
CSIDL_MYPICTURES=0x0027 ; My Pictures, new for Win2K
CSIDL_PERSONAL=0x0005 ; My Documents
CSIDL_PROGRAM_FILES_COMMON=0x002b ; C:\Program Files\Common
CSIDL_PROGRAM_FILES=0x0026 ; C:\Program Files
CSIDL_PROGRAMS=0x0002 ; C:\Documents and Settings\username\Start Menu\Programs
CSIDL_RESOURCES=0x0038 ; %windir%\Resources\, For theme and other windows resources.
CSIDL_STARTMENU=0x000b ; C:\Documents and Settings\username\Start Menu
CSIDL_STARTUP=0x0007 ; C:\Documents and Settings\username\Start Menu\Programs\Startup.
CSIDL_SYSTEM=0x0025 ; GetSystemDirectory()
CSIDL_WINDOWS=0x0024 ; GetWindowsDirectory()
;================================================================================================
 
val = % CSIDL_%csidl%
VarSetCapacity(fpath, 256)
DllCall( "shell32\SHGetFolderPathA", "uint", 0, "int", val, "uint", 0, "int", 0, "str", fpath)
return %fpath%
}
 
;-----------------------------------------------------------------------------------
 
IsPseudoVar( ppath )
{
StringGetPos idx, ppath, `%$
if (idx != -1)
return true
else
return false
}
; ######################################################################
; ########## END  pasting of "pseudo.ahk"
; ######################################################################
; ######################################################################
; ######################################################################
; ## ExpandIncludes: 1. occurance of "config.ahk"
; -- #include config.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "config.ahk"
; ######################################################################
SetTrayMenu()
{
Menu, tray, icon, shell32.dll, 44
Menu, tray, NoStandard
Menu, tray, tip, TC Fav Menu
 
Menu, tray, add, Setup, tray_Handler
Menu, tray, add, Delete Config, tray_Handler
Menu, tray, add, Disable, tray_Handler
Menu, tray, add
Menu, tray, add, About, tray_Handler
Menu, tray, add, Reload, tray_Handler
Menu, tray, add, Exit, tray_Handler
 
}
 
tray_Handler:
if ( A_ThisMenuItem = "Disable" )
{
HotKey, %tcKey%,,Off
Menu, tray, Rename, Disable, Enable
}
 
if ( A_ThisMenuItem = "Enable" )
{
HotKey, %tcKey%,,On
Menu, tray, Rename, Enable, Disable
}
 
 
if ( A_ThisMenuItem = "Setup" ) && (!setup_visible)
Setup_Create()
 
if ( A_ThisMenuItem = "Reload" )
Reload
 
if ( A_ThisMenuItem = "Delete Config" )
{
DeleteConfigData()
Reload
}
 
if ( A_ThisMenuItem = "About" )
{
msg :=
msg := msg . g_title . "`n`n`n"
msg := msg . "Created by:`t`t Miodrag Milic`n"
 
msg := msg . "e-mail:`t`t miodrag.milic@gmail.com`n`n`n"
 
msg := msg . "www.r-moth.com`n"
msg := msg . "Jun 2006`n"
MsgBox 48, About, %msg%
}
 
if ( A_ThisMenuItem = "Exit" )
ExitApp
return
 
FindCommander()
{
global tcIni, tcExe
 
RegRead tcExe, HKEY_CURRENT_USER, Software\Ghisler\Total Commander, InstallDir
RegRead tcIni, HKEY_CURRENT_USER, Software\Ghisler\Total Commander, IniFileName
 
tcExe = %tcExe%\TotalCmd.exe
 
if (FileExist(tcExe)) && (FileExist(tcIni))
return true
 
 
EnvGet COMMANDER_PATH, COMMANDER_PATH
if (COMMANDER_PATH != "")
{
tcExe = %COMMANDER_PATH%\TotalCmd.exe
tcIni = %COMMANDER_PATH%\wincmd.ini
 
if (FileExist(tcExe)) && (FileExist(tcIni))
return true
}
 
return false
}
 
;-----------------------------------------------------------------------------------
 
GetConfigData()
{
global
 
RegRead tcExe, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcExe
RegRead tcIni, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcIni
RegRead tcKey, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcKey
RegRead tcPos, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcPos
 
if (tcExe = "") || (tcIni = "") || (tcKey = "")
return false
 
if (tcPos = "")
tcPos := 3
 
Hotkey %tcKey%, MenuHotKey,On
return true
}
 
;-----------------------------------------------------------------------------------
 
SaveConfigData()
{
global
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcExe, %tcExe%
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcIni, %tcIni%
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcKey, %tcKey%
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcPos, %tcPos%
}
 
;-----------------------------------------------------------------------------------
 
DeleteConfigData()
{
RegDelete HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcExe
RegDelete HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcIni
RegDelete HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcKey
RegDelete HKEY_CURRENT_USER, Software\Miodrag Milic\TcFavMenu, tcPos
}
 
CheckConfigData()
{
global
 
if (! FileExist(tcExe) )
{
MsgBox Total Commander not found.`nInvalid config deleted.
reset := true
}
 
if (! FileExist(tcIni) )
{
MsgBox INI not found.`nInvalid config deleted.
reset := true
}
 
 
 
if (reset)
{
DeleteConfigData()
Reload
}
}
; ######################################################################
; ########## END  pasting of "config.ahk"
; ######################################################################
; ######################################################################
; ######################################################################
; ## ExpandIncludes: 1. occurance of "tc_functions.ahk"
; -- #include tc_functions.ahk --
; ######################################################################
; ######################################################################
; ########## BEGIN pasting of "tc_functions.ahk"
; ######################################################################
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}
}
 
;--------------------------------------------------------------------------
 
GetTCPanels( ByRef pLeft, ByRef pRight)
{
global
local saveClip, tc_left
 
; do things with the clipboard
saveClip := clipboardAll
SendTCCommand(cm_CopySrcPathToClip)
pLeft := clipboard
SendTCCommand(cm_CopyTrgPathToClip)
pRight := clipboard
 
SendTCCommand(cm_FocusLeft)
SendTCCommand(cm_CopySrcPathToClip)
tc_left := clipboard
clipboard := saveClip
SaveClip =
 
; determine what is left what is right panel
if (pLeft != tc_left)
{
SendTCCommand(cm_FocusRight)
pRight := pLeft
pLeft := tc_left
}
}
 
;---------------------------------------------------------------------------
 
AddTCPanels( ByRef pLeft, ByRef pRight)
{
cnt := 0
b_same := % pLeft = pRight
 
; add left panel dir to the menu
StringGetPos idx, pLeft, \, R
if (idx != -1) and (idx != 2)
StringMid pLeft, pLeft, idx+2, 256
Menu sub1, add,   &1  %pLeft% , FullMenuHandler
cnt += 1


; If they are not the same, add right panel
* [[AutoHotkey: TC Fav Menu: Screenshot|More screenshots]]
if (! b_same)
{
StringGetPos idx, pRight, \, R
if (idx != -1) and (idx != 2)
StringMid pRight, pRight, idx+2, 256
Menu sub1, add,   &2  %pRight% , FullMenuHandler
cnt += 1
}


; add separator
* [http://ghisler.ch/board/viewtopic.php?p=88536#88536 '''Forum link to the latest version''']
Menu sub1, add


return cnt + 1
}


;---------------------------------------------------------------------------
----


SendTCCommand(cmd, wait=1)
Back to [[AutoHotkey]]
{
[[category:AutoHotkey|TC Fav Menu]]
if (wait)
SendMessage 1075, cmd, 0, , ahk_class TTOTAL_CMD
else
PostMessage 1075, cmd, 0, , ahk_class TTOTAL_CMD
}
; ######################################################################
; ########## END  pasting of "tc_functions.ahk"
; ######################################################################
; ######################################################################
</pre>

Revision as of 19:19, 6 June 2008

Screenshot of FavMenu editor

TC Fav Menu

	for Windows XP & 2K

This is a Total Commander utility.
It will make TC favorites available in the system.
It will also make TC Favorites to become Open/Save dialog enhancer (for standard dialogs)




Back to AutoHotkey