Button2em_

Title Button2em_
File Name Button2em.txt
Description Convert a button to a user command (em_)
Author Vochomurka
Parameters -
Plugins Called file, ini, vec
Icon
Version 1.2
Updated on 15.02.2012
local Path = "path_to_panels\*.bar"
local Bar = pickfile(file.listfiles(Path, 0), "Pick Bar File")
static BB = "Buttonbar"
static M = "menu"

if(not Bar)
	quit

local i, Mess, Counter
local Buttons = ini.get(Bar, BB, "Buttoncount")
if(ini_status != "OK") do
	messagebox("ok error", ini_status, "INI plugin error #1")
	quit
endif

local v = vec.create(Buttons)
if(v <= 0) do
	messagebox("ok error", "Failure creating vector", "VEC plugin Error #1")
	quit
endif

for(i = 1; i <= Buttons; i++)
	Path = ini.check_exists(Bar, BB, M ++ i)
	if(Path != 3)
		continue

	Mess = Mess ++ ini.get(Bar, BB, M ++ i) ++ esc(?+\n+, ?+\+)
	v[Counter] = i
	Counter++
endfor

pickstring(Mess, "Pick a button from " ++ Bar, 2)

if(not _pickedline_)
	quit

Counter = v[_pickedline_ - 1]
v.destroy

v = vec.createfromwords("button cmd path param menu")
if(v <= 0) do
	messagebox("ok error", "Failure creating vector", "VEC plugin Error #2")
	quit
endif

Buttons = ini.get(Bar, BB, M ++ Counter)
Buttons = case("title", Buttons)
Mess = "em_" ++ replacechars(Buttons, " ", "")
Buttons = inputdefault(Mess, "Enter new user command name")

if(not Buttons)
	quit

Path = env("WINDIR") ++ "\usercmd.ini"

for(i = 0; i < 4; i++)
	if(ini.check_exists(Bar, BB, v[i] ++ Counter) == 3) do
		Mess = ini.get(Bar, BB, v[i] ++ Counter)
		ini.set(Path, Buttons, v[i], Mess) 
	endif
endfor

Comments:

Script allows to transform a button on a button bar to a user command (for example, so as to assign a shortcut key to this command). First, indicate path to *.bar files (usually the TabDir key in configuration). Second, indicate path to your usercmd.ini file (usually the same as that to wincmd.ini).

After the script is run, you first choose the *.bar file to take the button from, and the button itself. Then the name for a new user command is suggested, but can be changed.


All Scripts Total Commander TotalCmd.net PowerPro