local hwnd = win.handle("c=TTOTAL_CMD")
local Path = file.folder(win.exepath(hwnd))
static Config = Path ++ "\DEFAULT.BAR"
static BB = "Buttonbar"
static BC = "Buttoncount"
static Buttons = ini.get(Config, BB, BC)
dialog.error_dialog_on()
local hDlg = dialog.define("0!", "0!", "163!", "44!", "DeleteButtons Script", "thickframe sysmenu centre", "" , "", "", "", "plugins\dialog.dll", 1)
if(not hDlg)
quit
local iCnt = 1
local EN_CHANGE = 0x0300
hDlg.define_control("16 6 12 10", "editbox", "ebCnt", iCnt, "3d border", "", "", EN_CHANGE)
hDlg.define_control("6 6 12 10", "spinner", "spCnt", "", "setbuddyint")
hDlg.define_control("32 6 128 10", "static", "text", "Number of buttons to delete (from right)")
hDlg.define_control("6 22 74 16", "button", "", "Ok", "", cbx("@onOk"), "", "", "", "", "ok")
hDlg.define_control("86 22 74 16", "button", "btQuit", "&Cancel", "", cbx("@onQuit"), "", "", "", "", "cancel")
hDlg.create(0)
local hWnd = hDlg.get("ebCnt", "hwnd")
hDlg.send_message("spCnt", "setbuddy", hWnd, 0, 0)
hDlg.run("foreground")
hDlg.set_range("spCnt", 1, Buttons)
quit
;===================================================
Function onOk(sUserArg, dlgHan)
local Num = dlgHan.get_value("spCnt")
dlgHan.destroy()
local i, j, Counter, Real
local w = vec.createfromwords("button cmd param path menu iconic")
if(w <= 0) do
messagebox("ok error", "Failure creating vector", "VEC plugin Error #2")
quit
endif
local Keys = w.length
for(i = Buttons; i > 0; i--)
flag set 1
if(ini.check_exists(Config, BB, w[0] ++ i) == 3 && not ini.get(Config, BB, w[0] ++ i)) do
flag clear 1
Real++
endif
for(j = 0; j < Keys; j++)
if(ini.check_exists(Config, BB, w[j] ++ i) == 3)
ini.delete_key(Config, BB, w[j] ++ i)
endfor
if(pproflag(1))
Counter++
if(Counter >= Num)
break
endfor
ini.set(Config, BB, BC, Buttons - Counter - Real)
local Hand = win.handle("c=TTOTAL_CMD")
win.postmessage(Hand, 0x400+51, 2901, 0)
win.postmessage(Hand, 0x400+51, 2901, 0)
quit
;===================================================
Function onQuit(sUserArg, dlgHan)
dlgHan.show("hide")
dlgHan.destroy()
To perform some specific job, I usually put one or several buttons on the main button bar (default.bar). After completing the job buttons get useless. This script removes them quickly. Counting of buttons is done from the right.