args Stat, ClipBoard, SourceBar, TargetBar, From, To static Buf = 0 if(ClipBoard || Shift) Buf = 1 static BB = "Buttonbar" static BC = "Buttoncount" static w = vec.createfromwords("button cmd param path menu iconic") if(not w) do messagebox("ok error", "Failure creating vector", "VEC plugin Error #4") quit endif if(arg(0) > 2) .@Batch(SourceBar, TargetBar, From, To) static Config = pprofolder ++ "scripts\ini\ButtonBarTools.ini" static Height = ini.get(Config, "General", "Height") static CR = esc(?+\r+, ?+\+) local i flag clear 1 if(Ctrl || Stat) do local Rep = pprofolder ++ "ButtonBars.ini" local fh = file.open(Rep, "w") if(fh <= 0) do messagebox("ok error", "File not created", "FILE plugin error #1") quit endif file.close(fh) local Bars, Buttons, Counter, j, Temp for each line i in ini.enum_sections(Config) if(i != "General") do .@Read(i) else .@Read() endif Counter = v.length Bars += Counter for(j = 0; j < Counter; j++) Temp = ini.get(v[j], BB, BC) ini.set(Rep, i, v[j], Temp) Buttons += Temp endfor ini.set(Rep, "Summary", "Bars", Bars) ini.set(Rep, "Summary", "Buttons", Buttons) endfor Temp = "File " ++ Rep ++ " created" ++ CR ++ CR ++ "Bars: " ++ Bars ++ CR ++ "Buttons: " ++ Buttons messagebox("ok", Temp, "ButtonBarTools script") quit endif static D = cl.Create("Dirs", 1) for each line i in ini.enum_sections(Config) if(i != "General") do D.Insert(0) D.AddLeft(0, cb("@Read", i)) D.SetLabel(0, i) endif endfor D.Insert(0) D.AddLeft(0, cb("@Read")) D.SetLabel(0, "Main Bars") if(D.Length > 1) *menu show Dirs .@GetBars() *menu show Bars quit all ;;************************************************ Function Read(Sec) local Mask = "*.bar" local Temp, Str, List, Elem, Counter, Path static v if(vec.exists(v)) v.destroy if(not Sec) do local hh = win.handle("c=TTOTAL_CMD") Path = file.folder(win.exepath(hh)) Temp = file.listfiles(Path ++ "\" ++ Mask) v = vec.createfromlines(Temp) if(v <= 0) messagebox("ok error", "Vector not created", "VEC plugin error #1") quit endif v = vec.create(1, 1) if(v <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error #2") quit endif Str = ini.enum_keys(Config, Sec) for each line Temp in Str Elem = ini.get(Config, Sec, Temp) if(Sec == "Local Bars") do v[Counter] = Elem ++ "_local.bar" Counter++ else List = file.listfiles(Elem ++ Mask) for each line Elem in List v[Counter] = Elem Counter++ endfor endif endfor quit ;;************************************************ Function Left(i) if(pproflag(1)) do static Target = v[i] quit endif flag set 1 static Source = v[i] static Items = ini.get(Source, BB, BC) static B = cl.Create("Bar", 1) setstring Quote " local i, Str, Counter, TT, Param, Work, How, Menu, IconFile, Icon, Command, Temp if(not Buf) do B.Insert(0) B.AddLeft(0, cb("@Copy")) B.AddRight(0, cb("@Clip")) B.SetLabel(0, "OK") B.SetTooltip(0, "Left: Copy Buttons/Right: Put 1 Button to Clip") B.SetIcon(0, env("WINDIR") ++ "\system32\comres.dll", 8) B.SetBackColor(0, "128 255 128") B.SetHeight(0, 24) B.Insert(0) B.AddLeft(0, "*bar close Bar") B.SetLabel(0, "Cancel") B.SetIcon(0, env("WINDIR") ++ "\system32\comres.dll", 10) B.SetBackColor(0, "255 128 128") B.SetHeight(0, 24) B.SetTooltip(0, "Close Bar") endif for(i = Items; i >= 1; i--) B.Insert(0) if(ini.check_exists(Source, BB, "cmd" ++ i) == 2) do if(Buf) do B.AddLeft(0, "Format Separator") else B.SetLabel(0, "Separator") B.SetBackColor(0, 0) B.SetTextColor(0, "255 255 255") B.SetToolTip(0, "Button #" ++ i ++ "/Left: Close") B.AddLeft(0, "*bar close Bar") endif continue endif Command = ini.get(Source, BB, "cmd" ++ i) Command = .@CheckLength(Command) if(Command == -2) do Counter = 0 if(Buf) do B.AddLeft(0, "Format NewColumnLine") else B.SetLabel(0, "New Column") B.SetBackColor(0, 0) B.SetTextColor(0, "255 255 255") B.SetToolTip(0, "Button #" ++ i ++ "/Left: Close") B.AddLeft(0, "*bar close Bar") endif continue endif TT = "Button #" ++ i ++ "/Command: " ++ Command if(ini.check_exists(Source, BB, "param" ++ i) == 3) do Param = ini.get(Source, BB, "param" ++ i) Param = .@CheckLength(Param) TT ++= "/Parameters: " ++ Param else Param = "" endif if(ini.check_exists(Source, BB, "path" ++ i) == 3) do Work = ini.get(Source, BB, "path" ++ i) TT ++= "/Start path: " ++ Work else Work = "" endif if(ini.check_exists(Source, BB, "menu" ++ i) == 3) do Menu = ini.get(Source, BB, "menu" ++ i) TT ++= "/Tooltip: " ++ Menu Menu = replacechars(Menu, Quote, "''") else Menu = Command endif if(ini.check_exists(Source, BB, "iconic" ++ i) == 3) do How = ini.get(Source, BB, "iconic" ++ i) else How = "" endif B.SetToolTip(0, TT) if(Buf) do B.SetLabel(0, Menu) B.AddLeft(0, cb("@Buffer", i)) else B.SetLabel(0, "*control button autocheckbox" ++ Quote ++ Menu ++ Quote) endif if(ini.check_exists(Source, BB, "button" ++ i) == 3) do Str = ini.get(Source, BB, "button" ++ i) if(validpath(Str)) do IconFile = Str B.SetIcon(0, IconFile) Icon = "" else IconFile = nextword(Str, "Icon", ",") B.SetIcon(0, IconFile, Icon) endif endif Str = "TOTALCMD#BAR#DATA" ++ CR ++ Command ++ CR ++ Param ++ CR Str ++= IconFile ++ Icon ++ CR ++ Menu ++ CR ++ Work ++ CR ++ How B.AddRight(0, Str) if(Buf && Counter > Height) do B.Insert(0) B.AddLeft(0, "Format NewColumnLine") Counter = 0 else Counter++ endif endfor B.SetProperties("Format=barsize position: leftcaption samesize vertical iconsize: 16 tooltips") if(Buf) do *menu show Bar quit endif B.show quit ;;************************************************ Function Clip() local i for(i = 0; i < B.Length; i++) if(B.GetCtrlValue(i)) do clip.set(B.GetRightCmd(i)) B.SetCtrlValue(i, 0) break endif endfor quit ;;************************************************ Function Buffer(Num) local Str = B.GetRightCmd(Num - 1) clip.set(Str) quit all ;;************************************************ Function Copy() local i, Elem, i1, Counter, Temp, Str if(D.Length > 1) *menu show Dirs .@GetBars() *menu show Bars local Buttons = ini.get(Target, BB, BC) local Next = Buttons for(i = 0; i < B.Length; i++) if(B.GetCtrlValue(i)) do i1 = i + 1 Counter++ Next++ for each Elem in w Temp = Elem ++ i1 if(ini.check_exists(Source, BB, Temp) == 3) do Str = ini.get(Source, BB, Temp) ini.set(Target, BB, Elem ++ Next, Str) endif endfor endif endfor B.close ini.set(Target, BB, BC, Buttons + Counter) Str = Counter ++ " buttons are successfully copied from " ++ Source ++ " to " ++ Target messagebox("ok", Str, "ButtonBarTools Script") quit ;;************************************************ Function Batch(SourceBar, TargetBar, From, To) local i, Str, Counter, Temp, Elem local Buttons = ini.get(TargetBar, BB, BC) local Next = Buttons if(not validpath(TargetBar)) do Str = "Target bar file name " ++ TargetBar ++ " is wrong" messagebox ("ok", Str, "ButtonBarTools Script") quit endif if(not validpath(SourceBar)) do Str = "Source bar file name " ++ SourceBar ++ " is wrong" messagebox ("ok", Str, "ButtonBarTools Script") quit endif if(From > To) do Str = "Starting button number " ++ From ++ " is more than ending number " ++ To messagebox ("ok", Str, "ButtonBarTools Script") quit endif i = ini.get(SourceBar, BB, BC) if(i < To) do Str = "Button count in " ++ SourceBar ++ " is " ++ i ++ " and is less than ending number " ++ To messagebox ("ok", Str, "ButtonBarTools Script") quit endif for(i = From; i <= To; i++) Counter++ Next++ for each Elem in w Temp = Elem ++ i if(ini.check_exists(SourceBar, BB, Temp) == 3) do Str = ini.get(SourceBar, BB, Temp) ini.set(TargetBar, BB, Elem ++ Next, Str) endif endfor endfor ini.set(TargetBar, BB, BC, Buttons + Counter) Str = Counter ++ " buttons are successfully copied from " ++ SourceBar ++ " to " ++ TargetBar messagebox ("ok", Str, "ButtonBarTools Script") quit all ;;************************************************ Function GetBars() static Bs = cl.Create("Bars", 1) Bs.NewProperties("tooltips") local Number = v.length for(i = Number - 1; i >= 0; i--) Bs.Insert(0) Bs.AddLeft(0, cb("@Left", i)) Temp = file.name(v[i]) Bs.SetLabel(0, Temp) Temp = ini.get(v[i], BB, BC) Bs.SetTooltip(0, v[i] ++ "/" ++ Temp ++ " buttons") endfor for(i = 1; i <= Number/Height; i++) Bs.Insert(i*Height) Bs.AddLeft(i*Height, "Format NewColumnLine") endfor quit ;;************************************************ Function CheckLength(Str) static MT = B.GetMaxtext local Text if(length(Str) > MT) do Text = "String for command #" ++ i ++ " is longer than " ++ MT Text ++= " characters." ++ CR ++ "String is truncated" messagebox("ok", Text, "ButtonBarTools Script") Str = remove(Str, Temp - length(Str) - 200) endif quit(Str)