args Param static Mode = Param if(arg(0) > 1) do .@Batch(arg(1), arg(2), arg(3), arg(4)) quit all endif static BB = "Buttonbar" static BC = "Buttoncount" static hh = win.handle("c=TTOTAL_CMD") static Path = file.folder(win.exepath(hh)) static ButtonCount = 0 static G = "General" static Config = pprofolder ++ "scripts\ini\ButtonBarTools.ini" static Height = ini.get(Config, G, "Height") - 2 local MainBar, Cur static E = cl.Create("Dirs", 1) local Sex = ini.enum_sections(Config) static FSS = "Format StartSubmenu" static FES = "Format EndSubmenu" static FNCL = "Format NewColumnLine" static Mask = "*.bar" static CR = esc(?+\r+, ?+\+) static Tab = esc(?+\t+, ?+\+) static BBTS = "ButtonBarTools Script" static FCV = "Failure creating vector" flag set 1 static w = vec.createfromwords("button cmd param path menu iconic") if(not w) do messagebox("ok error", FCV, "VEC plugin Error #4") quit endif static KeyWords = w.length static S = vec.create(6) if(not S) do messagebox("ok error", FCV, "VEC plugin Error #2") quit endif S[1] = 0 S[3] = 0 S[5] = 0 static Target = Path ++ "\BBT" ++ ifelse(ini.get(Config, G, "SameNameResult"), "", date ++ time) ++ ".bar" E.Insert(0) E.AddLeft(0, FSS) E.SetLabel(0, "Main Bars") .@Read() Cur = E.length E.Insert(Cur) E.AddLeft(Cur, FES) for each line MainBar in Sex if(MainBar != G) do Cur = E.length E.Insert(Cur) E.AddLeft(Cur, FSS) E.SetLabel(Cur, MainBar) .@Read(MainBar) Cur = E.length E.Insert(Cur) E.AddLeft(Cur, FES) endif endfor E.SetProperties("Format=samesize vertical iconsize: 16 tooltips") if(Mode == "s") do static Ba = "Bars" static Bu = "Buttons" Cur = S[1] + S[3] + S[5] MainBar = S[0] + S[2] + S[4] Sex = "Main:" ++ CR ++ Ba ++ Tab ++ S[0] ++ CR ++ Bu ++ Tab ++ S[1] ++ CR ++ CR Sex ++= "Local:" ++ CR ++ Ba ++ Tab ++ S[2] ++ CR ++ Bu ++ Tab ++ S[3] ++ CR ++ CR Sex ++= "Other:" ++ CR ++ Ba ++ Tab ++ S[4] ++ CR ++ Bu ++ Tab ++ S[5] ++ CR ++ CR Sex ++= "Total:" ++ CR ++ Ba ++ Tab ++ MainBar ++ CR ++ Bu ++ Tab ++ Cur messagebox("ok information", Sex, BBTS) else E.ShowMenu("centerscreen") endif if(!ini.get(Config, G, "KeepResult")) file.delete(Target) if(Mode == "b") do Cur = E.GetLastMenuSel() if(Cur) quit(E.GetTooltip(Cur)) endif quit all ;;************************************************ Function Read(Sec) local Str, List, Elem, Counter, j, Cur, Pan, Temp static i = "information" static B = " bars" static T = "timeout=5" static FolderIcon = env("WINDIR") ++ "\system32\shell32.dll" switch (Sec) case "Local Bars" Str = ini.enum_keys(Config, Sec) Pan = line(Str, 0) miscplugin.BalloonTip(1, i, "Local: " ++ Pan ++ B, T) S[2] = Pan for each line Temp in Str Elem = ini.get(Config, Sec, Temp) j = Elem ++ "_local.bar" Cur = E.length E.Insert(Cur) E.SetLabel(Cur, j) E.SetIcon(Cur, FolderIcon, 4) if(Mode != "b") do E.AddLeft(Cur, FSS) S[3] += .@Bur(j) Cur = E.length E.Insert(Cur) E.AddLeft(Cur, FES) endif if(Counter > Height) do E.Insert(Cur + 1) E.AddLeft(Cur + 1, FNCL) Counter = 0 else Counter++ endif endfor break case "Other Bars" Str = ini.enum_keys(Config, Sec) for each line Pan in Str Elem = ini.get(Config, Sec, Pan) List = file.listfiles(Elem ++ Mask) S[4] += line(List, 0) miscplugin.BalloonTip(1, i, "Other: " ++ S[4] ++ B, T) for each line j in List Cur = E.length E.Insert(Cur) E.SetLabel(Cur, j) E.SetIcon(Cur, FolderIcon, 4) if(Mode != "b") do E.AddLeft(Cur, FSS) S[5] += .@Bur(j) Cur = E.length E.Insert(Cur) E.AddLeft(Cur, FES) endif if(Counter > Height) do E.Insert(Cur + 1) E.AddLeft(Cur + 1, FNCL) Counter = 0 else Counter++ endif endfor endfor break case else Temp = file.listfiles(Path ++ "\*.bar") Pan = line(Temp, 0) S[0] = Pan miscplugin.BalloonTip(1, i, " Main: " ++ Pan ++ B, T) for each line j in Temp Elem = file.name(j) Cur = E.length with E.Insert(Cur) .SetLabel(Elem) .SetIcon(FolderIcon, 4) .SetTooltip(j) endwith if(Mode != "b") do E.AddLeft(Cur, FSS) S[1] += .@Bur(j) Cur = E.length E.Insert(Cur) E.AddLeft(Cur, FES) endif if(Counter > Height) do E.Insert(Cur + 1) E.AddLeft(Cur + 1, FNCL) Counter = 0 else Counter++ endif endfor endswitch quit ;;************************************************ Function Bur(Name) local Name local Buttons = ini.get(Name, BB, BC) local BarNum = E.length - 1 static SR = ini.get(Config, G, "SlashReplacer") local j, Temp, Cur, TT, Counter, Item, cmds E.SetId(BarNum, Name) for(j = 1; j <= Buttons; j++) Temp = w[1] ++ j if(ini.check_exists(Name, BB, Temp) == 2) do Cur = E.length E.Insert(Cur) E.AddLeft(Cur, "Format Separator") continue endif if(ini.get(Name, BB, Temp) == -2) do Cur = E.length E.Insert(Cur) E.AddLeft(Cur, FNCL) continue endif Cur = E.length Item = E.Insert(Cur) cmds++ with Item if(ini.check_exists(Name, BB, w[4] ++ j) == 3) .SetLabel(ini.get(Name, BB, w[4] ++ j)) if(ini.check_exists(Name, BB, w[0] ++ j) == 3) .SetIcon(ini.get(Name, BB, w[0] ++ j)) TT = "Command: " ++ replacechars(ini.get(Name, BB, Temp), "/", SR) if(ini.check_exists(Name, BB, w[2] ++ j) == 3) TT ++= "/Parameters: " ++ replacechars(ini.get(Name, BB, w[2] ++ j), "/", SR) if(ini.check_exists(Name, BB, w[3] ++ j) == 3) TT ++= "/Path: " ++ ini.get(Name, BB, w[3] ++ j) Temp = E.GetMaxtext Cur = length(TT) if(Cur > Temp) TT = remove(TT, Temp - Cur - 20) ++ "/...truncated" .SetTooltip(TT) .AddLeft(cb("@Mark", Cur, BarNum, j)) .AddRight(cb("@BInsert", BarNum, j)) endwith if(Counter > Height) do E.Insert(Cur + 1) E.AddLeft(Cur + 1, FNCL) Counter = 0 else Counter++ endif endfor quit(cmds) ;;************************************************ Function Mark(Num, BarNum, Button) local k, Key, Value local Source = E.GetId(BarNum) if(Ctrl || Mode == "c") do .@Buffer(Source, Button) quit all endif static ButtonColor = ini.get(Config, G, "MarkButton") static BurColor = ini.get(Config, G, "MarkBar") E.SetBackColor(Num, ButtonColor) E.SetBackColor(BarNum, BurColor) flag clear 1 ButtonCount++ ini.error_dialog_off() for(k = 0; k < KeyWords; k++) Temp = w[k] Key = Temp ++ Button if(ini.check_exists(Source, BB, Key) == 3) do Value = ini.get(Source, BB, Key) ini.set(Target, BB, Temp ++ ButtonCount, Value) ini.set(Target, BB, BC, ButtonCount) endif endfor E.ShowMenu("centerscreen") quit ;;************************************************ Function BInsert(BarNum, Button) local Source = E.GetId(BarNum) if(pproflag(1)) do .@Buffer(Source, Button) quit all endif local Keys = ini.get(Source, BB, BC) local k, m, Temp, Value, Key, Shift for(k = Keys; k > Button; k--) Shift = k + ButtonCount for(m = 0; m < KeyWords; m++) Temp = w[m] Key = Temp ++ k if(ini.check_exists(Source, BB, Key) == 3) do Value = ini.get(Source, BB, Key) Temp = w[m] ++ Shift ini.set(Source, BB, Temp, Value) ini.delete_key(Source, BB, Key) endif endfor endfor for(k = 1; k <= ButtonCount; k++) Shift = k + Button for(m = 0; m < KeyWords; m++) Temp = w[m] Key = Temp ++ k if(ini.check_exists(Target, BB, Key) == 3) do Value = ini.get(Target, BB, Key) Temp = w[m] ++ Shift ini.set(Source, BB, Temp, Value) endif endfor endfor messagebox("ok information", ButtonCount ++ " buttons copied to " ++ Source, BBTS) ini.set(Source, BB, BC, Keys + ButtonCount) quit ;;************************************************ Function Batch(SourceBar, TargetBar, From, To) local j, 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, BBTS) quit endif if(not validpath(SourceBar)) do Str = "Source bar file name " ++ SourceBar ++ " is wrong" messagebox ("ok", Str, BBTS) quit endif if(From > To) do Str = "Starting button number " ++ From ++ " is more than ending number " ++ To messagebox ("ok", Str, BBTS) quit endif Temp = ini.get(SourceBar, BB, BC) if(Temp < To) do Str = "Button count in " ++ SourceBar ++ " is " ++ Temp ++ " and is less than ending number " ++ To messagebox ("ok", Str, BBTS) quit endif if(!From && !To) do From = 1 To = Temp endif for(j = From; j <= To; j++) Counter++ Next++ for each Elem in w Temp = Elem ++ j 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, BBTS) quit ;;************************************************ Function Buffer(Source, Button) local k, Value, Key local x = vec.create(KeyWords) local Temp = "TOTALCMD#BAR#DATA" ++ CR if(not x) do messagebox("ok error", FCV, "VEC plugin Error #3") quit all endif for(k = 0; k < KeyWords; k++) Value = w[k] Key = Value ++ Button x[k] = ifelse(ini.check_exists(Source, BB, Key) == 3, ini.get(Source, BB, Key), "") endfor Temp ++= x[1] ++ CR ++ x[2] ++ CR ++ x[0] ++ CR ++ x[4] ++ CR ++ x[3] ++ CR ++ x[5] unicode.clip_set(Temp) quit