Sign in to follow this  
Followers 0
MilesAhead

Launch FreeCommander with Layout

2 posts in this topic

I like to use FreeCommander file manager. As yet afaik there's no command line option to launch it with the desired Layout. (A Layout is a configuration of folder tabs saved as a name, which when clicked will open all tabs as layed out in the Layout.)

AutoIt3 being perfect for such a job I made a trivial script to open FreeCommander if not already running and open the desired Layout. (You can of course enhance it to read params from the command line for which layout to open or whatever.)

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.12.1
    Author:      MilesAhead
    
    Script Function: launch FreeCommander then open particular Layout.
    
    Note that Send("!2") sends Alt+2 to the active window.  Change the
    Alt key combination to open the Layout you want.
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
Opt("WinTitleMatchMode", 2)
;use path to FreeCommander.exe on your machine
$freeCommander = "C:\Program Files\FreeCommander\FreeCommander.exe"
If Not ProcessExists("FreeCommander.exe") Then
    ShellExecute($freeCommander)
Else
    WinActivate("FreeCommander")
EndIf
WinWaitActive("FreeCommander")
Send("!2")
Exit

Share this post


Link to post
Share on other sites



I dressed it up a bit. Assuming FreeCommander.exe is under C:\Program Files is not good since there

may actually be a copy there on a multiboot machine, but it may not be the one you want to use.

I changed it to bring up a file open dialog and let the user choose the FreeCommander.exe, saving the result in an .ini file. Also I changed the sent key combo to "!1" since that should be the default Layout

if there is one. The next enhancement would be to use the .ini file and/or command line to select a different layout.

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.12.1
    Author:      MilesAhead
    
    Script Function: launch FreeCommander then open particular Layout.
    
    Note that Send("!1") sends Alt+1 to the active window.  Change the
    Alt key combination to open the Layout you want.
    
#ce ----------------------------------------------------------------------------

; match any substring
Opt("WinTitleMatchMode", 2)

$freeCommander = ""
If Not _Init_FreeCommander($freeCommander) Then
    Exit
EndIf

If Not ProcessExists("FreeCommander.exe") Then
    ShellExecute($freeCommander)
Else
    WinActivate("FreeCommander")
EndIf
WinWaitActive("FreeCommander")
Send("!1")
Exit

Func _Init_FreeCommander(ByRef $fcExeFile)
    $iFile = @ScriptDir & "\FreeCommanderLayout.ini"
    $fname = IniRead($iFile, "FCFileName", "FreeCommander", "NotFound")
    If $fname <> "NotFound" Then
        $fcExeFile = $fname
        Return True
    EndIf
    $fname = FileOpenDialog("Select FreeCommander exe File", @ProgramFilesDir, "Executables (*.exe)", 1 + 2, "FreeCommander.exe")
    If @error Then
        Return False
    EndIf
    IniWrite($iFile, "FCFileName", "FreeCommander", $fname)
    $fcExeFile = $fname
    Return True
EndFunc  ;==>_Init_FreeCommander

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0