I simply meant if the lines of code are fully over to the left side where they need to be and in other cases have a few spaces in front of the code lines (i.e., make sure you haven't made any changes of that nature to the code in the first post).CookieMonster wrote:What do you mean by alignment issues ?
[Script] WhiteSpaceCtxMenu
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
I can verify that I haven't made any alignment issues; no one else has problem with running the script but me, arghhh !

-
Stef123
Re: [Script] WhiteSpaceCtxMenu
To ease your mind, let me tell you that I struggled enormously with several syntax issues, notably Heredoc naming and alignment, but also things like quotes-handling and bracketing. Hardly ever do I get my scripts working on the first go-around. I've spent considerable time re-reading scripting helpCookieMonster wrote:no one else has problem with running the script but me, arghhh !![]()
![]()
![]()
@Ken
Yes, a a ready-made .xys file helps non-programmers like me to take some of the frustration out of scripting. Makes it easier to tweak and adjust when you can be sure you already have a working syntax in place.
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
Stef - From what I can see, there are no syntax issues; although I understand syntax issues, learning different programming languages I do make quite a few of those mistakes. 
Why is this not working, if there are no syntax issues, it's really frustrating; must I create a video to demonstrate what I'm doing ?

Why is this not working, if there are no syntax issues, it's really frustrating; must I create a video to demonstrate what I'm doing ?
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
Hi CookieMonster, I uploaded a zip version of the script on the first post. Try that to eliminate possible syntax or copy/paste issues before we try anything else.
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
I replaced my WhiteSpaceCtxMenu.xys with the one you uploaded and it workedklownboy wrote:Hi CookieMonster, I uploaded a zip version of the script on the first post. Try that to eliminate possible syntax or copy/paste issues before we try anything else.
When I remove everything from the script that you uploaded and leave only what you see below, as I had previously, it doesn't work ?
/*** 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;
-
Stef123
Re: [Script] WhiteSpaceCtxMenu
Well, that may explain it, imo - but you better wait for Ken or someone else with more expertise to confirm it.CookieMonster wrote:[When I remove everything from the script that you uploaded and leave only what you see below, as I had previously, it doesn't work ?
/*** 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;
You define the variable "$txt" - but then you do nothing with it, it simply sits there and waits and waits and waits.....
What's missing in your script - if you really left out EVERYTHING else - is the decision-making part, the section that decides what's gonna happen based on the current selection (if any) and its extension.
So what you really need to include - and adjust - is the bottom part of the script, starting with
Code: Select all
if (exists("<selitem>") == 1) {
$selext = getpathcomponent("<selitem>", "ext");
.......
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
Hey CookieMonster, glad to hear it finally worked for you. Using that portion you showed by itself will not work. That's only the heredoc section for a menu that displays if you have a text file selected. But, it also needs the section which actually runs, or I should say loads the heredoc created variable menus based on file type (extension). You have to include the section starting with if(exists("<selitem>") == 1) { all the way down to but not including: "_FavFolders : _FavFolders";
I would suggest that you simply modify each section for the different file types to specify your own programs. That's what make the script powerful...having it set to bring up a different menu that you've personally created for each file type.
Thanks Stef123, you're absolutely correct. I had this mostly written when I saw your post. If it was a little later I wouldn't have bothered.
I would suggest that you simply modify each section for the different file types to specify your own programs. That's what make the script powerful...having it set to bring up a different menu that you've personally created for each file type.
Thanks Stef123, you're absolutely correct. I had this mostly written when I saw your post. If it was a little later I wouldn't have bothered.
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
Code: Select all
/*** text file menu ***/
if(exists("<selitem>") == 1) {
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);}
}
$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;$FavFolders;
$CopyMove
What is wrong with the code; so I can customize the menu for various file types ?
-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
There's nothing wrong with the original. You can use its structure as is to have it work for various file types you just have to change the programs referred to in the various menus. You bastardized it, which is fine, but you did it incorrectly. You can't get rid of the lead "if" statement and start off with "elseif". As I said, you should be modifying the original with your own programs. You can even get rid of file types, but you have to keep that load section in tact unless you really know what you're doing. You also deleted the variable $selext line. You get $FavFolders and $CopyMove because you deleted those sections of the script. Try this below. If a text file is not selected it will bring up Favorite Folders. If a "ahk" file is selected it will open it immediately in notepad. If a "xys" file is selected it will load it.CookieMonster wrote:What is wrong with the code; so I can customize the menu for various file types ?
Code: Select all
/*** 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;
if(exists("<selitem>") == 1) {
$selext = getpathcomponent("<selitem>", "ext");
if(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 "C:\Windows\notepad.exe"; end(1);} //no menu - example to open an AHK file for editing
else {#550; end(1);}
}
else {
#550
}-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
Ahh, the condition loads the variables, silly me, why I butchered the script as I did was a dumb mistake on my part.
Klownboy - The script you recently posted in your most recent message works. I have a question, how did you get the custom menu for XYS files when it's not calling a variable ?
Klownboy - The script you recently posted in your most recent message works. I have a question, how did you get the custom menu for XYS files when it's not calling a variable ?
Code: Select all
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-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
It's not written to provide a custom menu for that situation. That was an example of how to load the script immediately with no menu (i.e., select the script, the file with an "xys" extension, and right click on white and it should run (no menu)). You could have a menu come up if you wanted, but probably the only choices you would have are: Load the script & Edit the script. Though you could have: Load the script (with stepping) & Load script (no stepping) & Edit script. So you'd make a variable using heredoc as we did for text files "$txt". Try it if you like and see if can make it work. Remember, besides writing the new section for an "xys" files (call it variable $xys), you need to add a line which loads $xys after the line which loads $txt. Show us what you come up with. If it doesn't work I'll help you out. Good luck.CookieMonster wrote:The script you recently posted in your most recent message works. I have a question, how did you get the custom menu for XYS files when it's not calling a variable ?
-
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
This is what I came up with for PSD files before I begin adding more different types.
Code: Select all
/*** 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;
$PSD = <<<PSD
"Photoshop|"C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe""
PSD;
if(exists("<selitem>") == 1) {
$selext = getpathcomponent("<selitem>", "ext");
if(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 "C:\Windows\notepad.exe"; end(1);} //no menu - example to open an AHK file for editing
elseif("$select == "psd")
else {#550; end(1);}
}
else {
#550
}-
klownboy
- Posts: 4402
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: [Script] WhiteSpaceCtxMenu
Hi CookieMonster, the only problem is, you only have one menu item. Not much sense in having a menu with one item.
Don't you have other graphics program as well like viewers (e.g., Irfanview, ImageEye, etc) that you could add to your menu. Or, why not have a more general image menu similar to one I have in the original version. All you would have to do is add the "psd" extension to the list of extensions in the $image variable section. You'd get rid of references to programs you don't have installed and add one for Photoshop. So if the file selected is a psd you would choose Photoshop from the menu. For your case above though, you need to add the open or openwith statement after the elseif...Another option would be to handle it like I did for "xys" script files or "ahk" files - automatically run the file with Photoshop when you right click on white if the extension is "psd" with no menu. As you can see there are many ways to handle individual cases which is what makes it powerful. It just a matter of setting it up the way you want it to work.
Code: Select all
elseif("$select" == "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);} -
CookieMonster
Re: [Script] WhiteSpaceCtxMenu
Sorry, I don't understandYou'd get rid of references to programs you don't have installed and add one for Photoshop.
The name of the variable matters, in this case, if it's PSD it will, (maybe I'll answer my own question, with this question) only run the menu if a PSD file is selected ?
$txt = <<<DOC
Code: Select all
"Photoshop|"C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"
XYplorer Beta Club