--- In [email protected], "brucexs" <[EMAIL PROTECTED]> wrote:
>
> >
> > Could you set me off in a direction for accomplishing the above ?
I
> > want to implement different action for right and left mouse click
> on
> > a file. I cannot think of a way to do it without using ini's...
> >
>
> First, why not use an ini? Its a small extension to your existing
> script to write out multiple lines for each element in the menu
> representing the ini format
> [n]
> lcmd1=xxx
> rcmd1=yyy
> You'd have to ensure "configure|setup|all menus|right selects..."
is
> checked. You might have to split internal commands like clip into
> command and parameters
> rcmd1=clip
> rparam1=paste text
> But test without first -- it might work.
>
> Other ideas (each of these can be tried independently depending on
> you taste):
>
> 1. Use Win.lastmouse (see help) along with vec.showmenu or
filemenu
> function. This means the menu display and subsequent check of
which
> mouse key has to be in your script, not in More Commands.
>
> 2. Call your script with argument, something like .showrecent(n)
> where n is a number. Now establish different hot keys for the
things
> you want to do, and call the script with a different n for each hot
> key. Then have the script display the menu but interpret the
result
> depending on n (you will need to use vec.showmenu or filemenu
> function).
>
>
Hi
I'm trying to use win.lastmouse along with filemenu.
win.lastmouse(1)
local res = filemenu("extsort.txt")
win.debug(win.lastmouse(0),res)
trying to show in the debugger I can see only the result if I click
the left mouse button
(debug = 1 E:/Download/New/nirext.zip)
or the right button ,but without the result
(debug = 3)
I made sure that right select it's own command on setup->all menus
but it does not help - what can I do to make it work ?
Also - no matter what I tried , I never succesfully assigned an icon
to an item in the menu by using the ::index,iconfile syntax , no
matter what form I use filemenu or showfile. Is there a tick I should
tick somewhere for that (I've got properties icon size 16 put in the
file menu)
attached is the script -
Note - right click is not yet working for the mentined reason
/*
ExtSort.Powerpro
script is used to take all recent items in recent folder ,
sort them by their extention. look up in extention.txt for each file
extention
and categorise all the files into their right category.
After the sort display a menu
resulting menu should be a list of menus
(audio,video,office,docs,etc...) each containing
corresponding filetypes
left click = execute the file
right click = open context menu for the file
example of extentions.txt (should be in ppro folder)
-------------
audio=mp3,wav,wma
video=mpeg,mpg,avi,rm,mov,vob
office=doc,xls,ppt,pps
docs=pdf,txt,html,xml,htm,ini
-------------
Install:
1.Create a file called extentions.txt inside ppro folder.
2.Put in categories and their extentions. (see example above)
3.Add '[EMAIL PROTECTED]' to ppro startup
4.use command list item or hotkey to display the menu (simply
running .ExtSort)
*/
win.lastmouse(1)
local res = filemenu("extsort.txt")
win.debug(win.lastmouse(0),res)
if (res) do
makeAction(res)
endif
quit
@reCreate
local recent = env("userprofile") ++ ?"\recent"
local maxitems = 300
global watcher
file.deleteold(35,recent)
local v = vec.create(maxItems)
local w = vec.create(maxItems)
local i = 0
;retrieve all types from predefined file extentions.txt
static vecTypes = vec.create(20,10)
local han = file.open(pprofolder ++ "extentions.txt","r")
local line
for (i=0;1;i=i+1)
line = han.readline
if (han.eof)
break
vecTypes [i]=line
endfor
han.close
vecTypes.sort(v)
;retrieve all files in recent folder and their filetype into two
vectors (v,w)
i=0
file.allfiles(recent,"v[i]=file.resolve(_file_)\r w[i]=file.type(v
[i])\r i=i+1")
for (i=0;i<w.length;i++)
w[i] = getType(w[i])
endfor
w.doublesort(v)
local n = vec.create(maxitems+30)
;format the list
n[0]="properties autoquote iconsize 16"
n[1]=w[0] ++ ?"=format startsubmenu"
local j=2
local currext =w[0]
for (i=0; i<v.length; i=i+1)
if (currext!==w[i]) do
currext= w[i]
n[j] = "format endsubmenu"
n[j+1] = currext ++ "=format startsubmenu"
j+=2
endif
local fixpath = replacechars(v[i],??\?,??/?)
n[j] = ??@"? ++ select(fixpath,13) ++ ??...? ++ select
(fixpath,-19) ++ ??" ? ++ fixpath
j++
endfor
;now save the file
local han = file.open(pprofolder ++ "/extsort.txt", "w")
for (i=0; i<n.length; i=i+1)
han.WriteLine(n[i])
endfor
;win.debug("finihed rebuild")
;recreate the monitor for the recent folder
watcher = file.watchfolder(recent,?"[EMAIL PROTECTED]",0,"file")
quit
@getType
;function looks in arg(1) in VecTypes vector , and returns
;categorised result
;i.e if arg(1) ="doc" is found in documents record of vectype
return "documents"
for (local i=0;i<vecTypes.length;i++)
local strExt = arg(1)
if (index(vecTypes[i],arg(1)) > 0) do
local res = select(vecTypes[i],index(vecTypes[i],?"=")-1)
quit(res)
endif
endfor
if (strExt=="") do
quit("folders")
endif
quit("others")
quit
@MakeAction
;function takes exe , parses mouse button and performs action
;left = execute
;right = show context menu
local ResMouse = win.lastmouse(0)
local runCmd = arg(1)
if (ResMouse == 1) do
do(runCmd)
endif
if (ResMouse == 3) do
exec.contextmenu(runCmd)
endif
quit