[Script] WhiteSpaceCtxMenu

Discuss and share scripts and script files...
Post Reply
highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

I was originally informed to put the full path of Ps
Put it where?
I get is a dubious error
Which is?

Seriously, is this some kind of game show?
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

I after going back and forth quite a bit I lost rack that you were using the variable (via heredoc) in this case. When you want to open a menu especially when you have multiple menu items to select from, you want to use the variable created using heredoc, $psd. So you use the load statement to load the script hence load statement of: [CASE1 - using variable created using heredoc]

Code: Select all

elseif($selext LikeI "psd") {load "$psd", , s; end (1)}
Whereas,when you simply want to open the selected psd type file in Photoshop with no menu (i.e., menu not necessary since all you want to do is run the selected file with only one program, Photoshop - no other choices). This is what I did for the XYS files and AHK file in the example script. You don't see variables/heredoc statements for these because there's no need. There's no menu - the specified program will open the the selected file immediately.[CASE 2 - no variable created using heredoc]

Code: Select all

elseif($selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);} 
The first case works like the second case in this situation (showing no menu) because you only have one menu item. XY will run the one menu item immediately as I've already stated. Does that help clarify?

Highend, I'm really trying to be good but I'm close... :whistle:
Last edited by klownboy on 12 Jul 2015 20:10, edited 1 time in total.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

The first case works like the second case in this situation (showing no menu) because you only have one menu item. XY will run the one menu item immediately as I've already stated. Does that help clarify?
When you say the first case and second case, what code are you referring too, so we can refresh this thread for clarity ? :)

You say both snippets of code should work; in practice only one is working, that one being this; which I don't understand the syntax.

Code: Select all

elseif($selext LikeI "psd") {load "$psd", , s; end (1)}
It should be irrelevant regardless what snippet of code I use, as from my perception we both know all PSD files should strictly open in Ps, with no menu, as I said previously, I will be adding a menu but that is in progress, that is not happening as stated.

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

Highend, I'm really trying to be good but I'm close...
Don't know why you're still trying :appl:
Programming / Scripting means to be: being precise, "dubious error" (with no screenshot / or c&p) is far, far, far away from that. Not answering questions but asking the same questions over and over again (although they have been answered already) is... <choose an answer yourself>
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

highend wrote:
Highend, I'm really trying to be good but I'm close...
Don't know why you're still trying :appl:
Programming / Scripting means to be: being precise, "dubious error" (with no screenshot / or c&p) is far, far, far away from that. Not answering questions but asking the same questions over and over again (although they have been answered already) is... <choose an answer yourself>
I know about being precise; you want a screenshot !

Image

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

Post the complete code...
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

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" openwith "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 LikeI "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 LikeI "ahk") {openwith "C:\Windows\notepad.exe"; end(1);}   //no menu - example to open an AHK file for editing
        elseif($selext LikeI "psd") {openwith "C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe"; end(1);}
        else {#550; end(1);}
   }
   else {
        #550
        }

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

Re: [Script] WhiteSpaceCtxMenu

Post by klownboy »

:cry: Look at the first post CookieMonster. What you posted is nothing like that. I had a heredoc to create $txt variable. You are butchering the script and expecting it to work. You can't pick and choose lines of code and through them together. As highend stated, coding has to be exact. The smallest mistake results in the script failing. I know, I've been learning from scratch with no computer background.

Edit: So in looking at the above you must have left lines out of the posted code. I don't have PhotoShop, but I tested the elseif's similar to the 'psd' code line with other programs and they ran fine.
@highend could it be quoting in this case (needing triple in lieu of single quotes)...it does run for CookieMonster using the $psd variable created with heredoc with "load $psd, ,s"
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

This was the code in the original post, considering, I didn't need all of this code, it was reduced, you posted a reduced version of the code with only the heredoc for text files and I created the heredoc for psd files.

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
I've never touched the code besides juggling with quotation marks. Look at this post http://www.xyplorer.com/xyfc/viewtopic. ... 75#p126058, the only difference in the code is you did not declare an absolute path for Ps; declaring an absolute path should work, no ?

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

Code posted on: 12 Jul 2015 21:53
I don't see any dubious error warnings when executing that code, regardless if Syntax Checking is on or off... and it works fine when a .psd is selected...
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

highend wrote:
Code posted on: 12 Jul 2015 21:53
I don't see any dubious error warnings when executing that code, regardless if Syntax Checking is on or off... and it works fine when a .psd is selected...
This code; http://www.xyplorer.com/xyfc/viewtopic. ... 90#p126088 not what I posted; you can be literal in code; not in language. :eh:

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

Your link leads exactly to the code that I'm commenting on...
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

Why, when I have a PSD selected, then right-click on white space do I get the error I posted here http://www.xyplorer.com/xyfc/viewtopic. ... 90#p126081 ?

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Script] WhiteSpaceCtxMenu

Post by highend »

Upload the .xys file with that code...
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: [Script] WhiteSpaceCtxMenu

Post by CookieMonster »

highend wrote:Upload the .xys file with that code...
https://www.dropbox.com/s/ge11jh9mmqvov ... u.xys?dl=0 to XYS file.

Post Reply