Button to Shortcut

Title Button2Shortcut
File Name Button2Shortcut.txt
Description Convert button to shortcut
Author Vochomurka
Parameters -
Plugins Called file, ini, vec
Icon
Version 1.0
Updated on 18.02.2006
local Path = "path\*.bar"
local Bar = pickfile(file.listfiles(Path, 0), "Pick Bar File")
local Tab = esc(?+\t+, ?+\+)
local CR = esc(?+\n+, ?+\+)
local i, Key, Mess

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

if(not pproflag(0))
	quit

v = vec.create(6)
if(v == 0) do
	messagebox("ok error", "Failure creating vector", "VEC plugin Error")
	quit
endif

v[0] = "button"
v[1] = "cmd"
v[2] = "param"
v[3] = "path"
v[4] = "menu"
v[5] = "iconic"

flag set 3

for(i = 1; i <= Buttons; i = i + 1)
	Mess = ""
	flag clear 1 2
	if(ini.check_exists(Bar, "Buttonbar", "button" ++ i) == 3) do
		if(ini.get(Bar, "Buttonbar", "button" ++ i) != "")
			flag set 1
	endif

	if(ini.check_exists(Bar, "Buttonbar", "cmd" ++ i) == 3) do
		if(file.validpath(ini.get(Bar, "Buttonbar", "cmd" ++ i)))
			flag set 2
	endif

	if(pproflag(1) && pproflag(2)) do
		for(j = 0; j <= 5; j = j + 1)
			Key = v[j] ++ i
			if(ini.check_exists(Bar, "Buttonbar", Key) == 3) do
				Mess = Mess ++ Key ++ ": " ++ Tab
				if(i > 9 && j != 0)
					Mess = Mess ++ Tab

				Mess = Mess ++ ini.get(Bar, "Buttonbar", Key) ++ CR
			endif
		endfor
		Mess = Mess ++ CR ++ "Convert to shortcut?"
		Path = "Button #" ++ i ++ " of " ++ Buttons ++ " in " ++ Bar
		Key = messagebox("yesnocancel question", Mess, Path)
		if(Key == 0) do
			quit
		elseif(Key == 6) do
			flag clear 3
			break
		endif
	endif
endfor

if(pproflag(3))
	quit

Path = ini.get(Bar, "Buttonbar", "cmd" ++ i)
Key = "path\" ++ ini.get(Bar, "Buttonbar", "menu" ++ i) ++ ".lnk"

if(ini.check_exists(Bar, "Buttonbar", "param" ++ i) == 3) do
	Tab = ini.get(Bar, "Buttonbar", "param" ++ i)
else
	Tab = ""
endif

CR = ini.get(Bar, "Buttonbar", "button" ++ i)
Buttons = revindex(CR, ",")
Mess = ifelse(Buttons != 0, select(CR, Buttons - 1), CR)
Buttons = select(CR, Buttons + 1, length(CR))
Bar = "Shortcut created with PowerPro Script from Total Commander Button"
Bar = file.createshortcut(Path, Key, Bar, Tab, Mess, Buttons)

if(Bar == 1) do
	messagebox("ok information", "Shortcut successfully created", Key)
else
	messagebox("ok error", "Error creating shortcut", Key)
endif

vec.unload
ini.unload

Comments:

Script converts a button from button bar to the Windows shortcut (with the lnk extension). After running the script first pick a button bar file from the list, and then press "No" till the necessary button description appears.


Shortcut to Button

Title Shortcut2Button
File Name Shortcut2Button.txt
Description Convert shortcut to button
Author Vochomurka
Parameters ("%p%n")
Plugins Called file, clip, vec
Icon
Version 1.0
Updated on 18.02.2006
args ShCut

v = vec.create(6)
if(v == 0) do
	messagebox("ok error", "Failure creating vector", "VEC plugin Error")
	quit
endif

v[0] = "TOTALCMD#BAR#DATA"
v[1] = file.resolve(ShCut)
v[2] = file.resolve(ShCut, "par")
v[3] = file.resolve(ShCut, "icon")
v[4] = file.resolve(ShCut, "desc")
v[5] = file.resolve(ShCut, "work")

if(v[3] == "")
	v[3] = v[1]

local Str = vec.makelines(v)
clip.set(Str)
vec.destroy(v)
vec.unload

Comments:

Put the cursor on a desired shortcut file and run the script. Then point the mouse to the button bar, and select "Paste" in the right-click menu.


All Scripts Total Commander TotalCmd.net PowerPro