Stable release 0.2.1 / 01.12.2012
Status Discontinued / not supported
Written in AutoHotkey script
Runtime environment AutoHotkey
Available in English
Type Application Launcher
License GNU General Public License
Distribution Packaged AutoHotkey script source
Download from (AHK, 26 KB)


cubit is an application launcher or link lister, which is configured by using LNK files. It lists the content of the LNK files in a given directory with a prepending alphanumeric character, which is used as a hotkey to run or open the associated application or file.

Source view

  cubit -- link lister
  Copyright (c) 2011-2012 joten

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see <>.

  @version (01.012.2012)

  quick help

  cubit is a link lister or launcher.
  It uses the following data structure:
    + root-directory
      + sub-directory 1
        link 1-1
        link 1-2
      + sub-directory 2
        link 2-1

  The root-directory should contain sub-directories, which are used
  for grouping links. The sub-directories then should contain links to
  applications or files, which can be run (opened); they can also
  contain more directories for nested grouping.
  The root-directory can be given as an argument when starting cubit
  or set in configuration section in this script; if not given an
  absolute path, the script will asume, that the path is relative to
  the script directory. If the root-directory is not given as an
  argument, the script directory itself is asumed to contain the
  link-directories (groups).

  When started cubit reads in the data-structure and saves the
  properties of the links grouped by sub-directory; the groups and
  links are indexed in the order they are listed.
  At the bottom of this script file hotkeys should be defined for
  showing and selecting a link from a group. The index of the group is
  given by argument to the function "Gui_show"; this function when
  called opens a new window and lists all links from the specified
  (group-)directory; you can then select an entry for which the
  associated application is run.
  The window shows the following information in columns:
    + Alphanumeric sign (for selection purposes)
    + Name (The filename relative to the given link directory)
    + Target
    + Arguments
    + Working Directory
    + Run State (minimized or maximized)

  The first two columns are always shown with a width adjusted to fit
  their content (AutoHdr). For the other four colums you may set the
  width with the configuration variables at the beginning of the script
  ("Config_columnWidth<header name>") to either "AutoHdr", a fixed size
  in pixel or 0, if the column should be hidden. You may also set the
  window width by means of the configuration variable

  You may select an entry either by mouse or by keyboard; selecting it by
  keyboard can be done with the "Up" and "Down" arrow keys, or by
  pressing the key given by the alphanumeric sign in the first column.
  If you set the configuration variable "Config_runOnSelection" to True
  the associated application is immediatly run and cubit closes the
  window. If you set "Config_runOnSelection" to False you also need to
  press the "Enter" key to run the application. If you did not select
  any entry and hit "Enter", all listed applications are run. If you
  do not want to run any application press the "Escape" key and cubit
  will only close the window.

  You may also set the variable "Config_removeSortingFromLinkName" to
  True, if you put numbers in front of the link names to sort them in a
  non-alphabetic order and do not want them to appear in the name shown
  in the second column of the script window.
  You may set the variable "Config_useLinkNameInitial" to True, if you
  want the script to not choose the next number or letter in line for the
  first column of an entry, but the first letter of the link name, if
  available (not already used for a prior entry).

NAME  := "cubit"
VERSION := "0.2.1"

;; configuration
Config_columnWidthArguments      := "AutoHdr"
Config_columnWidthRunState       := 0
Config_columnWidthTarget         := 0
Config_columnWidthWorkingDir     := "AutoHdr"
Config_linkDir                   := "lnk"
Config_listViewWidth             := 700
Config_runOnSelection            := True     ;; else run on Enter
Config_removeSortingFromLinkName := True
Config_useLinkNameInitial        := True     ;; else each list entry gets a sequential initial for selection purposes

;; script settings
SetBatchLines, -1
SetTitleMatchMode, 3
SetTitleMatchMode, fast
#SingleInstance force

;; pseudo main function
  If 0 > 0
    Config_linkDir = %1%
    If Not InStr(Config_linkDir, ":")
      Config_linkDir := A_WorkingDir "\" Config_linkDir

  Menu, Tray, Tip, %NAME% %VERSION%
  IfExist %A_ScriptDir%\logo.ico
    Menu, Tray, Icon, %A_ScriptDir%\logo.ico
  Menu, Tray, NoStandard
  Menu, Tray, Add, Reload, Main_reload
  Menu, Tray, Add, Exit, Main_quit
Return         ;; end of the auto-execute section

;; function & label definitions
  Gui, Destroy

  Gui, Destroy

  Config_listViewWidth := A_GuiWidth - 0
  Gui_listViewHeight := A_GuiHeight - 12
  GuiControl, Move, Gui_listView, X0 Y0 W%Config_listViewWidth% H%Gui_listViewHeight%

  GuiControlGet, Gui_focusedControl, FocusV
  If (Gui_focusedControl = "Gui_listView") And (A_GuiEvent = "DoubleClick" Or (A_GuiEvent = "I" And Config_runOnSelection))

  GuiControlGet, Gui_focusedControl, FocusV
  If (Gui_focusedControl = "Gui_listView")

  If LV_GetNext(0, "Focused")
    LV_GetText(selectedTarget, LV_GetNext(0, "Focused"), 3)
    LV_GetText(selectedDir, LV_GetNext(0, "Focused"), 5)
    LV_GetText(selectedArgs, LV_GetNext(0, "Focused"), 4)
    LV_GetText(selectedRunState, LV_GetNext(0, "Focused"), 6)
    If selectedArgs
      selectedTarget .= " " selectedArgs
    Run, %selectedTarget%, %selectedDir%, %selectedRunState%
    Loop, % LV_GetCount()
      LV_GetText(selectedTarget, A_Index, 3)
      LV_GetText(selectedDir, A_Index, 5)
      LV_GetText(selectedArgs, A_Index, 4)
      LV_GetText(selectedRunState, A_Index, 6)
      If selectedArgs
        selectedTarget .= " " selectedArgs
      Run, %selectedTarget%, %selectedDir%, %selectedRunState%
  Gui, Destroy

  Local rows

  If (i <= Config_groupCount)
    Suspend, On

    Gui, %i%: Default
    ; IfWinExist, %NAME%
    Gui, Destroy
    Gui, +LastFound +0xCF0000
    Gui, +LabelGui

    rows := Gui_rows_#%i%
    Gui, Add, ListView, AltSubmit Count36 -Multi R%rows% W%Config_listViewWidth% gGui_listViewEvent vGui_listView, #|Name|Target|Arguments|Working Directory|Run State
    Gui, Add, Button, Hidden Default gGui_listViewEnter,
    GuiControl, -Redraw, Gui_listView

    Loop, %rows%
      LV_Add("", Gui_hotstring_#%i%_#%A_Index%, Gui_linkName_#%i%_#%A_Index%, Gui_linkTarget_#%i%_#%A_Index%, Gui_linkArgs_#%i%_#%A_Index%, Gui_linkDir_#%i%_#%A_Index%, Gui_linkRunState_#%i%_#%A_Index%)

    LV_ModifyCol(1, "AutoHdr")
    LV_ModifyCol(2, "AutoHdr")
    LV_ModifyCol(3, Config_columnWidthTarget)
    LV_ModifyCol(4, Config_columnWidthArguments)
    LV_ModifyCol(5, Config_columnWidthWorkingDir)
    LV_ModifyCol(6, Config_columnWidthRunState)
    GuiControl, +Redraw, Gui_listView
    Gui, Show, AutoSize, % NAME ": " Gui_groupName_#%i%

    Suspend, Off


  Local hotstring, hotstrings, i, j, linkArgs, linkDir, linkName, linkRunState, linkTarget, searchDir

  i := 0
  Loop, %Config_linkDir%\*, 2, 0
    i += 1
    Gui_groupName_#%i% := A_LoopFileName
    Gui_rows_#%i% := 0
    searchDir := A_LoopFileLongPath

    ;; hotstrings := "1;2;3;4;5;6;7;8;9;0;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;"
    hotstrings := "1;2;3;4;5;6;7;8;9;0;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;Ä;Ö;Ü;ß;+;#;-;.;,;"
    j := 0
    Loop, %searchDir%\*.lnk, 0, 1
      j += 1
      FileGetShortcut, %A_LoopFileLongPath%, linkTarget, linkDir, linkArgs, , , , linkRunState

      linkName := A_LoopFileLongPath
      StringReplace, linkName, linkName, %searchDir%\,
      StringTrimRight, linkName, linkName, 4

      StringReplace, linkTarget, linkTarget, `%WinDir`%, %A_WinDir%
      StringReplace, linkDir, linkDir, `%WinDir`%, %A_WinDir%

      If linkRunState = 7
        linkRunState := "Min"
      Else If linkRunState = 3
        linkRunState := "Max"
        linkRunState := ""

      If Config_useLinkNameInitial
        hotstring := SubStr(linkName, InStr(linkName, "\", False, 0) + 1, 1)
        StringUpper, hotstring, hotstring
      If Not InStr(hotstrings, hotstring ";") Or (hotstring = "")
        StringLeft, hotstring, hotstrings, 1
      StringReplace, hotstrings, hotstrings, %hotstring%`;,

      If Config_removeSortingFromLinkName And RegExMatch(linkName, "^[0-9]+ ")
        linkName := RegExReplace(linkName, "^[0-9]+ ")

      Gui_hotstring_#%i%_#%j%    := hotstring
      Gui_linkName_#%i%_#%j%     := linkName
      Gui_linkArgs_#%i%_#%j%     := linkArgs
      Gui_linkDir_#%i%_#%j%      := linkDir
      Gui_linkRunState_#%i%_#%j% := linkRunState
      Gui_linkTarget_#%i%_#%j%   := linkTarget
    Gui_rows_#%i% := j
  Config_groupCount := i


;; hotkey definitions