What do you think is the better approach, in terms of performance when the If-list gets really long? Using your extraction method or relying on XY built-in (not yet
[Script] WhiteSpaceCtxMenu
-
Stef123
Re: [Script] WhiteSpaceCtxMenu
What do you think is the better approach, in terms of performance when the If-list gets really long? Using your extraction method or relying on XY built-in (not yet
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
Though <selext> may still be nice to have in our back pocket, I'm not sure speed wise if it would make much of a difference. We're only obtaining the "ext" of the <selitem> (via $selext variable) one time and using it for the remainder of the script and that's extremely quick. If we got <selext>, it still might be wise to do the same thing (i.e., set a variable to <selext> so the same variable is used instead throughout the script rather than XY having to determine <selext> for each if or elseif statement). Though that determination I'm sure is only a fraction of a millisecond especially after the first use. We're probably talking a fraction of millisecond difference between one method and the other, so it certainly wouldn't be noticeable.
You mentioned having a long list of "if' and "elseif" statements, you must be really fine tuning this thing. I have to do more of that. I am really liking it and getting more use than I thought I would out of it. I'll get around to updating the first post to incorporate our changes since then (e.g., <selitem> , structure, etc.). Keep in mind, it works great to immediately run a particular extension using the method in the first post and it does work by your drag technique. Say you normally execute an AHK file by double clicking the file like I do with an AHK file or many others, this technique could be the alternate of immediately opening the ahk file in Notepad++ with no menu). Or just the opposite with an 'XYS' extension, I have double clicking the file open it in Notepad++, where as this script is used to immediately run the script.
You mentioned having a long list of "if' and "elseif" statements, you must be really fine tuning this thing. I have to do more of that. I am really liking it and getting more use than I thought I would out of it. I'll get around to updating the first post to incorporate our changes since then (e.g., <selitem> , structure, etc.). Keep in mind, it works great to immediately run a particular extension using the method in the first post and it does work by your drag technique. Say you normally execute an AHK file by double clicking the file like I do with an AHK file or many others, this technique could be the alternate of immediately opening the ahk file in Notepad++ with no menu). Or just the opposite with an 'XYS' extension, I have double clicking the file open it in Notepad++, where as this script is used to immediately run the script.
Re: [Script] WhiteSpaceCtxMenu
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
I modified the XYplorer.ini file as well as created a script called "WhiteSpaceCtxMenu.xys" with the code provided, despite the fact that the odds are, the programs on the ops computer, in this case klownboys are not installed on my PC.
When I select a text file, and right click a white space, the only context menu that appears is XYplorer default context menu ?
When I select a text file, and right click a white space, the only context menu that appears is XYplorer default context menu ?
klownboy wrote:The purpose of this script is to call out specific menus when the user right clicks on the list panel white space. The menu which comes up is dependent on the file type of the current file. So you could set it up such that if you had a jpg or png file selected (i.e <curitem>), a menu with 4 or 5 different programs to select from would display, you'd choose one and the file would be opened in that program. So it similar to a right clicking on the file itself to bring up a context menu, but in this case the user is clicking the white space. I mentioned coming up with something similar to this here http://www.xyplorer.com/xyfc/viewtopic. ... 15#p122111 If no file is selected, the script brings up a default menu which can be anything the user wants (i.e, it could be as simple as bringing up the Favorite Files, Favorite Folders, call your own menu, or something more elaborate). Remember if a file is currently selected, but you'd rather just bring up the default menu rather than the specific file-type menu of a highlighted file, you can simply normal left click on white and then right click. You can also easily set the menu up such that some file types programs would immediately be run in a program of choice. For example, you could have it set such that if you have a single GIF file selected, it would bring up all the folder's GIFs in TheQwerty's 'HTMLImagePreview.xys' viewer. You could even set it up such that the script does something special if a folder is selected.
3 examples of the menus which surface if you right clicked with a certain file types selected along with an example default menu:No, it's nothing new as far as scripting goes, but setting up a script to run when you right click on white space is quite easy and can be very handy. So, why not improve it, make it a bit smarter by expanding its capabilities. I call the script "WhiteSpaceCtxMenu.xys". To use, the 2 lines in the XYplorer.ini file which have to change are:Obviously this is not the type of script a user can simply plop into his script folder and use. This is more of an idea and skeleton script you can use to arrive at your own. You have to take a few minutes an substitute your own programs to run based on the file types and any new files types as you wish. What I show here are just examples and certainly not my final script. I'm finding it easier than using the 'real' context menu or even PFAs since it it seems to be less clicking in many cases. If the file you'd like to run a program on is currently selected simply right click on white to bring up the the specific file type menu. If the file isn't currently selected you simply select with the left click and then move the mouse slightly and right click. If you'd rather bring up the default menu when there's a file currently hi-lighted, just left click on white (to un-select) and then follow with a right click.Code: Select all
CEA_ListRightClickOnWhite=6 CEA_ListRightClickOnWhite_Script=load "<xyscripts>\WhiteSpaceCtxMenu.xys"I hope you can get some use out of it or maybe some new, additional or better ideas will spawn from it. Once set-up, I'm finding easier to use than the normal context menu.Code: Select all
/*** image file menu ***/ $image = <<<IMAGE "Thumbnails in new Instance|:conf"; $jpgPath = getpathcomponent("<curitem>", "path"); run """<xy>"" /new ""$jpgPath"" /win=normal,10,10,1900,1050 /script=""::if(get('View') != '6') {#308};loadlayout('thumbs');open 'D:\Tools\AutoHotkey\AHK scripts\TB_XY_hide.ahk';"""; end(1); } "ImageEye|D:\Graphics\Image Eye\Image Eye.exe"; Openwith "D:\Graphics\Image Eye\Image Eye.exe"; end(1); "Irfanview|D:\Graphics\IrfanView\i_view32.exe"; openwith "D:\Graphics\IrfanView\i_view32.exe";end(1); "Greenfish Icon Editor|D:\Graphics\Greenfish Icon Editor Pro\gfie64.exe" openwith "D:\Graphics\Greenfish Icon Editor Pro\gfie64.exe"; IMAGE; /*** video file menu ***/ $vid = <<<VID "BD Rebuilder|D:\DVD\BD Rebuilder\BDRB.exe" open "D:\DVD\BD Rebuilder\BDRB.exe"; "ConvertXtoDvd|D:\DVD\ConvertX\ConvertXtoDvd.exe" open "D:\DVD\ConvertX\ConvertXtoDvd.exe"; "EMDB|D:\DVD\EMDB\EMDB.exe" open "D:\DVD\EMDB\EMDB.exe"; "ImgBurn|D:\DVD\ImgBurn\ImgBurn.exe" open "D:\DVD\ImgBurn\ImgBurn.exe"; "MPC-HC|D:\DVD\MPC HomeCinema (x64)\mpc-hc64.exe" openwith "D:\DVD\MPC HomeCinema (x64)\mpc-hc64.exe"; "TMPGEnc|C:\Program Files (x86)\Pegasys Inc\TMPGEnc Authoring Works 4\TMPGEncAuthoringWorks4.exe" open "C:\Program Files (x86)\Pegasys Inc\TMPGEnc Authoring Works 4\TMPGEncAuthoringWorks4.exe"; "Video Joiner|D:\DVD\Boilsoft Video Joiner\EZMerge.exe" open "D:\DVD\Boilsoft Video Joiner\EZMerge.exe"; "VLC|D:\DVD\VLC\vlc.exe" openwith "D:\DVD\VLC\vlc.exe"; VID; /*** text file menu ***/ $txt = <<<DOC "NotePad++|D:\Tools\NotePad++\notepad++.exe" openwith "D:\Tools\NotePad++\notepad++.exe"; "PSPad|D:\Tools\PSPad\PSPad.exe" openwith "D:\Tools\PSPad\PSPad.exe"; "Notepad|C:\Windows\notepad.exe" openwith "C:\Windows\notepad.exe"; DOC; /*** Folder menu ***/ $dir = <<<FOLDER "Open Folder in new instance Thumbnail view|:viewthumbs" run """<xy>"" /new ""$folder"" /win=normal,10,10,1900,1060 /script=""::if(get('View') != '6') {#308};loadlayout('thumbs');""", , 0, 0; "Favorite Folders|:favs"; #550; end(1); "Favorite Files|:favfiles"; #564; end(1); FOLDER; /*** Copy/Move menu ***/ $CopyMove = <<<COMO "Copy|:copyto" #5; "Move|:moveto" #4; "Move to &Tools|:moveto"; moveto "H:\Misc\tools"; "-" "Sort...|:sort" #320; "Columns...|D:\Graphics\Icons\table-select-column-fatcow.ico" #360; "View...|:viewthumbs" #301; "-" "New|:newfolder" #230; COMO; //***note: if you're not going to use Favorite Folders in conjunction with another menu you don't need this section //***you can simply use #550 $FavFolderCount = getkey("Count", "Favorites"); if($FavFolderCount == "0") {$FFs = "No favorite folders";} else { $FFs = ""; $i = 1; while ($i <= $FavFolderCount) { $a = getkey("Fav$i", "Favorites"); $FFs = $FFs . $a . "<crlf>"; $i++; } } $FavFolders = trim($FFs, "<crlf>", 'R'); if(exists("<selitem>") == 1) { $selext = getpathcomponent("<selitem>", "ext"); if(gettokenindex($selext, "jpg|gif|png|ico", '|', 'i')) {load "$image;<crlf>-<crlf>$CopyMove", ,s; end(1);} //load image and CopyMove menus together elseif(gettokenindex($selext, "avi|mp4|wmv|wma", '|', 'i')) {load "$vid", , s; end(1);} //load video menu elseif(gettokenindex($selext, "ini|txt|nfo|inf|reg|ps1|vbs", '|', 'i')) {load "$txt", , s; end(1);} //load textfile menu elseif("$selext" == "xys") {load("<selitem>"); end(1);} //no menu - example showing how you can automatically run an XY script on a right click on white elseif("$selext" == "ahk") {openwith "D:\Tools\NotePad++\notepad++.exe"; end(1);} //no menu - example to open an AHK file for editing else {load "$FavFolders;<crlf>-<crlf>$CopyMove", ,s; end(1);} } elseif(exists("<selitem>") == 2) { perm $folder = "<curitem>"; load "$dir", , s; end(1); } else { // when none of the other listed conditions or comparisons are met load "$FavFolders;<crlf>-<crlf>$CopyMove", ,s; end(1) //this takes care of the "nothing selected" condition //you can simply use #550 to load Favorite Folders (or Files #564) alone here or whatever script you } "_Terminate"; unset $folder; //you don't need this line or "_Terminate"; if you don't use variable $folder above
Thanks,
Ken
Edit1: Modified the script to use SC gettokenindex rather than LikeI comparisons as per PeterH suggestion.
Edit2: Modified the "load" statement that uses the variable '$image' to show how to display 2 menus together (i.e., the Image menu and Copy move menu) as one menu with a separator between them
Edit3: Incorporated the use of new XY variable <selitem> and cleaned up the "if" , "elseif", and "else" structure. Also included obtaining "Favorite Folders" if you want to combine them with another menu. Otherwise you can leave that section out.
Re: [Script] WhiteSpaceCtxMenu
So did you adapt the code in the section for txt files to list the programs that you would like to pop up for txt files?
Or expected some miracle instead?
Or expected some miracle instead?
Ralph 
(OS: W11 24H2 Home x64 - XY: Current x32 beta - Office 2024 32-bit - Display: 1920x1080 @ 125%)
(OS: W11 24H2 Home x64 - XY: Current x32 beta - Office 2024 32-bit - Display: 1920x1080 @ 125%)
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
I wasn't suppose to adapt all the code; only sections of the code I want for specific file types ? 
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
Can I wish for a miracle?
Hey CookieMonster, if I were you, first I'd modify your white space entry in the XYplorer.ini file to load a script called which you know works to make sure that part of the setup is working as it should. Save the ini file and exit XY without saving (i.e., all the normal stuff when you change the ini file). Right click in the white space to see if the script you specified runs. If the White space test works, go ahead and change it back to refer to the "WhiteSpaceCtxMenu.xys" script. Then I'd modify part of the script to see if it's working for you. For example, in the text file section of the script, change one of the entries like the "Notepad++.exe" entry to a text editor that you use. You could even use Windows notepad.exe usually "C:\Windows\notepad.exe". So the text file section in the WhiteSpaceCtxMenu.xys would be:After this is done/saved, then select a text file in the list and right click in the White Space in the list and the modified menu should come up. If you select NotePad it should open the file. I just tested the above change in my version and it worked fine. Good luck. No miracles required. I've been getting a lot of use out of that script. It's become my most used script actually.
Edit: Note, when you don't have one of the programs I have listed installed on your system, the menu should still display, but with an exclamation icon since XY won't be able to locate the program or its icon. So obviously it won't work. I didn't even notice that I had notepad.exe in the script already.
Hey CookieMonster, if I were you, first I'd modify your white space entry in the XYplorer.ini file to load a script called which you know works to make sure that part of the setup is working as it should. Save the ini file and exit XY without saving (i.e., all the normal stuff when you change the ini file). Right click in the white space to see if the script you specified runs. If the White space test works, go ahead and change it back to refer to the "WhiteSpaceCtxMenu.xys" script. Then I'd modify part of the script to see if it's working for you. For example, in the text file section of the script, change one of the entries like the "Notepad++.exe" entry to a text editor that you use. You could even use Windows notepad.exe usually "C:\Windows\notepad.exe". So the text file section in the WhiteSpaceCtxMenu.xys would be:
Code: Select all
/*** text file menu ***/
$txt = <<<DOC
"NotePad|C:\Windows\notepad.exe" openwith "C:\Windows\notepad.exe";
"NotePad++|D:\Tools\NotePad++\notepad++.exe" openwith "D:\Tools\NotePad++\notepad++.exe";
"PSPad|D:\Tools\PSPad\PSPad.exe" openwith "D:\Tools\PSPad\PSPad.exe";
DOC;
Edit: Note, when you don't have one of the programs I have listed installed on your system, the menu should still display, but with an exclamation icon since XY won't be able to locate the program or its icon. So obviously it won't work. I didn't even notice that I had notepad.exe in the script already.
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
klownboy - I followed the instructions exactly, when selecting a text file, then right clicking on white space, the menu show only programs associated with text files doesn't load ?
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
You have to test to see if your right-click on white space function is working for you. Did you first attempt to refer to a working script in place of the "WhiteSpaceCtxMenu.xys" script? Modify XYplorer.ini such that...Save it and exit XY without saving. Pick some script which will run regardless of circumstances even if it's a one liner like text "I'm working here!"; Right click on white in the list panel to see if that script runs for you or not.
Code: Select all
CEA_ListRightClickOnWhite=6
CEA_ListRightClickOnWhite_Script=load "<xyscripts>\Known2WorkScriptHere.xys"-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
When I modify the two; CEA_LightRightclickOnWhite in XYplorer.ini as mentioned in the first post, then save XYplorer.ini, oddly enough, when I open XYplorer.ini to verify all is good; the changes I made and saved are reverted back to, for example; CEA_LightRightclickOnWhite=0, instead of 6 ? 
-
Stef123
Re: [Script] WhiteSpaceCtxMenu
You may be running into the same snag again, try whatever you did last time when it happened:CookieMonster wrote:When I modify the two; CEA_LightRightclickOnWhite in XYplorer.ini as mentioned in the first post, then save XYplorer.ini, oddly enough, when I open XYplorer.ini to verify all is good; the changes I made and saved are reverted back to, for example; CEA_LightRightclickOnWhite=0, instead of 6 ?
http://www.xyplorer.com/xyfc/viewtopic. ... 30#p123607
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: [Script] WhiteSpaceCtxMenu
You remember that klownboy wrote: "Save it and exit XY without saving."
As exiting XY *with* save overwrites the .ini with all in-storage values.
As exiting XY *with* save overwrites the .ini with all in-storage values.
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
The proxy script as mentioned to create by klownboy works, except the WhiteSpaceCtxMenu isn't working with a text file select and right clicking in white space 
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
So then, the little test script works when you click on white space, but the WhiteSpaceCtxMenu.xys script does not. I take it, you do not get a menu popping up similar to this when you have a text file selected and you click on white space?There are many heredoc statements in the script. Could you have an alignment issues. The lead-in Heredoc lines like this should not be left justified (i.e., they should have a few spaces before them as in my post above). I ask because I didn't provide the script as a downloadable file (though maybe I should have). I'm sure quite a few people have used the script, modified to their liking of course, and would have reported issues. I'm not aware of any other setting in XY that might be affecting the proper running of the script and I assume you are using XY's latest version anyway.
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
No, that is correct, I don't get any menu.klownboy wrote:So then, the little test script works when you click on white space, but the WhiteSpaceCtxMenu.xys script does not. I take it, you do not get a menu popping up similar to this when you have a text file selected and you click on white space?
What do you mean by alignment issues ?
XYplorer Beta Club