Jump to content

LaunchDock - updated!


maqleod
 Share

Recommended Posts

Well, it's been 3.5 years since I wrote this and I'm just now getting back to it with some major improvements. It still needs some work and some refining in certain areas, but it works.

LaunchDock is a tabbed application launcher.

Features:

Add as many tabs as you'd like

drag and drop .exe files on buttons to add them

change background color

change transparency

start on boot option

always on top option

minimizes to tray

To Do:

Fix noted bugs (below)

add autohide when docked to screen edge

add ability to handle any type of file, not just executables

add ability to change the order of tabs

add ability to set custom hotkeys for buttons

eventually update to sqlite embedded functionality for better speed

create help file

Known Bugs:

If minimized to tray when closed does not always appear when opened again

New tabs retain other tabs icons when first shown (icons do not remain if tab loses focus and regains it)

Delete Tab does not realign buttons correctly on tabs after the deleted tab, loads correctly again when restarted though

FileChangeDir(@ScriptDir)
#include <Constants.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#Include <GuiButton.au3>
#include <GUITab.au3>
#NoTrayIcon

Opt("GUIOnEventMode", 1)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

Dim $tabsheet[100], $button[100][10], $tabdata[100]
$name = "LaunchDock"
$version = "1.0"
$author = "Jared Epstein"
$newcolor = 1

$background = _GetBackground()
$transdata = _GetTransparency()
$winpos = _GuiGetLastPos($name, "", 2)

$parent = GUICreate($name, 460, 100, $winpos[0], $winpos[1], -1, $WS_EX_ACCEPTFILES)
GUISetBkColor($background)
WinSetTrans($name, "", $transdata)
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_MinimizeToTray")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetOnEvent($GUI_EVENT_DROPPED, "_SetButton")

$restore = TrayCreateItem("Restore")
TrayItemSetState(-1, $TRAY_DEFAULT)
$exittray = TrayCreateItem("Exit")

$contextmenu = GUICtrlCreateContextMenu()
$fileopt = GUICtrlCreateMenu("&File")
$exititem = GUICtrlCreateMenuItem("Exit", $fileopt)
$configopt = GUICtrlCreateMenu("Configure")
$toggleitem = GUICtrlCreateMenuItem("Start On Boot", $configopt)
$ontopitem = GUICtrlCreateMenuItem("Always On Top", $configopt)
$bkcoloritem = GUICtrlCreateMenuItem("Background Color", $configopt)
$transitem = GUICtrlCreateMenuItem("Transparency", $configopt)
$tabopt = GUICtrlCreateMenu("Tabs")
$addtabitem = GUICtrlCreateMenuItem("Add Tab", $tabopt)
$renametabitem = GUICtrlCreateMenuItem("Rename Tab", $tabopt)
$deltabitem = GUICtrlCreateMenuItem("Delete Tab", $tabopt)
$helpopt = GUICtrlCreateMenu("About")
$aboutitem = GUICtrlCreateMenuItem("About", $helpopt)
$helpitem = GUICtrlCreateMenuItem("Help", $helpopt)

$filemenu = GUICtrlCreateMenu("File", $contextmenu)
$exit = GUICtrlCreateMenuItem("Exit", $filemenu)
$configmenu = GUICtrlCreateMenu("Configure", $contextmenu)
$toggle = GUICtrlCreateMenuItem("Start On Boot", $configmenu)
$ontop = GUICtrlCreateMenuItem("Always On Top", $configmenu)
$bkcolor = GUICtrlCreateMenuItem("Background Color", $configmenu)
$trans = GUICtrlCreateMenuItem("Transparency", $configmenu)
$tabmenu = GUICtrlCreateMenu("Tabs", $contextmenu)
$addtab = GUICtrlCreateMenuItem("Add Tab", $tabmenu)
$renametab = GUICtrlCreateMenuItem("Rename Tab", $tabmenu)
$deltab = GUICtrlCreateMenuItem("Delete Tab", $tabmenu)
$aboutmenu = GUICtrlCreateMenu("About", $contextmenu)
$about = GUICtrlCreateMenuItem("About", $aboutmenu)
$help = GUICtrlCreateMenuItem("Help", $aboutmenu)

_CheckOnTop()
_CheckOnBoot()
GUICtrlSetOnEvent($addtab, "_AddTab")
GUICtrlSetOnEvent($addtabitem, "_AddTab")
GUICtrlSetOnEvent($renametab, "_RenameTab")
GUICtrlSetOnEvent($renametabitem, "_RenameTab")
GUICtrlSetOnEvent($deltab, "_DeleteTab")
GUICtrlSetOnEvent($deltabitem, "_DeleteTab")
GUICtrlSetOnEvent($bkcolor, "_Background")
GUICtrlSetOnEvent($bkcoloritem, "_Background")
GUICtrlSetOnEvent($trans, "_Transparency")
GUICtrlSetOnEvent($transitem, "_Transparency")
GUICtrlSetOnEvent($about, "_AboutInfo")
GUICtrlSetOnEvent($aboutitem, "_AboutInfo")
GUICtrlSetOnEvent($ontop, "_SetOnTop")
GUICtrlSetOnEvent($ontopitem, "_SetOnTop")
GUICtrlSetOnEvent($toggle, "_SetOnBoot")
GUICtrlSetOnEvent($toggleitem, "_SetOnBoot")
TrayItemSetOnEvent($restore, "_RestoreFromTray")
GUICtrlSetOnEvent($exit, "_Exit")
GUICtrlSetOnEvent($exititem, "_Exit")
TrayItemSetOnEvent($exittray, "_Exit")

$tab = GUICtrlCreateTab(8, 10, 445, 65, $TCS_FLATBUTTONS, $TCS_BUTTONS)
$tabhandle = GUICtrlGetHandle($tab)
_EnumerateTabs()

GUISetOnEvent($GUI_EVENT_DROPPED, "_SetButton")

GUISetState(@SW_SHOW)
While 1
    Sleep(100)  ; Idle around
WEnd

Func _Exit()
    _GuiSetLastPos($name, "", 2)
    Exit
EndFunc   ;==>_Exit

Func _EnumerateTabs()
    $read = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select title from tabs order by position;"')
    $tabs = StringSplit($read[1], Chr(9))
    If @error <> 1 Then
        For $i = 1 To $tabs[0]
            $x = 0
            $tabsheet[$i] = GUICtrlCreateTabItem($tabs[$i])
            $tabdata = StringSplit($tabs[$i], Chr(124))
            $buttons = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select name,path from buttons where tab = ' & "'" & $tabdata[1] & "' order by id;")
            $buttonsplit = StringSplit($buttons[1], Chr(9))
            For $j = 1 To $buttonsplit[0]
                $buttoninfo = StringSplit($buttonsplit[$j], Chr(124))
                $button[$i][$j] = GUICtrlCreateButton($j, $x + 16, 36, 32, 32, $BS_ICON)
                GUICtrlSetImage($button[$i][$j], $buttoninfo[2], 1)
                GUICtrlSetTip($button[$i][$j], $buttoninfo[1])
                GUICtrlSetState($button[$i][$j], $GUI_DROPACCEPTED)
                GUICtrlSetOnEvent($button[$i][$j], "_Launch")
                $x = $x + 49
            Next
        Next
    ElseIf @error = 1 And $tabs[0] = 1 Then
        If $tabs[1] <> "" Then
            $x = 0
            $tabsheet[1] = GUICtrlCreateTabItem($tabs[1])
            $tabdata = StringSplit($tabs[1], Chr(124))
            $buttons = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select name,path from buttons where tab = ' & "'" & $tabdata[1] & "' order by id;")
            $buttonsplit = StringSplit($buttons[1], Chr(9))
            For $j = 1 To $buttonsplit[0]
                $buttoninfo = StringSplit($buttonsplit[$j], Chr(124))
                $button[1][$j] = GUICtrlCreateButton($j, $x + 16, 36, 32, 32, $BS_ICON);
                GUICtrlSetImage($button[1][$j], $buttoninfo[2], 1)
                GUICtrlSetTip($button[1][$j], $buttoninfo[1])
                GUICtrlSetState($button[1][$j], $GUI_DROPACCEPTED)
                GUICtrlSetOnEvent($button[1][$j], "_Launch")
                $x = $x + 49
            Next
        EndIf
    EndIf
EndFunc   ;==>_EnumerateTabs

Func _SetButton()
    $execheck = StringRight(@GUI_DragFile, 3)
    If $execheck <> "exe" Then; Or $execheck <> "com" Or $execheck <> "pif" Or $execheck <> "bat" Then
        MsgBox(64, "Error", "LaunchDock only supports executable files at this time.")
    Else
        $nameinput = InputBox("Configure Button", "Enter Program Name")
        If @error <> 1 Then
            GUICtrlSetImage(@GUI_DropId, @GUI_DragFile, 1)
            GUICtrlSetTip(@GUI_DropId, $nameinput)
            $currenttab = _GUICtrlTab_GetCurFocus ($tab)
            $tabname = _GuiCtrlTab_GetItemText ($tabhandle, $currenttab)
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update buttons set name = ' & "'" & $nameinput & "', path = '" & @GUI_DragFile & "' where tab = " & "'" & $tabname & "' and id = " & _GUICtrlButton_GetText (@GUI_DropId) & ";")
        Else
        EndIf
    EndIf
EndFunc   ;==>_SetButton

Func _Launch() ;launch program
    $currentbutton = _GUICtrlButton_GetText (@GUI_CtrlId);@GUI_CtrlId, Get button number
    $currenttab = _GUICtrlTab_GetCurFocus ($tab) ;get current tab id
    $tabname = _GuiCtrlTab_GetItemText ($tabhandle, $currenttab) ;get current tab text
    $path = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select path from buttons where tab = ' & "'" & $tabname & "' and id == " & $currentbutton & ";") ;use number and tab to reference database to get path
    Run($path[1])
EndFunc   ;==>_Launch

Func _AddTab() ;look into bug with icons from another tab appearing on new tab at first
    $nameerror = 0
    $tabcount = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select count(*) from tabs";')
    $tabinput = InputBox("Add New Tab", "Enter New Tab Name", "", "", 200, 120)
    If @error <> 1 Then
        $tabnames = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select title from tabs";')
        $namesplit = StringSplit($tabnames[1], Chr(9))
        For $i = 1 To $namesplit[0]
            If $namesplit[$i] = $tabinput Then
                $nameerror = 1
            EndIf
        Next
        If $nameerror <> 1 Then
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into tabs values (' & "'" & $tabinput & "'," & ($tabcount[1] + 1) & ");")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (1,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (2,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (3,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (4,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (5,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (6,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (7,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (8,NULL,NULL,' & "'" & $tabinput & "');")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "insert into buttons values (9,NULL,NULL,' & "'" & $tabinput & "');")
            $x = 0
            $newtab = GUICtrlCreateTabItem($tabinput)
            _GUICtrlTab_SetCurFocus ($tabhandle, $tabcount[1])
            $buttons = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select name,path from buttons where tab = ' & "'" & $tabinput & "' order by id;")
            $buttonsplit = StringSplit($buttons[1], Chr(9))
            For $i = 1 To $buttonsplit[0]
                $buttoninfo = StringSplit($buttonsplit[$i], Chr(124))
                $button[($tabcount[1] + 1) ][$i] = GUICtrlCreateButton($i, $x + 16, 36, 32, 32, $BS_ICON);
                GUICtrlSetImage($button[($tabcount[1] + 1) ][$i], $buttoninfo[2], 1)
                GUICtrlSetTip($button[($tabcount[1] + 1) ][$i], $buttoninfo[1])
                GUICtrlSetState($button[($tabcount[1] + 1) ][$i], $GUI_DROPACCEPTED)
                GUICtrlSetOnEvent($button[($tabcount[1] + 1) ][$i], "_Launch")
                $x = $x + 49
            Next
            GUICtrlSetState($tab, $GUI_SHOW + $GUI_ENABLE)
        Else
            MsgBox(64, "Error", "You must choose a name that does not already belong to a tab.")
        EndIf
    EndIf
EndFunc   ;==>_AddTab

Func _RenameTab()
    $newtabname = InputBox("Rename Tab", "Enter New Name for Selected Tab:", "", "", 200, 120)
    If @error <> 1 Then
        $tabnames = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select title from tabs";')
        $namesplit = StringSplit($tabnames[1], Chr(9))
        For $i = 1 To $namesplit[0]
            If $namesplit[$i] = $newtabname Then
                $nameerror = 1
            EndIf
        Next
        If $nameerror <> 1 Then
            $currenttab = _GUICtrlTab_GetCurFocus ($tab)
            $tabname = _GuiCtrlTab_GetItemText ($tabhandle, $currenttab)
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update tabs set title = ' & "'" & $newtabname & "' where title = '" & $tabname & "';")
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update buttons set tab = ' & "'" & $newtabname & "' where tab = '" & $tabname & "';")
            _GuiCtrlTab_SetItemText ($tabhandle, $currenttab, $newtabname)
            GUICtrlSetState($tab, $GUI_SHOW)
        Else
            MsgBox(64, "Error", "You must choose a name that does not already belong to a tab.")
        EndIf
    EndIf
EndFunc   ;==>_RenameTab

Func _DeleteTab() ;requires that remaining tabs be reinventoried and reassigned positions
    $tabcount = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select count(*) from tabs";')
    If $tabcount[1] = 1 Then
        MsgBox(64, "Error", "You may not delete the last tab.")
    Else
        $deletecheck = MsgBox(1, "Delete Tab", "Delete Selected Tab?")
        If $deletecheck = 1 Then ;ok
            $currenttab = _GUICtrlTab_GetCurFocus ($tab) ;get current tab id
            $tabname = _GuiCtrlTab_GetItemText ($tabhandle, $currenttab) ;get current tab text
            ;For $i = 1 To 9
            ;   _GUICtrlButton_Destroy ($button[$currenttab + 1][$i]) ;delete tab buttons
            ;Next
            _GUICtrlTab_DeleteItem ($tabhandle, $currenttab) ;delete tab control
            $position = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select position from tabs where title = ' & "'" & $tabname & "';") ;find position of tab
            $remainder = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select title from tabs where position > ' & $position[1] & " order by position;") ;find tabs to deincriment
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "delete from tabs where title = ' & "'" & $tabname & "';") ;delete tab from database
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "delete from buttons where tab = ' & "'" & $tabname & "';") ;delete tab buttons from database
            $remaindersplit = StringSplit($remainder[1], Chr(9))
            If @error <> 1 Then
                For $i = 1 To $remaindersplit[0]
                    $buttons = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select name,path from buttons where tab = ' & "'" & $remaindersplit[$i] & "' order by id;") ;enumerate buttons on tabs
                    $buttonsplit = StringSplit($buttons[1], Chr(9)) ;separate tabs
                    MsgBox(64,"",$buttonsplit[1] & "," & $buttonsplit[2] & "," & $buttonsplit[3] & "," & $buttonsplit[4] & "," & $buttonsplit[5] & "," & $buttonsplit[6] & "," & $buttonsplit[7] & "," & $buttonsplit[8] & "," & $buttonsplit[9])
                    For $j = 1 To $buttonsplit[0] ;separate buttons
                        $buttoninfo = StringSplit($buttonsplit[$j], Chr(124)) ;separate info on each button
                        GUICtrlSetImage($button[$position[1] + $i][$j], $buttoninfo[2], 1) ;set appropriate image
                        GUICtrlSetTip($button[$position[1] + $i][$j], $buttoninfo[1]) ;set appropriate tip
                    Next
                    _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update tabs set position = ' & $position[1] - 1 + $i & " where title = '" & $remaindersplit[$i] & "';") ;deincriment tabs if many
                Next
            ElseIf @error = 1 Then
                If $remaindersplit[1] <> "" Then
                    _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update tabs set position = ' & $position[1] & " where title = '" & $remaindersplit[1] & "';") ;deincriment tab if just one
                ElseIf $remaindersplit[1] = "" Then
                EndIf
            EndIf
        ElseIf $deletecheck = 2 Then ;cancel
        EndIf
    EndIf
EndFunc   ;==>_DeleteTab

Func _Background()
    Opt("GUIOnEventMode", 0)
    $h_Child = GUICreate("Set Background", 220, 220, $winpos[0], $winpos[1], -1, -1, $parent)
    GUISetBkColor(_GetBackground(), $h_Child)
    WinSetTrans("Set Background", "", _GetTransparency())
    GUICtrlCreateLabel("Choose a Color:", 20, 50, 90, 70)
    $bkcolorchange = GUICtrlCreateCombo("Black", 105, 45, 75, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "Blue|Red|Green|Yellow|Purple|Gray|White|Orange", "Button 1")
    $colorok = GUICtrlCreateButton("OK", 50, 150, 75, 25)
    $colorcancel = GUICtrlCreateButton("Cancel", 130, 150, 75, 25)
    GUISetState()
    Do
        $msg1 = GUIGetMsg()
        If $msg1 = $colorok Then
            $newcolour = GUICtrlRead($bkcolorchange)
            If $newcolour = "Black" Then
                Assign("newcolor", "0x000000")
            ElseIf $newcolour = "Blue" Then
                Assign("newcolor", "0x0000FF")
            ElseIf $newcolour = "Red" Then
                Assign("newcolor", "0xFF0000")
            ElseIf $newcolour = "Green" Then
                Assign("newcolor", "0x009900")
            ElseIf $newcolour = "Yellow" Then
                Assign("newcolor", "0xFFFF00")
            ElseIf $newcolour = "Purple" Then
                Assign("newcolor", "0x660099")
            ElseIf $newcolour = "Gray" Then
                Assign("newcolor", "0x999999")
            ElseIf $newcolour = "White" Then
                Assign("newcolor", "0xFFFFFF")
            ElseIf $newcolour = "Orange" Then
                Assign("newcolor", "0xFF9900")
            EndIf
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update conf set background = ' & "'" & $newcolor & "';")
            GUISetBkColor($newcolor, $parent)
            ExitLoop
        EndIf
        If $msg1 = $colorcancel Then
            ExitLoop
        EndIf
    Until $msg1 = $GUI_EVENT_CLOSE
    GUIDelete($h_Child)
    Opt("GUIOnEventMode", 1)
EndFunc   ;==>_Background

Func _Transparency()
    Opt("GUIOnEventMode", 0)
    Local $h_Child
    $h_Child = GUICreate("Set Transparency", 280, 120, $winpos[0], $winpos[1], -1, -1, $parent)
    GUISetBkColor(_GetBackground(), $h_Child)
    WinSetTrans("Set Transparency", "", _GetTransparency())
    GUICtrlCreateLabel("1", 10, 25, 10, 25)
    $settrans = GUICtrlCreateSlider(35, 20, 200, 20)
    GUICtrlSetLimit($settrans, 255, 0)
    GUICtrlCreateLabel("255", 240, 25, 25, 25)
    GUICtrlSetData($settrans, $transdata)
    $transok = GUICtrlCreateButton("OK", 80, 60, 75, 25)
    $transcancel = GUICtrlCreateButton("Cancel", 180, 60, 75, 25)
    GUISetState()
    Do
        $msg1 = GUIGetMsg()
        If $msg1 = $transok Then
            _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update conf set transparency = ' & GUICtrlRead($settrans) & ";")
            WinSetTrans($name, "", _GetTransparency())
            ExitLoop
        EndIf
        If $msg1 = $transcancel Then
            ExitLoop
        EndIf
    Until $msg1 = $GUI_EVENT_CLOSE
    GUIDelete($h_Child)
    Opt("GUIOnEventMode", 1)
EndFunc   ;==>_Transparency

Func _AboutInfo()
    Opt("GUIOnEventMode", 0)
    Local $h_Child, $s_Font, $h_Aboutok, $s_Msg1
    $h_Child = GUICreate("About", 220, 220, -1, -1, -1, -1, $parent)
    $s_Font = "Ariel"
    GUISetBkColor(_GetBackground(), $h_Child)
    WinSetTrans("About", "", _GetTransparency())
    GUICtrlCreateLabel($name & " " & $version, 50, 30, 150, 30)
    GUICtrlSetFont(-1, 10, 400, $s_Font)
    GUICtrlCreateIcon("Icons\launchdock.ico", -1, 85, 60, 48, 48)
    GUICtrlCreateLabel("Written by " & $author, 55, 120, 150, 30)
    GUICtrlSetFont(-1, 10, 400, $s_Font)
    GUICtrlCreateLabel("Copyright " & @YEAR, 55, 140, 150, 30)
    GUICtrlSetFont(-1, 10, 400, $s_Font)
    $h_Aboutok = GUICtrlCreateButton("OK", 75, 175, 75, 25)
    GUISetState()
    Do
        $s_Msg1 = GUIGetMsg()
        If $s_Msg1 = $h_Aboutok Then
            ExitLoop
        EndIf
    Until $s_Msg1 = $GUI_EVENT_CLOSE
    GUIDelete($h_Child)
    Opt("GUIOnEventMode", 1)
EndFunc   ;==>_AboutInfo

Func _GuiGetLastPos($s_Title, $s_Text = "", $i_Info = 0)
    Local $ai_Pos[2], $i_xPos, $i_yPos, $ai_Read
    If $i_Info = 0 Then
        $i_xPos = IniRead($s_Title & ".ini", $s_Title, "Xpos", -1)
        $i_yPos = IniRead($s_Title & ".ini", $s_Title, "Ypos", -1)
        $ai_Pos[0] = $i_xPos
        $ai_Pos[1] = $i_yPos
    ElseIf $i_Info = 1 Then
        $i_xPos = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Xpos")
        If $i_xPos = 1 Or $i_xPos = -32000 Then
            RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Xpos", "REG_SZ", -1)
            $i_xPos = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Xpos")
        EndIf
        $i_yPos = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Ypos")
        If $i_yPos = 1 Or $i_yPos = -32000 Then
            RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Ypos", "REG_SZ", -1)
            $i_yPos = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Ypos")
        EndIf
        $ai_Pos[0] = $i_xPos
        $ai_Pos[1] = $i_yPos
    ElseIf $i_Info = 2 Then
        $ai_Read = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select x,y from conf";')
        $ai_Pos = StringSplit($ai_Read[1], Chr(124), 2)
    EndIf
    Return $ai_Pos
EndFunc   ;==>_GuiGetLastPos

Func _GuiSetLastPos($s_Title, $s_Text = "", $i_Info = 0)
    Local $ai_Pos[2]
    $ai_Pos = WinGetPos($s_Title, $s_Text)
    If $i_Info = 0 Then
        IniWrite($s_Title & ".ini", $s_Title, "Xpos", $ai_Pos[0])
        IniWrite($s_Title & ".ini", $s_Title, "Ypos", $ai_Pos[1])
    ElseIf $i_Info = 1 Then
        RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Xpos", "REG_SZ", $ai_Pos[0])
        RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $s_Title, "Ypos", "REG_SZ", $ai_Pos[1])
    ElseIf $i_Info = 2 Then
        _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update conf set x = ' & $ai_Pos[0] & ", y = " & $ai_Pos[1] & ";")
    EndIf
EndFunc   ;==>_GuiSetLastPos

Func _RunReadStd($doscmd, $timeoutSeconds = 0, $workingdir = @ScriptDir, $flag = @SW_HIDE, $nRetVal = -1, $sDelim = @TAB)
    Local $aReturn, $i_Pid, $h_Process, $i_ExitCode, $sStdOut, $sStdErr, $runTimer
    Dim $aReturn[3]

    ; run process with StdErr and StdOut flags
    $runTimer = TimerInit()
    $i_Pid = Run($doscmd, $workingdir, $flag, 6) ; 6 = $STDERR_CHILD+$STDOUT_CHILD

    ; Get process handle
    Sleep(100) ; or DllCall may fail - experimental
    $h_Process = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'int', 0x400, 'int', 0, 'int', $i_Pid)

    ; create tab delimited string containing StdOut text from process
    $aReturn[1] = ""
    $sStdOut = ""
    While 1
        $sStdOut &= StdoutRead($i_Pid)
        If @error Then ExitLoop
    WEnd
    $sStdOut = StringReplace($sStdOut, @CR, @TAB)
    $sStdOut = StringReplace($sStdOut, @LF, @TAB)
    $aStdOut = StringSplit($sStdOut, @TAB, 1)
    For $i = 1 To $aStdOut[0]
        $aStdOut[$i] = StringStripWS($aStdOut[$i], 3)
        If StringLen($aStdOut[$i]) > 0 Then
            $aReturn[1] &= $aStdOut[$i] & $sDelim
        EndIf
    Next
    $aReturn[1] = StringTrimRight($aReturn[1], 1)

    ; create tab delimited string containing StdErr text from process
    $aReturn[2] = ""
    $sStdErr = ""
    While 1
        $sStdErr &= StderrRead($i_Pid)
        If @error Then ExitLoop
    WEnd
    $sStdErr = StringReplace($sStdErr, @CR, @TAB)
    $sStdErr = StringReplace($sStdErr, @LF, @TAB)
    $aStderr = StringSplit($sStdErr, @TAB, 1)
    For $i = 1 To $aStderr[0]
        $aStderr[$i] = StringStripWS($aStderr[$i], 3)
        If StringLen($aStderr[$i]) > 0 Then
            $aReturn[2] &= $aStderr[$i] & $sDelim
        EndIf
    Next
    $aReturn[2] = StringTrimRight($aReturn[2], 1)

    ; kill the process if it exceeds $timeoutSeconds
    If $timeoutSeconds > 0 Then
        If TimerDiff($runTimer) / 1000 > $timeoutSeconds Then
            ProcessClose($i_Pid)
        EndIf
    EndIf

    ; fetch exit code and close process handle
    If IsArray($h_Process) Then
        Sleep(100) ; or DllCall may fail - experimental
        $i_ExitCode = DllCall('kernel32.dll', 'ptr', 'GetExitCodeProcess', 'ptr', $h_Process[0], 'int*', 0)
        If IsArray($i_ExitCode) Then
            $aReturn[0] = $i_ExitCode[2]
        Else
            $aReturn[0] = -1
        EndIf
        Sleep(100) ; or DllCall may fail - experimental
        DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $h_Process[0])
    Else
        $aReturn[0] = -2
    EndIf

    ; return single item if correctly specified with with $nRetVal
    If $nRetVal <> -1 And $nRetVal >= 0 And $nRetVal <= 2 Then Return $aReturn[$nRetVal]

    ; return array with exit code, stdout, and stderr
    Return $aReturn
EndFunc   ;==>_RunReadStd

Func _SetOnTop()
    If BitAND(GUICtrlRead($ontopitem), $GUI_CHECKED) = $GUI_CHECKED Then
        _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update conf set ontop = 0 ;"')
        WinSetOnTop($name, "", 0)
        GUICtrlSetState($ontopitem, $GUI_UNCHECKED)
        GUICtrlSetState($ontop, $GUI_UNCHECKED)
    Else
        _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "update conf set ontop = 1 ;"')
        WinSetOnTop($name, "", 1)
        GUICtrlSetState($ontopitem, $GUI_CHECKED)
        GUICtrlSetState($ontop, $GUI_CHECKED)
    EndIf
EndFunc   ;==>_SetOnTop

Func _CheckOnTop()
    $top = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select ontop from conf";')
    If $top[1] = 1 Then
        GUICtrlSetState($ontopitem, $GUI_CHECKED)
        GUICtrlSetState($ontop, $GUI_CHECKED)
        WinSetOnTop($name, "", 1)
    ElseIf $top[1] = 0 Then
        GUICtrlSetState($ontopitem, $GUI_UNCHECKED)
        GUICtrlSetState($ontop, $GUI_UNCHECKED)
    EndIf
EndFunc   ;==>_CheckOnTop

Func _SetOnBoot()
    If BitAND(GUICtrlRead($toggleitem), $GUI_CHECKED) = $GUI_CHECKED Then
        _RunReadStd(@ComSpec & " /c " & 'sqlite3 Calendar.db "update conf set boot = 0 ;"')
        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $name)
        GUICtrlSetState($toggleitem, $GUI_UNCHECKED)
        GUICtrlSetState($toggle, $GUI_UNCHECKED)
    Else
        _RunReadStd(@ComSpec & " /c " & 'sqlite3 Calendar.db "update conf set boot = 1 ;"')
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $name, "REG_SZ", @ScriptFullPath)
        GUICtrlSetState($toggleitem, $GUI_CHECKED)
        GUICtrlSetState($toggle, $GUI_CHECKED)
    EndIf
EndFunc   ;==>_SetOnBoot

Func _CheckOnBoot()
    $reg = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select boot from conf";')
    If $reg[1] = 1 Then
        GUICtrlSetState($toggleitem, $GUI_CHECKED)
        GUICtrlSetState($toggle, $GUI_CHECKED)
    ElseIf $reg[1] = 0 Then
        GUICtrlSetState($toggleitem, $GUI_UNCHECKED)
        GUICtrlSetState($toggle, $GUI_UNCHECKED)
    EndIf
EndFunc   ;==>_CheckOnBoot

Func _GetBackground()
    Local $bckgrnd
    $bckgrnd = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select background from conf";')
    Return $bckgrnd[1]
EndFunc   ;==>_GetBackground

Func _GetTransparency()
    Local $trans
    $trans = _RunReadStd(@ComSpec & " /c " & 'sqlite3 dock.db "select transparency from conf";')
    Return $trans[1]
EndFunc   ;==>_GetTransparency

Func _RestoreFromTray()
    GUISetState(@SW_SHOW, $parent)
    GUISetState(@SW_RESTORE, $parent)
    $offscreencheck = WinGetPos($name, "")
    If $offscreencheck[0] = -32000 And $offscreencheck[1] Then
        WinMove($name, "", $winpos[0], $winpos[1])
    EndIf
    Opt("TrayIconHide", 1)
EndFunc   ;==>_RestoreFromTray

Func _MinimizeToTray()
    GUISetState(@SW_HIDE, $parent)
    Opt("TrayIconHide", 0)
EndFunc   ;==>_MinimizeToTray

Package (sqlite3, prebuilt database, icon, source):

LD_1.0.zip

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

thanks, pastl, I was thinking actually of making it an option to either be a horizontal rectangle or a square gui, just hadn't quite decided how I was going to go about doing that.

sunblood, I will look into adding variables to account for changing the working directory to whatever program is being run and then switching back again, that shouldn't be too hard to do.

as for drak, thanks, and I'm not sure about the best way for adding tabs from within the program, I had thought about that feature when I first started scripting the tabs. I also want to make it so that you can configure the tab names. I'd also like to add the ability to configure the hotkeys.

Other options I want to add are a slide bar for setting the transparency, as well as a get position function so that you can set the start position to wherever the window currently is, or maybe just have the coordinates default to where it currently is. I'd also like to have an option so that you can decide if LaunchDock will open normally or minimized to the tray. Let me know if any of these sound good.

[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

here's a simple example of adding tabs at run time:

#include <GUIConstants.au3>

$SettingsTabs = IniRead(@Scriptdir & "\ExampleTabs.ini", "Settings", "Tabs", 1)
dim $TabSheet

GUICreate("Form1", 492, 466, 449, 198, -1)
GUISetBkColor(0xFFFFFF)
$PageControl1 = GUICtrlCreateTab(80, 64, 361, 273)
For $x = 1 To $SettingsTabs
    $TabSheet[$x] = GUICtrlCreateTabItem(IniRead(@Scriptdir & "\ExampleTabs.ini", "Tabs", "Tab" & $x, 1))
Next
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
;;;
    EndSelect
WEnd
Exit

Sample INI file (ExampleTabs.ini):

[Tabs]

Tab1=Apps

Tab2=Games

Tab3=System

[settings]

Tabs=3

Edited by drak
Link to comment
Share on other sites

  • 3 years later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...