/* Please note that this script cant launch steam games Credits: infogulch for pointing out a few bugs and for the SlideIn/Out idea/function and Tic for pointing out a few bugs aswell Todo: Add Separators Placement managment Steam games/apps support */ #SingleInstance Force #Persistent #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ScriptVersion := "1.0.0.8" CoordMode,Mouse,Screen SetTimer,GetMouseStats,5 SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. SetWinDelay,-1 SetBatchLines -1 Ini = Settings.ini Fade = 0 ;Default 0, Set to 1 to enable fadeouts S := A_ScreenWidth ;Gets the PCs Screenwidth GuiA := S//4 GuiB := S//2+S//4 WinTitle = BasicDock WinWidth := S/2 Alpha = 210 ;General Menu configuration --------------------------------------------------- Menu,tray,NoStandard Menu,tray,Add,[BasicDock %ScriptVersion%],Credits ;Remove this line to get rid of version info Menu,tray,disable,[BasicDock %ScriptVersion%] Menu,tray,Add, Menu,tray,Add,Add an application,AddApp Menu,tray,Add,Clear,ClearApps Menu,tray,Add, Menu,tray,Add,Check for update,UpdateCheck Menu,tray,Add,AHK Community,AHKC Menu,tray,Add,AHK.Net,AHKNet Menu,tray,Add, Menu,tray,Add,Exit ;Gui Configuration --------------------------------------------------------------- ConfigRead: Gui,3: Margin,y0 x35 Gui,3: +LastFound +ToolWindow WinSet,Transparent,%Alpha%, Gui,3: -Caption IniRead,AppPath,%Ini%,Apps,AppPath,ERROR If AppPath = ERROR Goto AddApp Loop,Parse,AppPath,|," ;" { If A_LoopField = { Empty = 1 } else Empty = 0 AppPath%A_Index% := A_LoopField ;Break it into Arrays Splitpath,A_LoopField,,OD,Ext If ( Ext = %Null% AND Empty != 1 ) { IsFolder = 1 } If IsFolder = 1 { Gui,3: Add,Pic,gStartApp y7,Explorer.exe } else { If Ext = AHK { Gui,3: Add,Pic,gStartApp y7 Icon2,%A_AhkPath% } else { If (IsFolder = 0) { Gui,3: Add,Pic,gStartApp y7,%A_LoopField% } } } ISFolder = 0 } Gui,3: +LastFoundExist Wi := "ahk_id" . WinExist() GuiTime := A_TickCount FadeStatus = 0 WinSet,Transparent,0 Gui,3: Show,w%WinWidth% h48 y0 xCenter,%WinTitle% FadeIn(Wi,0,Alpha,5) Return ;Menu Labels -------------------------------------------------------------------- AddApp: Gui,1: Destroy IfWinExist,Add an Application Gui,1: Destroy Gui,1: Add,Edit,vPath y7 x5 w200, ;The Application Add Dialog Gui,1: Add,Button,gBrowse y7 x205,... Gui,1: Add,Button,gSubmit y35 x5,Save Gui,1: Show,,Add an Application Return ClearApps: MsgBox,4,,Are you sure you want to delete the settings file ? IfMsgBox,Yes { FileDelete,%ini% Gui,3: Destroy Goto ConfigRead } Return AHKC: Run,http://www.autohotkey.com/forum/ Return AhkNet: Run,http://www.autohotkey.net/xfm/ Return Credits: Return Exit: If Fade = 1 FadeOut(W,Alpha,0,5) Gui,3: Destroy ExitApp Return ;Gui Labels -------------------------------------------------------------------- Browse: FileSelectFile,FTA GuiControl,1:,Path,%FTA% Return Submit: FadeOut(Wi,Alpha,0,5) Gui,1: Submit If Path != { IfExist,%Ini% { FileAppend,%Path%|,%Ini% } IfNotExist,%Ini% { FileAppend,[Apps]`nAppPath=%Path%|,%Ini% } } Gui,3: Destroy Goto ConfigRead Return 2GuiClose: Gui,2: Destroy Return StartApp: Loop,Parse,AppPath%C2%,|," ;" Run := A_LoopField Run,%Run% Return GuiClose: Gui,1: Destroy Return GuiDropFiles: SplitPath,A_GuiEvent,,OD,ext,name If ext = lnk { FileGetShortcut,%A_GuiEvent%,Targ GuiControl,1:,Path,%Targ% } else { GuiControl,1:,Path,%A_GuiEvent% } Return 3GuiDropFiles: FadeOut(Wi,Alpha,0,5) SplitPath,A_GuiEvent,,OD,ext,name If ext = lnk { FileGetShortcut,%A_GuiEvent%,Targ FileAppend,%Targ%|,%Ini% } else { FileAppend,%A_GuiEvent%|,%Ini% } Gui,3: Destroy Goto ConfigRead Return ;Input Labels ------------------------------------------------------------------ GetMouseStats: ;Thanks to infogulch for giving me lots of ideas and improvments CoordMode,Mouse,Screen MouseGetPos,X,Y,W,C If Y < 40 { If X between %GuiA% and %GuiB% { GuiTime := A_TickCount If Y < 5 { WinSet,AlwaysOnTop,On,%Wi% If FadeStatus = 1 { SlideIn(Wi,4,4) Sleep 20 FadeIn(Wi,80,210,5) FadeStatus = 0 } } IfInString,C,Static { StringTrimLeft,C2,C,6 Msg := AppPath%C2% ToolTip %Msg% ,,, 20 LStatic := Msg LCB := C2-1 LCF := C2+1 lX := X lY := Y } else ToolTip,,,,20 } else ToolTip,,,,20 } else ToolTip,,,,20 If (FadeStatus = 0 and A_TickCount-GuiTime > 5000) { FadeOut(Wi,Alpha,80,5) Sleep 20 SlideOut(Wi,4,4) WinSet,AlwaysOnTop,Off,%Wi% WinSet,Bottom,, %Wi% FadeStatus = 1 } Return ;Experimental ------------------------------------------------------------ 3GuiContextMenu: If C = Return If C != Static1 { Menu,Context,Add,Remove,Rem Menu,Context,Add,Move Left,MoveL Menu,Context,Add,Move Right,MoveR Menu,Context,Show } else { Menu,Context,Add,Remove,Rem Menu,Context,Add,Move Left,MoveL Menu,Context,Show } Return Rem: FadeOut(Wi,Alpha,0,5) FileRead,Last,%Ini% StringReplace,New,Last,%LStatic%|,, If ErrorLevel = 1 { FileCopy,%Ini%,BackupSettings.ini.bak MsgBox,Deletion of the entry you selected was not possible. The whole %Ini% will be deleted. (The script automaticly generated a backup in case you want to try using it again. Gui,3: Destroy FileDelete,%Ini% Goto ConfigRead } FileDelete,%Ini% FileAppend,%New%,%Ini% Gui,3: Destroy Goto ConfigRead Return MoveL: FadeOut(Wi,Alpha,0,5) FileRead,File,%Ini% VTL := AppPath%LCB% Print := SwitchLeft(File,LStatic,VTL) IfNotInString,Print,ErrorCode { FileDelete,%Ini% FileAppend,%Print%,%ini% Sleep 1000 Gui,3: Destroy Goto ConfigRead } Return MoveR: FadeOut(Wi,Alpha,0,5) FileRead,File,%Ini% V2 := AppPath%LCF% Print := SwitchRight(File,LStatic,V2) IfNotInString,Print,ErrorCode { FileDelete,%Ini% FileAppend,%Print%,%ini% Sleep 1000 } Gui,3: Destroy Goto ConfigRead Return ;Functions --------------------------------------------------------------------- FadeIn(Window,Alpha = 0,TargetAlpha = 255,Sleep = 5) { W := Window A := Alpha S := Sleep TA := TargetAlpha LoopC := (TA-A)//5 Loop %LoopC% { A += 5 WinSet,Transparent,%A%,%W% Sleep %S% } } Return FadeOut(Window,Alpha = 255,TargetAlpha = 0,Sleep = 5) { W := Window ;Set the respective short names A := Alpha S := Sleep TA := TargetAlpha LoopC := (A-TA)//5 Loop %LoopC% { A -= 5 WinSet,Transparent,%A%,%W% Sleep %S% } } Return SlideIn(Window,Sleep = 5,Rate = 4) { Global GuiA W := Window S := Sleep R := 48//Rate Loop %R% { Move := A_Index*Rate - 48 WinMove, %W%,, GuiA, Move If S Sleep %S% } WinMove, %W%,,GuiA,0 } Return SlideOut(Window,Sleep = 5,Rate = 4) { Global GuiA W := Window S := Sleep R := 48//Rate Loop %R% { Move := (-A_Index)*Rate WinMove, %W%,, GuiA, Move If S Sleep %S% } WinMove, %W%,,GuiA,-48 } Return SwitchLeft(Input,String1,String2) { StringReplace,Output,Input,%String2%|%String1%|,%String1%|%String2%| If ErrorLevel = 1 Output = ErrorCode 1: String 2 is missing (or there is no string 2) Return,Output } Return SwitchRight(Input,String1,String2) { StringReplace,Output,Input,%String1%|%String2%|,%String2%|%String1%| If ErrorLevel = 1 Output = ErrorCode 1: String 2 is missing (or there is no string 2) Return,Output } Return UpdateCheck: UrlDownloadToFile,http://www.autohotkey.net/~Adde/dl/BasicDockVersion.txt,BasicDockVersion.txt FileRead,Version,BasicDockVersion.txt If Version > %ScriptVersion% { MsgBox,4,,Would you like to download the new version ? IfMsgBox,Yes { UrlDownloadToFile,http://www.autohotkey.net/~Adde/dl/BasicDock.ahk,BasicDock.ahk FileDelete,BasicDockVersion.txt Reload } } else { MsgBox,No new updates. } Return